Skip to content

Commit

Permalink
[[FEAT]] Add support for dynamic import
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike authored and rwaldron committed Apr 5, 2021
1 parent b125dbe commit 6bfcaed
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 803 deletions.
19 changes: 16 additions & 3 deletions src/jshint.js
Expand Up @@ -5576,10 +5576,22 @@ var JSHINT = (function() {
}
});

if (!mp) {
if (mp) {
return mp;
}

if (!checkPunctuator(state.tokens.next, "(")) {
return state.syntax["(identifier)"].nud.call(this, context);
}
return mp;

if (!state.inES11()) {
warning("W119", state.tokens.curr, "dynamic import", "11");
}

advance("(");
expression(context, 10);
advance(")");
return this;
});

var importSymbol = stmt("import", function(context) {
Expand Down Expand Up @@ -5686,8 +5698,9 @@ var JSHINT = (function() {
importSymbol.reserved = true;
importSymbol.meta = { isFutureReservedWord: true, es5: true };
importSymbol.useFud = function() {
return !(checkPunctuator(state.tokens.next, ".") && peek().identifier);
return !(checkPunctuators(state.tokens.next, [".", "("]));
};
importSymbol.rbp = 161;

stmt("export", function(context) {
var ok = true;
Expand Down
2 changes: 1 addition & 1 deletion src/options.js
Expand Up @@ -1053,7 +1053,7 @@ exports.val = {
* Notable additions: optional catch bindings.
* - `11` - To enable language features introduced by ECMAScript 11. Notable
* additions: "export * as ns from 'module'", `import.meta`, the nullish
* coalescing operator, and optional chaining.
* coalescing operator, and optional chaining, and dynamic import.
*/
esversion: 5
};
Expand Down

0 comments on commit 6bfcaed

Please sign in to comment.