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

IE 11 support #1525

Merged
merged 1 commit into from Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"html-minifier": "^4.0.0",
"http-link-header": "^1.0.2",
"shimport": "^1.0.1",
"shimport": "^2.0.3",
"source-map": "^0.6.1",
"sourcemap-codec": "^1.4.6",
"string-hash": "^1.1.3"
Expand Down
23 changes: 12 additions & 11 deletions src/core/create_compilers/RollupCompiler.ts
Expand Up @@ -15,15 +15,16 @@ import { CompileResult } from './interfaces';
import RollupResult from './RollupResult';

const stderr = console.error.bind(console);
const INJECT_STYLES_ID = 'inject_styles';
const INJECT_STYLES_NAME = 'inject_styles';
const INJECT_STYLES_ID = 'inject_styles.js';

let rollup: any;

const inject_styles = `
export default files => {
return Promise.all(files.map(file => new Promise((fulfil, reject) => {
const href = new URL(file, import.meta.url);
let link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
export default function(files) {
return Promise.all(files.map(function(file) { return new Promise(function(fulfil, reject) {
var href = new URL(file, import.meta.url);
var link = document.querySelector('link[rel=stylesheet][href="' + href + '"]');
if (!link) {
link = document.createElement('link');
link.rel = 'stylesheet';
Expand All @@ -33,10 +34,10 @@ export default files => {
if (link.sheet) {
fulfil();
} else {
link.onload = () => fulfil();
link.onload = function() { return fulfil() };
link.onerror = reject;
}
})));
})}));
};`.trim();

const get_entry_point_output_chunk = (bundle: OutputBundle, entry_point?: string) => {
Expand Down Expand Up @@ -128,12 +129,12 @@ export default class RollupCompiler {
this.emitFile({
type: 'chunk',
id: INJECT_STYLES_ID,
name: INJECT_STYLES_ID,
preserveSignature: 'strict'
name: INJECT_STYLES_NAME,
preserveSignature: 'allow-extension'
});
},
load(id: string) {
return id === INJECT_STYLES_ID ? { code: inject_styles, moduleSideEffects: 'no-treeshake' } : null;
return id === INJECT_STYLES_ID ? inject_styles : null;
},
resolveId(importee: string, importer: string) {
return importee === INJECT_STYLES_ID ? INJECT_STYLES_ID : null;
Expand All @@ -145,7 +146,7 @@ export default class RollupCompiler {
if (targetModuleId) {
return {
left: 'Promise.all([import(',
right: `), ___SAPPER_CSS_INJECTION___${Buffer.from(targetModuleId).toString('hex')}___]).then(x => x[0])`
right: `), ___SAPPER_CSS_INJECTION___${Buffer.from(targetModuleId).toString('hex')}___]).then(function(x) { return x[0]; })`
};
} else {
return {
Expand Down