Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit add823a

Browse files
committed
fix compilation in preload check
strip out style blocks (#594)
1 parent d8c4730 commit add823a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/core/create_manifest_data.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ export default function create_manifest_data(cwd: string): ManifestData {
1717

1818
if (/preload/.test(source)) {
1919
try {
20-
const { stats } = svelte.compile(source, {
21-
generate: false,
22-
onwarn: () => {}
23-
});
24-
return !!stats.vars.find((variable: any) => variable.module && variable.export_name === 'preload');
20+
const { vars } = svelte.compile(source.replace(/<style\b[^>]*>[^]*?<\/style>/g, ''), { generate: false });
21+
return vars.some((variable: any) => variable.module && variable.export_name === 'preload');
2522
} catch (err) {}
2623
}
2724

@@ -346,4 +343,4 @@ function get_pattern(segments: Part[][], add_trailing_slash: boolean) {
346343
}).join('') +
347344
(add_trailing_slash ? '\\\/?$' : '$')
348345
);
349-
}
346+
}

0 commit comments

Comments
 (0)