import { extname } from 'node:path';
/**
* A script block extracted from an SFC (Vue or Svelte) source file.
*
* `content` – The raw JS/TS text between the opening and closing
* `` block in an SFC (Vue or
* Svelte). Works for both instance scripts and module/setup scripts.
*
* Limitations (shared with `@intlayer/svelte-compiler`'s own approach):
* - A literal `` inside a string or comment inside the script block
* would prematurely close the match. This is an accepted trade-off for the
* vast majority of real-world files.
*/
const SFC_SCRIPT_RE = /`
// match[1]: the attribute string (may be empty)
// match[2]: the script content
const attrs = match[1] ?? '';
const openingTagLength = '