@@ -19,10 +19,20 @@ const stderr = console.error.bind(console);
19
19
let rollup : any ;
20
20
21
21
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 + '"]');
26
36
if (!link) {
27
37
link = document.createElement('link');
28
38
link.rel = 'stylesheet';
@@ -32,10 +42,10 @@ export default files => {
32
42
if (link.sheet) {
33
43
fulfil();
34
44
} else {
35
- link.onload = () => fulfil();
45
+ link.onload = function () { return fulfil() } ;
36
46
link.onerror = reject;
37
47
}
38
- })));
48
+ })} ));
39
49
};` . trim ( ) ;
40
50
41
51
const get_entry_point_output_chunk = ( bundle : OutputBundle , entry_point ?: string ) => {
@@ -130,7 +140,7 @@ export default class RollupCompiler {
130
140
if ( targetModuleId ) {
131
141
return {
132
142
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]; } )`
134
144
} ;
135
145
} else {
136
146
return {
0 commit comments