aboutsummaryrefslogtreecommitdiff
path: root/node_modules/acorn-dynamic-import/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/acorn-dynamic-import/lib
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
node_modules
Diffstat (limited to 'node_modules/acorn-dynamic-import/lib')
-rw-r--r--node_modules/acorn-dynamic-import/lib/index.js17
-rw-r--r--node_modules/acorn-dynamic-import/lib/inject.js70
2 files changed, 87 insertions, 0 deletions
diff --git a/node_modules/acorn-dynamic-import/lib/index.js b/node_modules/acorn-dynamic-import/lib/index.js
new file mode 100644
index 000000000..b6087debf
--- /dev/null
+++ b/node_modules/acorn-dynamic-import/lib/index.js
@@ -0,0 +1,17 @@
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _acorn = require('acorn');
+
+var acorn = _interopRequireWildcard(_acorn);
+
+var _inject = require('./inject');
+
+var _inject2 = _interopRequireDefault(_inject);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
+
+exports['default'] = (0, _inject2['default'])(acorn); \ No newline at end of file
diff --git a/node_modules/acorn-dynamic-import/lib/inject.js b/node_modules/acorn-dynamic-import/lib/inject.js
new file mode 100644
index 000000000..7b3832b70
--- /dev/null
+++ b/node_modules/acorn-dynamic-import/lib/inject.js
@@ -0,0 +1,70 @@
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports['default'] = injectDynamicImport;
+/* eslint-disable no-underscore-dangle */
+
+function injectDynamicImport(acorn) {
+ var tt = acorn.tokTypes;
+
+ // NOTE: This allows `yield import()` to parse correctly.
+ tt._import.startsExpr = true;
+
+ function parseDynamicImport() {
+ var node = this.startNode();
+ this.next();
+ if (this.type !== tt.parenL) {
+ this.unexpected();
+ }
+ return this.finishNode(node, 'Import');
+ }
+
+ function peekNext() {
+ return this.input[this.pos];
+ }
+
+ // eslint-disable-next-line no-param-reassign
+ acorn.plugins.dynamicImport = function () {
+ function dynamicImportPlugin(instance) {
+ instance.extend('parseStatement', function (nextMethod) {
+ return function () {
+ function parseStatement() {
+ var node = this.startNode();
+ if (this.type === tt._import) {
+ var nextToken = peekNext.call(this);
+ if (nextToken === tt.parenL.label) {
+ var expr = this.parseExpression();
+ return this.parseExpressionStatement(node, expr);
+ }
+ }
+
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
+ return nextMethod.apply(this, args);
+ }
+
+ return parseStatement;
+ }();
+ });
+
+ instance.extend('parseExprAtom', function (nextMethod) {
+ return function () {
+ function parseExprAtom(refDestructuringErrors) {
+ if (this.type === tt._import) {
+ return parseDynamicImport.call(this);
+ }
+ return nextMethod.call(this, refDestructuringErrors);
+ }
+
+ return parseExprAtom;
+ }();
+ });
+ }
+
+ return dynamicImportPlugin;
+ }();
+
+ return acorn;
+} \ No newline at end of file