support import.meta in system transform

This commit is contained in:
Guy Bedford
2018-06-01 23:07:29 +02:00
committed by Brian Ng
parent bd44902024
commit 7da7e760a6
4 changed files with 26 additions and 1 deletions

View File

@@ -87,6 +87,20 @@ export default declare((api, options) => {
}
},
MetaProperty(path, state) {
if (
path.node.meta.name === "import" &&
path.node.property.name === "meta"
) {
path.replaceWith(
t.memberExpression(
t.identifier(state.contextIdent),
t.identifier("meta"),
),
);
}
},
ReferencedIdentifier(path, state) {
if (
path.node.name == "__moduleName" &&

View File

@@ -0,0 +1 @@
console.log(import.meta.url);

View File

@@ -0,0 +1,10 @@
System.register([], function (_export, _context) {
"use strict";
return {
setters: [],
execute: function () {
console.log(_context.meta.url);
}
};
});

View File

@@ -1,3 +1,3 @@
{
"plugins": ["external-helpers", "syntax-dynamic-import", "transform-modules-systemjs"]
"plugins": ["external-helpers", "syntax-dynamic-import", "syntax-import-meta", "transform-modules-systemjs"]
}