Skip to content

Commit be458aa

Browse files
committed
chore: simpler regex
1 parent c2271c0 commit be458aa

File tree

1 file changed

+6
-6
lines changed
  • packages/vite/src/node/optimizer

1 file changed

+6
-6
lines changed

packages/vite/src/node/optimizer/scan.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i
359359
const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i
360360
const langRE = /\blang\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i
361361
const svelteScriptModuleRE =
362-
/\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))|\b(?<!=)(?<!['"])(module)\b(?!['"])(?![^>]+['"]\s*>)/i
362+
/\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i
363+
const svelteModuleRE = /\s(module)\b/i
363364

364365
function esbuildScanPlugin(
365366
environment: ScanEnvironment,
@@ -568,12 +569,11 @@ function esbuildScanPlugin(
568569
// star exports, we need to ignore exports in <script>
569570
if (p.endsWith('.svelte')) {
570571
const contextMatch = svelteScriptModuleRE.exec(openTag)
572+
const moduleMatch = svelteModuleRE.exec(openTag)
571573
const context =
572-
contextMatch &&
573-
(contextMatch[1] ||
574-
contextMatch[2] ||
575-
contextMatch[3] ||
576-
contextMatch[4])
574+
(contextMatch &&
575+
(contextMatch[1] || contextMatch[2] || contextMatch[3])) ||
576+
(moduleMatch && moduleMatch[1])
577577

578578
if (context !== 'module') {
579579
addedImport = true

0 commit comments

Comments
 (0)