@@ -15,15 +15,16 @@ import { CompileResult } from './interfaces';
15
15
import RollupResult from './RollupResult' ;
16
16
17
17
const stderr = console . error . bind ( console ) ;
18
- const INJECT_STYLES_ID = 'inject_styles' ;
18
+ const INJECT_STYLES_NAME = 'inject_styles' ;
19
+ const INJECT_STYLES_ID = 'inject_styles.js' ;
19
20
20
21
let rollup : any ;
21
22
22
23
const inject_styles = `
23
- export default files => {
24
- return Promise.all(files.map(file => new Promise((fulfil, reject) => {
25
- const href = new URL(file, import.meta.url);
26
- let link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
24
+ export default function( files) {
25
+ return Promise.all(files.map(function( file) { return new Promise(function (fulfil, reject) {
26
+ var href = new URL(file, import.meta.url);
27
+ var link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
27
28
if (!link) {
28
29
link = document.createElement('link');
29
30
link.rel = 'stylesheet';
@@ -33,10 +34,10 @@ export default files => {
33
34
if (link.sheet) {
34
35
fulfil();
35
36
} else {
36
- link.onload = () => fulfil();
37
+ link.onload = function () { return fulfil() } ;
37
38
link.onerror = reject;
38
39
}
39
- })));
40
+ })} ));
40
41
};` . trim ( ) ;
41
42
42
43
const get_entry_point_output_chunk = ( bundle : OutputBundle , entry_point ?: string ) => {
@@ -128,12 +129,12 @@ export default class RollupCompiler {
128
129
this . emitFile ( {
129
130
type : 'chunk' ,
130
131
id : INJECT_STYLES_ID ,
131
- name : INJECT_STYLES_ID ,
132
- preserveSignature : 'strict '
132
+ name : INJECT_STYLES_NAME ,
133
+ preserveSignature : 'allow-extension '
133
134
} ) ;
134
135
} ,
135
136
load ( id : string ) {
136
- return id === INJECT_STYLES_ID ? { code : inject_styles , moduleSideEffects : 'no-treeshake' } : null ;
137
+ return id === INJECT_STYLES_ID ? inject_styles : null ;
137
138
} ,
138
139
resolveId ( importee : string , importer : string ) {
139
140
return importee === INJECT_STYLES_ID ? INJECT_STYLES_ID : null ;
@@ -145,7 +146,7 @@ export default class RollupCompiler {
145
146
if ( targetModuleId ) {
146
147
return {
147
148
left : 'Promise.all([import(' ,
148
- right : `), ___SAPPER_CSS_INJECTION___${ Buffer . from ( targetModuleId ) . toString ( 'hex' ) } ___]).then(x => x[0])`
149
+ right : `), ___SAPPER_CSS_INJECTION___${ Buffer . from ( targetModuleId ) . toString ( 'hex' ) } ___]).then(function(x) { return x[0]; } )`
149
150
} ;
150
151
} else {
151
152
return {
0 commit comments