Skip to content

Commit

Permalink
Allow import.meta.* for systemjs format (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail authored and lukastaegert committed Oct 15, 2019
1 parent 4b16548 commit f6db7bc
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ast/nodes/MetaProperty.ts
Expand Up @@ -36,14 +36,14 @@ export default class MetaProperty extends NodeBase {
? parent.propertyKey
: null);
if (metaProperty) {
if (metaProperty === 'url') {
this.scope.addAccessedGlobalsByFormat(accessedMetaUrlGlobals);
} else if (
if (
metaProperty.startsWith(FILE_PREFIX) ||
metaProperty.startsWith(ASSET_PREFIX) ||
metaProperty.startsWith(CHUNK_PREFIX)
) {
this.scope.addAccessedGlobalsByFormat(accessedFileUrlGlobals);
} else {
this.scope.addAccessedGlobalsByFormat(accessedMetaUrlGlobals);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/form/samples/import-meta-resolve/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'supports import.meta.resolve'
};
5 changes: 5 additions & 0 deletions test/form/samples/import-meta-resolve/_expected/amd.js
@@ -0,0 +1,5 @@
define(['module'], function (module) { 'use strict';

undefined('./foo.js');

});
3 changes: 3 additions & 0 deletions test/form/samples/import-meta-resolve/_expected/cjs.js
@@ -0,0 +1,3 @@
'use strict';

undefined('./foo.js');
1 change: 1 addition & 0 deletions test/form/samples/import-meta-resolve/_expected/es.js
@@ -0,0 +1 @@
import.meta.resolve('./foo.js');
6 changes: 6 additions & 0 deletions test/form/samples/import-meta-resolve/_expected/iife.js
@@ -0,0 +1,6 @@
(function () {
'use strict';

undefined('./foo.js');

}());
10 changes: 10 additions & 0 deletions test/form/samples/import-meta-resolve/_expected/system.js
@@ -0,0 +1,10 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {

module.meta.resolve('./foo.js');

}
};
});
8 changes: 8 additions & 0 deletions test/form/samples/import-meta-resolve/_expected/umd.js
@@ -0,0 +1,8 @@
(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(function () { 'use strict';

undefined('./foo.js');

}));
1 change: 1 addition & 0 deletions test/form/samples/import-meta-resolve/main.js
@@ -0,0 +1 @@
import.meta.resolve('./foo.js');

0 comments on commit f6db7bc

Please sign in to comment.