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

Commit 74c66b7

Browse files
ConduitryRich-Harris
authored andcommitted
Server-side preload check fixes (fixes #575, #594, #598)
1 parent 9540383 commit 74c66b7

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

package-lock.json

+9-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@
5050
"rollup-plugin-replace": "^2.1.0",
5151
"rollup-plugin-string": "^2.0.2",
5252
"rollup-plugin-sucrase": "^2.1.0",
53-
"rollup-plugin-svelte": "^5.0.1",
53+
"rollup-plugin-svelte": "^5.0.3",
5454
"sade": "^1.4.2",
5555
"sirv": "^0.2.2",
5656
"sucrase": "^3.9.5",
57-
"svelte": "^3.0.0-alpha27",
58-
"svelte-loader": "^2.12.0",
57+
"svelte": "^3.0.0-beta.11",
58+
"svelte-loader": "^2.13.3",
5959
"webpack": "^4.29.0",
6060
"webpack-format-messages": "^2.0.5",
6161
"yootils": "0.0.14"

rollup.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { builtinModules } from 'module';
99
const external = [].concat(
1010
Object.keys(pkg.dependencies),
1111
Object.keys(process.binding('natives')),
12-
'sapper/core.js'
12+
'sapper/core.js',
13+
'svelte/compiler'
1314
);
1415

1516
function template(kind, external) {
@@ -65,4 +66,4 @@ export default [
6566
})
6667
]
6768
}
68-
];
69+
];

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)