Skip to content

Commit

Permalink
6.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Sep 13, 2019
1 parent a40a82e commit de84d01
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 223 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
**SystemJS 6.1.0 (2019/09/11) - Minor Changes**
SystemJS 6.1.1 (2019/09/13)
* Fixes a bug where imports before the import map load might not apply the import map (https://github.com/systemjs/systemjs/issues/2024, @joeldenning)
* Fixes the module-types extra output which was incorrectly referencing an import (https://github.com/systemjs/systemjs/issues/2027, @joeldenning)

SystemJS 6.1.0 (2019/09/11) - Minor Changes
* Add support for `<script type="systemjs-module" src="import:foo">` (https://github.com/systemjs/systemjs/pull/2015)

**SystemJS 6.0.0 (2019/08/29) - Major Changes**
Expand Down
171 changes: 87 additions & 84 deletions dist/extras/module-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,94 @@
* Loads JSON, CSS, Wasm module types based on file extensions
* Supports application/javascript falling back to JS eval
*/
import { systemJSPrototype } from '../system-core';
const instantiate = systemJSPrototype.instantiate;
systemJSPrototype.instantiate = function (url, parent) {
const loader = this;
const ext = url.slice(url.lastIndexOf('.'));
switch (ext) {
case '.css':
return loadDynamicModule(function (_export, source) {
// Relies on a Constructable Stylesheet polyfill
const stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(source);
_export('default', stylesheet);
});
case '.html':
return getSourceRes().then(function (res) {
return maybeJSFallback(res) || loadError("'.html' modules not implemented");
});
case '.json':
return loadDynamicModule(function (_export, source) {
_export('default', JSON.parse(source));
});
case '.wasm':
return getSourceRes().then(function (res) {
return maybeJSFallback(res) ||
(WebAssembly.compileStreaming ? WebAssembly.compileStreaming(res) : res.arrayBuffer().then(WebAssembly.compile));
})
.then(function (module) {
const deps = [];
const setters = [];
const importObj = {};

// we can only set imports if supported (eg early Safari doesnt support)
if (WebAssembly.Module.imports)
WebAssembly.Module.imports(module).forEach(function (impt) {
const key = impt.module;
if (deps.indexOf(key) === -1) {
deps.push(key);
setters.push(function (m) {
importObj[key] = m;
});
}
});

return [deps, function (_export) {
return {
setters: setters,
execute: function () {
return WebAssembly.instantiate(module, importObj)
.then(function (instance) {
_export(instance.exports);
});
}
};
}];
});
}
return instantiate.apply(this, arguments);
(function() {
const systemPrototype = System.constructor.prototype;
const instantiate = systemPrototype.instantiate;

function getSourceRes () {
return fetch(url).then(function (res) {
if (!res.ok)
loadError(res.status + ' ' + res.statusText);
return res;
});
}
function maybeJSFallback (res) {
const contentType = res.headers.get('content-type');
// if the resource is sent as application/javascript, support eval-based execution
if (contentType && contentType.match(/^application\/javascript(;|$)/)) {
return res.text().then(function (source) {
(0, eval)(source);
return loader.getRegister();
systemPrototype.instantiate = function (url, parent) {
const loader = this;
const ext = url.slice(url.lastIndexOf('.'));
switch (ext) {
case '.css':
return loadDynamicModule(function (_export, source) {
// Relies on a Constructable Stylesheet polyfill
const stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(source);
_export('default', stylesheet);
});
case '.html':
return getSourceRes().then(function (res) {
return maybeJSFallback(res) || loadError("'.html' modules not implemented");
});
case '.json':
return loadDynamicModule(function (_export, source) {
_export('default', JSON.parse(source));
});
case '.wasm':
return getSourceRes().then(function (res) {
return maybeJSFallback(res) ||
(WebAssembly.compileStreaming ? WebAssembly.compileStreaming(res) : res.arrayBuffer().then(WebAssembly.compile));
})
.then(function (module) {
const deps = [];
const setters = [];
const importObj = {};

// we can only set imports if supported (eg early Safari doesnt support)
if (WebAssembly.Module.imports)
WebAssembly.Module.imports(module).forEach(function (impt) {
const key = impt.module;
if (deps.indexOf(key) === -1) {
deps.push(key);
setters.push(function (m) {
importObj[key] = m;
});
}
});

return [deps, function (_export) {
return {
setters: setters,
execute: function () {
return WebAssembly.instantiate(module, importObj)
.then(function (instance) {
_export(instance.exports);
});
}
};
}];
});
}
return instantiate.apply(this, arguments);

function getSourceRes () {
return fetch(url).then(function (res) {
if (!res.ok)
loadError(res.status + ' ' + res.statusText);
return res;
});
}
}
function loadDynamicModule (createExec) {
return getSourceRes().then(function (res) {
return maybeJSFallback(res) || res.text().then(function (source) {
return [[], function (_export) {
return { execute: createExec(_export, source) };
}];
function maybeJSFallback (res) {
const contentType = res.headers.get('content-type');
// if the resource is sent as application/javascript, support eval-based execution
if (contentType && contentType.match(/^application\/javascript(;|$)/)) {
return res.text().then(function (source) {
(0, eval)(source);
return loader.getRegister();
});
}
}
function loadDynamicModule (createExec) {
return getSourceRes().then(function (res) {
return maybeJSFallback(res) || res.text().then(function (source) {
return [[], function (_export) {
return { execute: createExec(_export, source) };
}];
});
});
});
}
function loadError (msg) {
throw Error(msg + ', loading ' + url + (parent ? ' from ' + parent : ''));
}
};
}
function loadError (msg) {
throw Error(msg + ', loading ' + url + (parent ? ' from ' + parent : ''));
}
};
})();
2 changes: 1 addition & 1 deletion dist/extras/module-types.min.js

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

2 changes: 1 addition & 1 deletion dist/extras/module-types.min.js.map

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

2 changes: 1 addition & 1 deletion dist/s.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SJS 6.1.0
* SJS 6.1.1
* Minimal SystemJS Build
*/
(function () {
Expand Down

0 comments on commit de84d01

Please sign in to comment.