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

Commit d00ab6a

Browse files
committed
ensure module this is not global
1 parent b4f61ea commit d00ab6a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/transpiler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ var transpile = (function() {
2323
else
2424
transpileFunction = babelTranspile;
2525

26-
return 'var __moduleName = "' + load.name + '", __moduleAddress = "' + load.address + '";'
26+
return '(function(__moduleName, __moduleAddress) {'
2727
+ transpileFunction.call(self, load, transpiler)
28+
+ '\n}).call({}, "' + load.name + '", "' + load.address + '");'
2829
+ '\n//# sourceURL=' + load.address + '!eval';
2930

3031
// sourceURL and sourceMappingURL:

test/custom-loader.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,39 @@ describe('Custom Loader', function () {
4444
it('should make the normalize throw', function (done) {
4545
customLoader.import('test/loader/error1-parent.js')
4646
.then(supposeToFail, function (e) {
47-
expect(e.toString()).to.contain('Error loading "' + base + 'error1-parent.js" at ' + base + 'error1-parent\.js');
47+
expect(e.toString()).to.contain('Error loading ' + base + 'error1-parent.js');
4848
})
4949
.then(done, done);
5050
});
5151

5252
it('should make the locate throw', function (done) {
5353
customLoader.import('test/loader/error2')
5454
.then(supposeToFail, function (e) {
55-
expect(e.toString()).to.be.contain('Error loading "' + base + 'error2" at ' + base + 'error2');
55+
expect(e.toString()).to.be.contain('Error loading ' + base + 'error2');
5656
})
5757
.then(done, done);
5858
});
5959

6060
it('should make the fetch throw', function (done) {
6161
customLoader.import('test/loader/error3')
6262
.then(supposeToFail, function (e) {
63-
expect(e.toString()).to.be.contain('Error loading "' + base + 'error3" at ' + base + 'error3');
63+
expect(e.toString()).to.be.contain('Error loading ' + base + 'error3');
6464
})
6565
.then(done, done);
6666
});
6767

6868
it('should make the translate throw', function (done) {
6969
customLoader.import('test/loader/error4')
7070
.then(supposeToFail, function (e) {
71-
expect(e.toString()).to.be.contain('Error loading "' + base + 'error4" at ' + base + 'error4');
71+
expect(e.toString()).to.be.contain('Error loading ' + base + 'error4');
7272
})
7373
.then(done, done);
7474
});
7575

7676
it('should make the instantiate throw', function (done) {
7777
customLoader.import('test/loader/error5')
7878
.then(supposeToFail, function (e) {
79-
expect(e.toString()).to.be.contain('Error loading "' + base + 'error5" at ' + base + 'error5');
79+
expect(e.toString()).to.be.contain('Error loading ' + base + 'error5');
8080
})
8181
.then(done, done);
8282
});

test/system.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ describe('System', function () {
227227
System.import('test/loads/load-non-existent.js')
228228
.then(supposedToFail)
229229
.catch(function (e) {
230-
expect(e).to.be.match(/Error loading "\S+" at \S+/);
230+
expect(e).to.be.match(/Error loading \S+/);
231231
})
232232
.then(done, done);
233233
});

0 commit comments

Comments
 (0)