Skip to content

Commit

Permalink
Merge pull request #1488 from stealjs/name-extensions
Browse files Browse the repository at this point in the history
Give all extensions names
  • Loading branch information
matthewp committed Dec 28, 2018
2 parents e112945 + 7b4a55c commit f217d58
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 109 deletions.
4 changes: 2 additions & 2 deletions ext/npm-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var isWorker = typeof WorkerGlobalScope !== "undefined" && (self instanceof Work
var isElectron = isNode && !!process.versions.electron;
var isBrowser = typeof window !== "undefined" && (!isNode || isElectron) && !isWorker;

exports.addExtension = function(System){
exports.addExtension = function addNpmExtension(System){
if (System._extensions) {
System._extensions.push(exports.addExtension);
System._extensions.push(addNpmExtension);
}
/**
* Normalize has to deal with a "tricky" situation. There are module names like
Expand Down
35 changes: 17 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ var makeSteal = function(System){
// foo.bar! -> foo.bar!path/to/bar
// 2. if you load a javascript file e.g. require("./foo.js")
// normalize will remove the ".js" to load the module
addStealExtension(function (loader) {
addStealExtension(function addExt(loader) {
loader.ext = {};

var normalize = loader.normalize,
Expand Down Expand Up @@ -371,7 +371,7 @@ addStealExtension(function (loader) {
// Steal Locate Extension
// normalize a given path e.g.
// "path/to/folder/" -> "path/to/folder/folder"
addStealExtension(function (loader) {
addStealExtension(function addForwardSlash(loader) {
var normalize = loader.normalize;
var npmLike = /@.+#.+/;

Expand All @@ -396,7 +396,7 @@ addStealExtension(function (loader) {

// override loader.translate to rewrite 'locate://' & 'pkg://' path schemes found
// in resources loaded by supporting plugins
addStealExtension(function (loader) {
addStealExtension(function addLocateProtocol(loader) {
/**
* @hide
* @function normalizeAndLocate
Expand Down Expand Up @@ -492,7 +492,7 @@ addStealExtension(function (loader) {
};
});

addStealExtension(function (loader) {
addStealExtension(function addContextual(loader) {
loader._contextualModules = {};

loader.setContextual = function(moduleName, definer){
Expand Down Expand Up @@ -550,7 +550,7 @@ addStealExtension(function (loader) {
* <script type="text/steal-module">...</script>
* <script type="steal-module">...</script>
*/
addStealExtension(function(loader) {
addStealExtension(function addStealModule(loader) {
// taken from https://github.com/ModuleLoader/es6-module-loader/blob/master/src/module-tag.js
function completed() {
document.removeEventListener("DOMContentLoaded", completed, false);
Expand Down Expand Up @@ -589,7 +589,7 @@ addStealExtension(function(loader) {

// SystemJS Steal Format
// Provides the Steal module format definition.
addStealExtension(function (loader) {
addStealExtension(function addStealFormat(loader) {
// Steal Module Format Detection RegEx
// steal(module, ...)
var stealRegEx = /(?:^\s*|[}{\(\);,\n\?\&]\s*)steal\s*\(\s*((?:"[^"]+"\s*,|'[^']+'\s*,\s*)*)/;
Expand Down Expand Up @@ -670,7 +670,8 @@ addStealExtension(function (loader) {
return loaderInstantiate.call(loader, load);
};
});
addStealExtension(function(loader) {

addStealExtension(function addMetaDeps(loader) {
var superTranspile = loader.transpile;
var superDetermineFormat = loader._determineFormat;

Expand Down Expand Up @@ -705,7 +706,7 @@ addStealExtension(function(loader) {
};
});

addStealExtension(function (loader) {
addStealExtension(function addStackTrace(loader) {
function StackTrace(message, items) {
this.message = message;
this.items = items;
Expand Down Expand Up @@ -931,7 +932,7 @@ addStealExtension(function (loader) {
};
});

addStealExtension(function(loader){
addStealExtension(function addPrettyName(loader){
loader.prettyName = function(load){
var pnm = load.metadata.parsedModuleName;
if(pnm) {
Expand All @@ -941,7 +942,7 @@ addStealExtension(function(loader){
};
});

addStealExtension(function(loader) {
addStealExtension(function addTreeShaking(loader) {
function treeShakingEnabled(loader, load) {
return !loader.noTreeShaking && loader.treeShaking !== false;
}
Expand Down Expand Up @@ -1332,7 +1333,7 @@ addStealExtension(function(loader) {
};
});

addStealExtension(function(loader){
addStealExtension(function addMJS(loader){
var mjsExp = /\.mjs$/;
var jsExp = /\.js$/;

Expand All @@ -1355,10 +1356,6 @@ addStealExtension(function(loader){
});

addStealExtension(function applyTraceExtension(loader) {
if(loader._extensions) {
loader._extensions.push(applyTraceExtension);
}

loader._traceData = {
loads: {},
parentMap: {}
Expand Down Expand Up @@ -1574,7 +1571,7 @@ addStealExtension(function applyTraceExtension(loader) {

// Steal JSON Format
// Provides the JSON module format definition.
addStealExtension(function (loader) {
addStealExtension(function addJSON(loader) {
var jsonExt = /\.json$/i;
var jsExt = /\.js$/i;

Expand Down Expand Up @@ -1678,7 +1675,7 @@ addStealExtension(function (loader) {
// Steal Cache-Bust Extension
// if enabled, Steal Cache-Bust will add a
// cacheKey and cacheVersion to the required file address
addStealExtension(function (loader) {
addStealExtension(function addCacheBust(loader) {
var fetch = loader.fetch;

loader.fetch = function(load) {
Expand All @@ -1694,6 +1691,7 @@ addStealExtension(function (loader) {
return fetch.call(this, load);
};
});

// Overwrites System.config with setter hooks
var setterConfig = function(loader, configOrder, configSpecial){
var oldConfig = loader.config;
Expand Down Expand Up @@ -2123,7 +2121,7 @@ addStealExtension(function (loader) {

// Steal Env Extension
// adds some special environment functions to the loader
addStealExtension(function (loader) {
addStealExtension(function addEnv(loader) {

loader.getEnv = function(){
var envParts = (this.env || "").split("-");
Expand All @@ -2144,6 +2142,7 @@ addStealExtension(function (loader) {
return this.getPlatform() === name;
};
});

// get config by the URL query
// like ?main=foo&env=production
// formally used for Webworkers
Expand Down
4 changes: 2 additions & 2 deletions src/cache-bust/cache-bust.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Steal Cache-Bust Extension
// if enabled, Steal Cache-Bust will add a
// cacheKey and cacheVersion to the required file address
addStealExtension(function (loader) {
addStealExtension(function addCacheBust(loader) {
var fetch = loader.fetch;

loader.fetch = function(load) {
Expand All @@ -16,4 +16,4 @@ addStealExtension(function (loader) {
}
return fetch.call(this, load);
};
});
});
4 changes: 2 additions & 2 deletions src/env/env.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Steal Env Extension
// adds some special environment functions to the loader
addStealExtension(function (loader) {
addStealExtension(function addEnv(loader) {

loader.getEnv = function(){
var envParts = (this.env || "").split("-");
Expand All @@ -20,4 +20,4 @@ addStealExtension(function (loader) {
loader.isPlatform = function(name){
return this.getPlatform() === name;
};
});
});
2 changes: 1 addition & 1 deletion src/extension-mjs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addStealExtension(function(loader){
addStealExtension(function addMJS(loader){
var mjsExp = /\.mjs$/;
var jsExp = /\.js$/;

Expand Down
2 changes: 1 addition & 1 deletion src/extension-no-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Auto-main warning. The main is no longer automatically loaded in development.
* This warns the user in cases where they likely forgot to set a main.
**/
addStealExtension(function (loader) {
addStealExtension(function addNoMainWarn(loader) {
loader._warnNoMain = function(ms){
var loader = this;
this._noMainTimeoutId = setTimeout(function(){
Expand Down
2 changes: 1 addition & 1 deletion src/extension-pretty-name.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addStealExtension(function(loader){
addStealExtension(function addPrettyName(loader){
loader.prettyName = function(load){
var pnm = load.metadata.parsedModuleName;
if(pnm) {
Expand Down
2 changes: 1 addition & 1 deletion src/extension-stack-trace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addStealExtension(function (loader) {
addStealExtension(function addStackTrace(loader) {
function StackTrace(message, items) {
this.message = message;
this.items = items;
Expand Down
2 changes: 1 addition & 1 deletion src/extension-tree-shaking.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addStealExtension(function(loader) {
addStealExtension(function addTreeShaking(loader) {
function treeShakingEnabled(loader, load) {
return !loader.noTreeShaking && loader.treeShaking !== false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/json/json.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Steal JSON Format
// Provides the JSON module format definition.
addStealExtension(function (loader) {
addStealExtension(function addJSON(loader) {
var jsonExt = /\.json$/i;
var jsExt = /\.js$/i;

Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-contextual.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addStealExtension(function (loader) {
addStealExtension(function addContextual(loader) {
loader._contextualModules = {};

loader.setContextual = function(moduleName, definer){
Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// foo.bar! -> foo.bar!path/to/bar
// 2. if you load a javascript file e.g. require("./foo.js")
// normalize will remove the ".js" to load the module
addStealExtension(function (loader) {
addStealExtension(function addExt(loader) {
loader.ext = {};

var normalize = loader.normalize,
Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-forward-slash.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Steal Locate Extension
// normalize a given path e.g.
// "path/to/folder/" -> "path/to/folder/folder"
addStealExtension(function (loader) {
addStealExtension(function addForwardSlash(loader) {
var normalize = loader.normalize;
var npmLike = /@.+#.+/;

Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-locate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// override loader.translate to rewrite 'locate://' & 'pkg://' path schemes found
// in resources loaded by supporting plugins
addStealExtension(function (loader) {
addStealExtension(function addLocateProtocol(loader) {
/**
* @hide
* @function normalizeAndLocate
Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-meta-deps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addStealExtension(function(loader) {
addStealExtension(function addMetaDeps(loader) {
var superTranspile = loader.transpile;
var superDetermineFormat = loader._determineFormat;

Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-module-loaded-twice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Multiple module instantiation might cause unexpected side effects
*/
addStealExtension(function(loader) {
addStealExtension(function addModuleLoadedWarn(loader) {
var superInstantiate = loader.instantiate;

var warn = typeof console === "object" ?
Expand Down
2 changes: 1 addition & 1 deletion src/system-extension-script-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* <script type="text/steal-module">...</script>
* <script type="steal-module">...</script>
*/
addStealExtension(function(loader) {
addStealExtension(function addStealModule(loader) {
// taken from https://github.com/ModuleLoader/es6-module-loader/blob/master/src/module-tag.js
function completed() {
document.removeEventListener("DOMContentLoaded", completed, false);
Expand Down
4 changes: 2 additions & 2 deletions src/system-extension-steal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SystemJS Steal Format
// Provides the Steal module format definition.
addStealExtension(function (loader) {
addStealExtension(function addStealFormat(loader) {
// Steal Module Format Detection RegEx
// steal(module, ...)
var stealRegEx = /(?:^\s*|[}{\(\);,\n\?\&]\s*)steal\s*\(\s*((?:"[^"]+"\s*,|'[^']+'\s*,\s*)*)/;
Expand Down Expand Up @@ -80,4 +80,4 @@ addStealExtension(function (loader) {
}
return loaderInstantiate.call(loader, load);
};
});
});
4 changes: 0 additions & 4 deletions src/trace/trace.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
addStealExtension(function applyTraceExtension(loader) {
if(loader._extensions) {
loader._extensions.push(applyTraceExtension);
}

loader._traceData = {
loads: {},
parentMap: {}
Expand Down
Loading

0 comments on commit f217d58

Please sign in to comment.