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

Commit ea3236a

Browse files
committed
Chrome 54 support
1 parent cfa5a42 commit ea3236a

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

package-lock.json

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"html-minifier": "^4.0.0",
2323
"http-link-header": "^1.0.2",
24-
"shimport": "^1.0.1",
24+
"shimport": "^2.0.0",
2525
"source-map": "^0.6.1",
2626
"sourcemap-codec": "^1.4.6",
2727
"string-hash": "^1.1.3"

src/core/create_compilers/RollupCompiler.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@ const stderr = console.error.bind(console);
1919
let rollup: any;
2020

2121
const inject_styles = `
22-
export default files => {
23-
return Promise.all(files.map(file => new Promise((fulfil, reject) => {
24-
const href = new URL(file, import.meta.url);
25-
let link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
22+
export default function(files) {
23+
return Promise.all(files.map(function(file) { return new Promise(function(fulfil, reject) {
24+
var scriptPath;
25+
try {
26+
if (typeof import.meta.url !== 'string') {
27+
throw new Error();
28+
}
29+
scriptPath = import.meta.url;
30+
} catch(err) {
31+
var line = err.stack.match(/(https?:\\/\\/.+):\\d+:\\d+/g)[0];
32+
scriptPath = line.match(/(https?:\\/\\/.+):\\d+:\\d+/)[1]
33+
}
34+
var href = new URL(file, scriptPath);
35+
var link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
2636
if (!link) {
2737
link = document.createElement('link');
2838
link.rel = 'stylesheet';
@@ -32,10 +42,10 @@ export default files => {
3242
if (link.sheet) {
3343
fulfil();
3444
} else {
35-
link.onload = () => fulfil();
45+
link.onload = function() { return fulfil() };
3646
link.onerror = reject;
3747
}
38-
})));
48+
})}));
3949
};`.trim();
4050

4151
const get_entry_point_output_chunk = (bundle: OutputBundle, entry_point?: string) => {
@@ -130,7 +140,7 @@ export default class RollupCompiler {
130140
if (targetModuleId) {
131141
return {
132142
left: 'Promise.all([import(',
133-
right: `), ___SAPPER_CSS_INJECTION___${Buffer.from(targetModuleId).toString('hex')}___]).then(x => x[0])`
143+
right: `), ___SAPPER_CSS_INJECTION___${Buffer.from(targetModuleId).toString('hex')}___]).then(function(x) { return x[0]; })`
134144
};
135145
} else {
136146
return {

0 commit comments

Comments
 (0)