Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit ca24dec

Browse files
committed
Module -> ModuleNamespace
1 parent 1166605 commit ca24dec

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

core/loader-polyfill.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addToError, createSymbol } from './common.js';
22

3-
export { Loader, Module, Module as ModuleNamespace }
3+
export { Loader, ModuleNamespace }
44

55
/*
66
* Simple Array values shim
@@ -158,7 +158,7 @@ Registry.prototype.get = function (key) {
158158
};
159159
// 4.4.7
160160
Registry.prototype.set = function (key, namespace) {
161-
if (!(namespace instanceof Module))
161+
if (!(namespace instanceof ModuleNamespace))
162162
throw new Error('Registry must be set with an instance of Module Namespace');
163163
this[REGISTRY][key] = namespace;
164164
return this;
@@ -195,7 +195,7 @@ var BASE_OBJECT = createSymbol('baseObject');
195195
* Optional evaluation function provides experimental Module.evaluate
196196
* support for non-executed modules in registry.
197197
*/
198-
function Module (baseObject/*, evaluate*/) {
198+
function ModuleNamespace (baseObject/*, evaluate*/) {
199199
Object.defineProperty(this, BASE_OBJECT, {
200200
value: baseObject
201201
});
@@ -213,10 +213,10 @@ function Module (baseObject/*, evaluate*/) {
213213
//}
214214
};
215215
// 8.4.2
216-
Module.prototype = Object.create(null);
216+
ModuleNamespace.prototype = Object.create(null);
217217

218218
if (typeof Symbol !== 'undefined' && Symbol.toStringTag)
219-
Object.defineProperty(Module.prototype, Symbol.toStringTag, {
219+
Object.defineProperty(ModuleNamespace.prototype, Symbol.toStringTag, {
220220
value: 'Module'
221221
});
222222

core/register-loader.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Loader, Module, } from './loader-polyfill.js';
1+
import { Loader, ModuleNamespace } from './loader-polyfill.js';
22
import { resolveIfNotPlain } from './resolve.js';
33
import { addToError, global, createSymbol, baseURI } from './common.js';
44

@@ -122,7 +122,7 @@ RegisterLoader.prototype[Loader.resolveInstantiate] = function (key, parentKey)
122122

123123
return resolveInstantiate(loader, key, parentKey, registry, registerRegistry)
124124
.then(function (instantiated) {
125-
if (instantiated instanceof Module)
125+
if (instantiated instanceof ModuleNamespace)
126126
return instantiated;
127127

128128
// if already beaten to linked, return
@@ -205,7 +205,7 @@ function instantiate (loader, load, link, registry, registerRegistry) {
205205
.then(function (instantiation) {
206206
// direct module return from instantiate -> we're done
207207
if (instantiation !== undefined) {
208-
if (!(instantiation instanceof Module))
208+
if (!(instantiation instanceof ModuleNamespace))
209209
throw new TypeError('Instantiate did not return a valid Module object.');
210210

211211
delete registerRegistry[load.key];
@@ -407,7 +407,7 @@ function instantiateDeps (loader, load, link, registry, registerRegistry, seen)
407407
if (setter) {
408408
var instantiation = dependencyInstantiations[i];
409409

410-
if (instantiation instanceof Module) {
410+
if (instantiation instanceof ModuleNamespace) {
411411
setter(instantiation);
412412
}
413413
else {
@@ -474,7 +474,7 @@ function clearLoadErrors (loader, load) {
474474

475475
if (link.dependencyInstantiations)
476476
link.dependencyInstantiations.forEach(function (depLoad, index) {
477-
if (!depLoad || depLoad instanceof Module)
477+
if (!depLoad || depLoad instanceof ModuleNamespace)
478478
return;
479479

480480
if (depLoad.linkRecord) {
@@ -588,7 +588,7 @@ function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations
588588
var depLoad = dependencyInstantiations[i];
589589
var module;
590590

591-
if (depLoad instanceof Module)
591+
if (depLoad instanceof ModuleNamespace)
592592
module = depLoad;
593593
else
594594
module = ensureEvaluate(loader, depLoad, depLoad.linkRecord, registry, registerRegistry, seen);
@@ -614,7 +614,7 @@ function doEvaluate (loader, load, link, registry, registerRegistry, seen) {
614614
for (var i = 0; i < link.dependencies.length; i++) {
615615
depLoad = link.dependencyInstantiations[i];
616616

617-
if (depLoad instanceof Module)
617+
if (depLoad instanceof ModuleNamespace)
618618
continue;
619619

620620
// custom Module returned from instantiate
@@ -669,7 +669,7 @@ function doEvaluate (loader, load, link, registry, registerRegistry, seen) {
669669
if (err)
670670
return link.error = addToError(err, 'Evaluating ' + load.key);
671671

672-
registry[load.key] = load.module = new Module(link.moduleObj);
672+
registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
673673

674674
// if not an esm module, run importer setters and clear them
675675
// this allows dynamic modules to update themselves into es modules

core/resolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isNode } from './common.js';
44
* Optimized URL normalization assuming a syntax-valid URL parent
55
*/
66
function throwResolveError () {
7-
throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
7+
throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
88
}
99
export function resolveIfNotPlain (relUrl, parentUrl) {
1010
var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);

test/2-loader-api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'assert';
2-
import { Loader, Module, ModuleNamespace } from '../core/loader-polyfill.js';
2+
import { Loader, ModuleNamespace } from '../core/loader-polyfill.js';
33
import { pathToFileUrl } from '../core/common.js';
44

55
describe('Loader Polyfill API', function() {
@@ -42,7 +42,7 @@ describe('Loader Polyfill API', function() {
4242
it('Should support Module construction, evaluation and mutation', function() {
4343
//var evaluated = false;
4444
var mutator = { a: 'asdf' };
45-
var module = new Module(mutator);/*, function() {
45+
var module = new ModuleNamespace(mutator);/*, function() {
4646
evaluated = true;
4747
mutator.a = 'b';
4848
});*/

0 commit comments

Comments
 (0)