pax_global_header00006660000000000000000000000064132277326170014524gustar00rootroot0000000000000052 comment=58186e02ca823990f92b9c973b00b584d24ee1e1 acorn-dynamic-import-3.0.0/000077500000000000000000000000001322773261700155605ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/.babelrc000066400000000000000000000000341322773261700171500ustar00rootroot00000000000000{ "presets": ["airbnb"] } acorn-dynamic-import-3.0.0/.eslintignore000066400000000000000000000000231322773261700202560ustar00rootroot00000000000000test/fixtures lib/ acorn-dynamic-import-3.0.0/.eslintrc000066400000000000000000000001131322773261700173770ustar00rootroot00000000000000{ "parser": "babel-eslint", "extends": "airbnb-base", "root": true } acorn-dynamic-import-3.0.0/.gitignore000077500000000000000000000000321322773261700175460ustar00rootroot00000000000000.idea/ node_modules/ lib/ acorn-dynamic-import-3.0.0/.npmignore000077500000000000000000000000101322773261700175510ustar00rootroot00000000000000test .* acorn-dynamic-import-3.0.0/.travis.yml000077500000000000000000000007611322773261700177000ustar00rootroot00000000000000language: node_js node_js: - "7" - "6" - "5" - "4" - "iojs-v3" - "iojs-v2" - "iojs-v1" - "0.12" before_install: - 'npm install -g npm' script: - 'if [ -n "${LINT-}" ]; then npm run lint ; fi' - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' sudo: false env: - TEST=true matrix: fast_finish: true include: - node_js: "node" env: LINT=true allow_failures: - node_js: "iojs-v3" - node_js: "iojs-v2" - node_js: "iojs-v1" - node_js: "0.12" acorn-dynamic-import-3.0.0/CHANGELOG.md000066400000000000000000000004461322773261700173750ustar00rootroot00000000000000# 3.0.0 - Adding acorn walk support. - Bump acorn version. # 2.0.2 - Fixing parsing of `yield import()`. # 2.0.1 - Removing unnecessary `in-publish` dependency. # 2.0.0 - Updating acorn version to >= 4. # 1.0.1 - Fixes for publishing the module. # 1.0.0 - Initial release of plugin. acorn-dynamic-import-3.0.0/LICENSE000077500000000000000000000020571322773261700165740ustar00rootroot00000000000000MIT License Copyright (c) 2016 Jordan Gensler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. acorn-dynamic-import-3.0.0/README.md000077500000000000000000000026411322773261700170450ustar00rootroot00000000000000# Dynamic import support in acorn This is plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. For more information, check out the [proposal repo](https://github.com/tc39/proposal-dynamic-import). ## Usage You can use this module directly in order to get Acorn instance with plugin installed: ```js import acorn from 'acorn-dynamic-import'; // or... const acorn = require('acorn-dynamic-import').default; ``` Or you can use `inject.js` for injecting plugin into your own version of Acorn like this: ```js const acorn = require('acorn-dynamic-import/lib/inject').default(require('./custom-acorn')); ``` Then, use the `plugins` option whenever you need to support dynamicImport while parsing: ```js const ast = acorn.parse(code, { plugins: { dynamicImport: true } }); ``` To use the updated walk functionality the process is similar. You can require the default implementation as: ```js import walk from 'acorn-dynamic-import/lib/walk'; // or... const dynamicImportWalk = require('acorn-dynamic-import/lib/walk').default; ``` Or you can use the injectable version for injecting the new walk functionality into your own version of Acorn like this: ```js import { inject } from 'acorn-dynamic-import/lib/walk'; import acornWalk from 'acorn/dist/walk'; const walk = inject(acornWalk); ``` ## License This plugin is issued under the [MIT license](./LICENSE). acorn-dynamic-import-3.0.0/package.json000066400000000000000000000035641322773261700200560ustar00rootroot00000000000000{ "name": "acorn-dynamic-import", "description": "Support dynamic imports in acorn", "main": "lib/index.js", "homepage": "https://github.com/kesne/acorn-dynamic-import", "author": "Jordan Gensler ", "repository": { "type": "git", "url": "https://github.com/kesne/acorn-dynamic-import" }, "license": "MIT", "scripts": { "build": "babel src --out-dir lib", "test": "npm run lint && npm run tests-only", "lint": "eslint .", "tests-only": "mocha", "prepublish": "in-publish && safe-publish-latest && npm run build || not-in-publish", "check-changelog": "expr $(git status --porcelain 2>/dev/null| grep \"^\\s*M.*CHANGELOG.md\" | wc -l) >/dev/null || (echo 'Please edit CHANGELOG.md' && exit 1)", "check-only-changelog-changed": "(expr $(git status --porcelain 2>/dev/null| grep -v \"CHANGELOG.md\" | wc -l) >/dev/null && echo 'Only CHANGELOG.md may have uncommitted changes' && exit 1) || exit 0", "version:major": "npm --no-git-tag-version version major", "version:minor": "npm --no-git-tag-version version minor", "version:patch": "npm --no-git-tag-version version patch", "postversion": "git commit package.json CHANGELOG.md -m \"v$npm_package_version\" && npm run tag && git push && git push --tags", "preversion": "npm run test && npm run check-changelog && npm run check-only-changelog-changed", "tag": "git tag v$npm_package_version" }, "dependencies": { "acorn": "^5.0.0" }, "devDependencies": { "babel-cli": "^6.18.0", "babel-eslint": "^7.1.1", "babel-preset-airbnb": "^2.1.1", "babel-register": "^6.18.0", "chai": "^3.0.0", "eslint": "^3.10.2", "eslint-config-airbnb-base": "^10.0.1", "eslint-plugin-import": "^2.2.0", "in-publish": "^2.0.0", "mocha": "^2.2.5", "rimraf": "^2.5.4", "safe-publish-latest": "^1.1.1" }, "version": "3.0.0" } acorn-dynamic-import-3.0.0/src/000077500000000000000000000000001322773261700163475ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/src/index.js000066400000000000000000000001361322773261700200140ustar00rootroot00000000000000import * as acorn from 'acorn'; import inject from './inject'; export default inject(acorn); acorn-dynamic-import-3.0.0/src/inject.js000066400000000000000000000026241322773261700201650ustar00rootroot00000000000000/* eslint-disable no-underscore-dangle */ export const DynamicImportKey = 'Import'; export default function injectDynamicImport(acorn) { const tt = acorn.tokTypes; // NOTE: This allows `yield import()` to parse correctly. tt._import.startsExpr = true; function parseDynamicImport() { const node = this.startNode(); this.next(); if (this.type !== tt.parenL) { this.unexpected(); } return this.finishNode(node, DynamicImportKey); } function peekNext() { return this.input[this.pos]; } // eslint-disable-next-line no-param-reassign acorn.plugins.dynamicImport = function dynamicImportPlugin(instance) { instance.extend('parseStatement', nextMethod => ( function parseStatement(...args) { const node = this.startNode(); if (this.type === tt._import) { const nextToken = peekNext.call(this); if (nextToken === tt.parenL.label) { const expr = this.parseExpression(); return this.parseExpressionStatement(node, expr); } } return nextMethod.apply(this, args); } )); instance.extend('parseExprAtom', nextMethod => ( function parseExprAtom(refDestructuringErrors) { if (this.type === tt._import) { return parseDynamicImport.call(this); } return nextMethod.call(this, refDestructuringErrors); } )); }; return acorn; } acorn-dynamic-import-3.0.0/src/walk.js000066400000000000000000000004551322773261700176470ustar00rootroot00000000000000import * as walk from 'acorn/dist/walk'; import { DynamicImportKey } from './inject'; export function inject(injectableWalk) { return Object.assign({}, injectableWalk, { base: Object.assign({}, injectableWalk.base, { [DynamicImportKey]() {}, }), }); } export default inject(walk); acorn-dynamic-import-3.0.0/test/000077500000000000000000000000001322773261700165375ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/.eslintrc000066400000000000000000000000471322773261700203640ustar00rootroot00000000000000{ "env": { "mocha": true, }, } acorn-dynamic-import-3.0.0/test/fixtures/000077500000000000000000000000001322773261700204105ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/direct-calls-only/000077500000000000000000000000001322773261700237355ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/direct-calls-only/actual.js000066400000000000000000000000621322773261700255420ustar00rootroot00000000000000function failsParse() { return import.then(); } acorn-dynamic-import-3.0.0/test/fixtures/direct-calls-only/expected.json000066400000000000000000000000501322773261700264240ustar00rootroot00000000000000{ "error": "Unexpected token (2:15)" }acorn-dynamic-import-3.0.0/test/fixtures/import-statement/000077500000000000000000000000001322773261700237245ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/import-statement/actual.js000066400000000000000000000002521322773261700255320ustar00rootroot00000000000000import * as testing from 'starImport'; import defaultThings from 'defaultImport' import { named, things } from 'namedImport'; import 'sideEffects'; import('me/too.js'); acorn-dynamic-import-3.0.0/test/fixtures/import-statement/expected.json000066400000000000000000000213621322773261700264240ustar00rootroot00000000000000{ "type": "Program", "start": 0, "end": 170, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 7, "column": 0 } }, "range": [ 0, 170 ], "body": [ { "type": "ImportDeclaration", "start": 0, "end": 38, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 38 } }, "range": [ 0, 38 ], "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 7, "end": 19, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 19 } }, "range": [ 7, 19 ], "local": { "type": "Identifier", "start": 12, "end": 19, "loc": { "start": { "line": 1, "column": 12 }, "end": { "line": 1, "column": 19 } }, "range": [ 12, 19 ], "name": "testing" } } ], "source": { "type": "Literal", "start": 25, "end": 37, "loc": { "start": { "line": 1, "column": 25 }, "end": { "line": 1, "column": 37 } }, "range": [ 25, 37 ], "value": "starImport", "raw": "'starImport'" } }, { "type": "ImportDeclaration", "start": 39, "end": 80, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 41 } }, "range": [ 39, 80 ], "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 46, "end": 59, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 } }, "range": [ 46, 59 ], "local": { "type": "Identifier", "start": 46, "end": 59, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 } }, "range": [ 46, 59 ], "name": "defaultThings" } } ], "source": { "type": "Literal", "start": 65, "end": 80, "loc": { "start": { "line": 2, "column": 26 }, "end": { "line": 2, "column": 41 } }, "range": [ 65, 80 ], "value": "defaultImport", "raw": "'defaultImport'" } }, { "type": "ImportDeclaration", "start": 81, "end": 125, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 44 } }, "range": [ 81, 125 ], "specifiers": [ { "type": "ImportSpecifier", "start": 90, "end": 95, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 14 } }, "range": [ 90, 95 ], "imported": { "type": "Identifier", "start": 90, "end": 95, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 14 } }, "range": [ 90, 95 ], "name": "named" }, "local": { "type": "Identifier", "start": 90, "end": 95, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 14 } }, "range": [ 90, 95 ], "name": "named" } }, { "type": "ImportSpecifier", "start": 97, "end": 103, "loc": { "start": { "line": 3, "column": 16 }, "end": { "line": 3, "column": 22 } }, "range": [ 97, 103 ], "imported": { "type": "Identifier", "start": 97, "end": 103, "loc": { "start": { "line": 3, "column": 16 }, "end": { "line": 3, "column": 22 } }, "range": [ 97, 103 ], "name": "things" }, "local": { "type": "Identifier", "start": 97, "end": 103, "loc": { "start": { "line": 3, "column": 16 }, "end": { "line": 3, "column": 22 } }, "range": [ 97, 103 ], "name": "things" } } ], "source": { "type": "Literal", "start": 111, "end": 124, "loc": { "start": { "line": 3, "column": 30 }, "end": { "line": 3, "column": 43 } }, "range": [ 111, 124 ], "value": "namedImport", "raw": "'namedImport'" } }, { "type": "ImportDeclaration", "start": 126, "end": 147, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 21 } }, "range": [ 126, 147 ], "specifiers": [], "source": { "type": "Literal", "start": 133, "end": 146, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 20 } }, "range": [ 133, 146 ], "value": "sideEffects", "raw": "'sideEffects'" } }, { "type": "ExpressionStatement", "start": 149, "end": 169, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 20 } }, "range": [ 149, 169 ], "expression": { "type": "CallExpression", "start": 149, "end": 168, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 19 } }, "range": [ 149, 168 ], "callee": { "type": "Import", "start": 149, "end": 155, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 6 } }, "range": [ 149, 155 ] }, "arguments": [ { "type": "Literal", "start": 156, "end": 167, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 18 } }, "range": [ 156, 167 ], "value": "me/too.js", "raw": "'me/too.js'" } ] } } ], "sourceType": "module" }acorn-dynamic-import-3.0.0/test/fixtures/inside-function/000077500000000000000000000000001322773261700235065ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/inside-function/actual.js000066400000000000000000000001021322773261700253060ustar00rootroot00000000000000function loadImport(file) { return import(`test/${file}.js`); } acorn-dynamic-import-3.0.0/test/fixtures/inside-function/expected.json000066400000000000000000000135471322773261700262140ustar00rootroot00000000000000{ "type": "Program", "start": 0, "end": 66, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 4, "column": 0 } }, "range": [ 0, 66 ], "body": [ { "type": "FunctionDeclaration", "start": 0, "end": 65, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 3, "column": 1 } }, "range": [ 0, 65 ], "id": { "type": "Identifier", "start": 9, "end": 19, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 19 } }, "range": [ 9, 19 ], "name": "loadImport" }, "generator": false, "expression": false, "params": [ { "type": "Identifier", "start": 20, "end": 24, "loc": { "start": { "line": 1, "column": 20 }, "end": { "line": 1, "column": 24 } }, "range": [ 20, 24 ], "name": "file" } ], "body": { "type": "BlockStatement", "start": 26, "end": 65, "loc": { "start": { "line": 1, "column": 26 }, "end": { "line": 3, "column": 1 } }, "range": [ 26, 65 ], "body": [ { "type": "ReturnStatement", "start": 30, "end": 63, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 2, "column": 35 } }, "range": [ 30, 63 ], "argument": { "type": "CallExpression", "start": 37, "end": 62, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 34 } }, "range": [ 37, 62 ], "callee": { "type": "Import", "start": 37, "end": 43, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 15 } }, "range": [ 37, 43 ] }, "arguments": [ { "type": "TemplateLiteral", "start": 44, "end": 61, "loc": { "start": { "line": 2, "column": 16 }, "end": { "line": 2, "column": 33 } }, "range": [ 44, 61 ], "expressions": [ { "type": "Identifier", "start": 52, "end": 56, "loc": { "start": { "line": 2, "column": 24 }, "end": { "line": 2, "column": 28 } }, "range": [ 52, 56 ], "name": "file" } ], "quasis": [ { "type": "TemplateElement", "start": 45, "end": 50, "loc": { "start": { "line": 2, "column": 17 }, "end": { "line": 2, "column": 22 } }, "range": [ 45, 50 ], "value": { "raw": "test/", "cooked": "test/" }, "tail": false }, { "type": "TemplateElement", "start": 57, "end": 60, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 32 } }, "range": [ 57, 60 ], "value": { "raw": ".js", "cooked": ".js" }, "tail": true } ] } ] } } ] } } ], "sourceType": "module" }acorn-dynamic-import-3.0.0/test/fixtures/return-value/000077500000000000000000000000001322773261700230415ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/return-value/actual.js000066400000000000000000000000501322773261700246430ustar00rootroot00000000000000const importResult = import('test.js'); acorn-dynamic-import-3.0.0/test/fixtures/return-value/expected.json000066400000000000000000000055161322773261700255440ustar00rootroot00000000000000{ "type": "Program", "start": 0, "end": 40, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 2, "column": 0 } }, "range": [ 0, 40 ], "body": [ { "type": "VariableDeclaration", "start": 0, "end": 39, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 39 } }, "range": [ 0, 39 ], "declarations": [ { "type": "VariableDeclarator", "start": 6, "end": 38, "loc": { "start": { "line": 1, "column": 6 }, "end": { "line": 1, "column": 38 } }, "range": [ 6, 38 ], "id": { "type": "Identifier", "start": 6, "end": 18, "loc": { "start": { "line": 1, "column": 6 }, "end": { "line": 1, "column": 18 } }, "range": [ 6, 18 ], "name": "importResult" }, "init": { "type": "CallExpression", "start": 21, "end": 38, "loc": { "start": { "line": 1, "column": 21 }, "end": { "line": 1, "column": 38 } }, "range": [ 21, 38 ], "callee": { "type": "Import", "start": 21, "end": 27, "loc": { "start": { "line": 1, "column": 21 }, "end": { "line": 1, "column": 27 } }, "range": [ 21, 27 ] }, "arguments": [ { "type": "Literal", "start": 28, "end": 37, "loc": { "start": { "line": 1, "column": 28 }, "end": { "line": 1, "column": 37 } }, "range": [ 28, 37 ], "value": "test.js", "raw": "'test.js'" } ] } } ], "kind": "const" } ], "sourceType": "module" }acorn-dynamic-import-3.0.0/test/fixtures/top-level/000077500000000000000000000000001322773261700223175ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/top-level/actual.js000066400000000000000000000001611322773261700241240ustar00rootroot00000000000000import('testing.js'); const test = 'hello'; import(`testing/${test}.js`); import('testing.js').then(() => {}); acorn-dynamic-import-3.0.0/test/fixtures/top-level/expected.json000066400000000000000000000250761322773261700250250ustar00rootroot00000000000000{ "type": "Program", "start": 0, "end": 113, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 7, "column": 0 } }, "range": [ 0, 113 ], "body": [ { "type": "ExpressionStatement", "start": 0, "end": 21, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 21 } }, "range": [ 0, 21 ], "expression": { "type": "CallExpression", "start": 0, "end": 20, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 20 } }, "range": [ 0, 20 ], "callee": { "type": "Import", "start": 0, "end": 6, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 6 } }, "range": [ 0, 6 ] }, "arguments": [ { "type": "Literal", "start": 7, "end": 19, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 19 } }, "range": [ 7, 19 ], "value": "testing.js", "raw": "'testing.js'" } ] } }, { "type": "VariableDeclaration", "start": 23, "end": 44, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 21 } }, "range": [ 23, 44 ], "declarations": [ { "type": "VariableDeclarator", "start": 29, "end": 43, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 20 } }, "range": [ 29, 43 ], "id": { "type": "Identifier", "start": 29, "end": 33, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 10 } }, "range": [ 29, 33 ], "name": "test" }, "init": { "type": "Literal", "start": 36, "end": 43, "loc": { "start": { "line": 3, "column": 13 }, "end": { "line": 3, "column": 20 } }, "range": [ 36, 43 ], "value": "hello", "raw": "'hello'" } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 45, "end": 74, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 29 } }, "range": [ 45, 74 ], "expression": { "type": "CallExpression", "start": 45, "end": 73, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 28 } }, "range": [ 45, 73 ], "callee": { "type": "Import", "start": 45, "end": 51, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 6 } }, "range": [ 45, 51 ] }, "arguments": [ { "type": "TemplateLiteral", "start": 52, "end": 72, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 27 } }, "range": [ 52, 72 ], "expressions": [ { "type": "Identifier", "start": 63, "end": 67, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 22 } }, "range": [ 63, 67 ], "name": "test" } ], "quasis": [ { "type": "TemplateElement", "start": 53, "end": 61, "loc": { "start": { "line": 4, "column": 8 }, "end": { "line": 4, "column": 16 } }, "range": [ 53, 61 ], "value": { "raw": "testing/", "cooked": "testing/" }, "tail": false }, { "type": "TemplateElement", "start": 68, "end": 71, "loc": { "start": { "line": 4, "column": 23 }, "end": { "line": 4, "column": 26 } }, "range": [ 68, 71 ], "value": { "raw": ".js", "cooked": ".js" }, "tail": true } ] } ] } }, { "type": "ExpressionStatement", "start": 76, "end": 112, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 36 } }, "range": [ 76, 112 ], "expression": { "type": "CallExpression", "start": 76, "end": 111, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 35 } }, "range": [ 76, 111 ], "callee": { "type": "MemberExpression", "start": 76, "end": 101, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 25 } }, "range": [ 76, 101 ], "object": { "type": "CallExpression", "start": 76, "end": 96, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 20 } }, "range": [ 76, 96 ], "callee": { "type": "Import", "start": 76, "end": 82, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 6 } }, "range": [ 76, 82 ] }, "arguments": [ { "type": "Literal", "start": 83, "end": 95, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 19 } }, "range": [ 83, 95 ], "value": "testing.js", "raw": "'testing.js'" } ] }, "property": { "type": "Identifier", "start": 97, "end": 101, "loc": { "start": { "line": 6, "column": 21 }, "end": { "line": 6, "column": 25 } }, "range": [ 97, 101 ], "name": "then" }, "computed": false }, "arguments": [ { "type": "ArrowFunctionExpression", "start": 102, "end": 110, "loc": { "start": { "line": 6, "column": 26 }, "end": { "line": 6, "column": 34 } }, "range": [ 102, 110 ], "id": null, "generator": false, "expression": false, "params": [], "body": { "type": "BlockStatement", "start": 108, "end": 110, "loc": { "start": { "line": 6, "column": 32 }, "end": { "line": 6, "column": 34 } }, "range": [ 108, 110 ], "body": [] } } ] } } ], "sourceType": "module" }acorn-dynamic-import-3.0.0/test/fixtures/variable-argument/000077500000000000000000000000001322773261700240155ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/variable-argument/actual.js000066400000000000000000000001031322773261700256160ustar00rootroot00000000000000const testVarible = 'test.js'; import(testVarible).then(() => {}); acorn-dynamic-import-3.0.0/test/fixtures/variable-argument/expected.json000066400000000000000000000134201322773261700265110ustar00rootroot00000000000000{ "type": "Program", "start": 0, "end": 67, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 3, "column": 0 } }, "range": [ 0, 67 ], "body": [ { "type": "VariableDeclaration", "start": 0, "end": 30, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 30 } }, "range": [ 0, 30 ], "declarations": [ { "type": "VariableDeclarator", "start": 6, "end": 29, "loc": { "start": { "line": 1, "column": 6 }, "end": { "line": 1, "column": 29 } }, "range": [ 6, 29 ], "id": { "type": "Identifier", "start": 6, "end": 17, "loc": { "start": { "line": 1, "column": 6 }, "end": { "line": 1, "column": 17 } }, "range": [ 6, 17 ], "name": "testVarible" }, "init": { "type": "Literal", "start": 20, "end": 29, "loc": { "start": { "line": 1, "column": 20 }, "end": { "line": 1, "column": 29 } }, "range": [ 20, 29 ], "value": "test.js", "raw": "'test.js'" } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 31, "end": 66, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 35 } }, "range": [ 31, 66 ], "expression": { "type": "CallExpression", "start": 31, "end": 65, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 34 } }, "range": [ 31, 65 ], "callee": { "type": "MemberExpression", "start": 31, "end": 55, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 24 } }, "range": [ 31, 55 ], "object": { "type": "CallExpression", "start": 31, "end": 50, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 19 } }, "range": [ 31, 50 ], "callee": { "type": "Import", "start": 31, "end": 37, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 6 } }, "range": [ 31, 37 ] }, "arguments": [ { "type": "Identifier", "start": 38, "end": 49, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 18 } }, "range": [ 38, 49 ], "name": "testVarible" } ] }, "property": { "type": "Identifier", "start": 51, "end": 55, "loc": { "start": { "line": 2, "column": 20 }, "end": { "line": 2, "column": 24 } }, "range": [ 51, 55 ], "name": "then" }, "computed": false }, "arguments": [ { "type": "ArrowFunctionExpression", "start": 56, "end": 64, "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 33 } }, "range": [ 56, 64 ], "id": null, "generator": false, "expression": false, "params": [], "body": { "type": "BlockStatement", "start": 62, "end": 64, "loc": { "start": { "line": 2, "column": 31 }, "end": { "line": 2, "column": 33 } }, "range": [ 62, 64 ], "body": [] } } ] } } ], "sourceType": "module" }acorn-dynamic-import-3.0.0/test/fixtures/yield-import/000077500000000000000000000000001322773261700230265ustar00rootroot00000000000000acorn-dynamic-import-3.0.0/test/fixtures/yield-import/actual.js000066400000000000000000000000521322773261700246320ustar00rootroot00000000000000function* a() { yield import('http'); } acorn-dynamic-import-3.0.0/test/fixtures/yield-import/expected.json000066400000000000000000000076031322773261700255300ustar00rootroot00000000000000{ "type": "Program", "start": 0, "end": 42, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 4, "column": 0 } }, "range": [ 0, 42 ], "body": [ { "type": "FunctionDeclaration", "start": 0, "end": 41, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 3, "column": 1 } }, "range": [ 0, 41 ], "id": { "type": "Identifier", "start": 10, "end": 11, "loc": { "start": { "line": 1, "column": 10 }, "end": { "line": 1, "column": 11 } }, "range": [ 10, 11 ], "name": "a" }, "generator": true, "expression": false, "params": [], "body": { "type": "BlockStatement", "start": 14, "end": 41, "loc": { "start": { "line": 1, "column": 14 }, "end": { "line": 3, "column": 1 } }, "range": [ 14, 41 ], "body": [ { "type": "ExpressionStatement", "start": 18, "end": 39, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 2, "column": 23 } }, "range": [ 18, 39 ], "expression": { "type": "YieldExpression", "start": 18, "end": 38, "loc": { "start": { "line": 2, "column": 2 }, "end": { "line": 2, "column": 22 } }, "range": [ 18, 38 ], "delegate": false, "argument": { "type": "CallExpression", "start": 24, "end": 38, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 22 } }, "range": [ 24, 38 ], "callee": { "type": "Import", "start": 24, "end": 30, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 14 } }, "range": [ 24, 30 ] }, "arguments": [ { "type": "Literal", "start": 31, "end": 37, "loc": { "start": { "line": 2, "column": 15 }, "end": { "line": 2, "column": 21 } }, "range": [ 31, 37 ], "value": "http", "raw": "'http'" } ] } } } ] } } ], "sourceType": "module" }acorn-dynamic-import-3.0.0/test/index.js000066400000000000000000000025671322773261700202160ustar00rootroot00000000000000import { expect } from 'chai'; import { join } from 'path'; import { readdirSync, writeFileSync, statSync, readFileSync } from 'fs'; import testPlugin from './testPlugin'; const FIXTURE_PATH = join(__dirname, 'fixtures'); const testFolders = readdirSync(FIXTURE_PATH).filter(file => ( statSync(join(FIXTURE_PATH, file)).isDirectory() )); const updateMode = process.env.UPDATE_TESTS === 'pls'; describe('babel-plugin-dynamic-import-node', () => { testFolders.forEach((folderName) => { it(`works with ${folderName}`, () => { const actual = readFileSync(join(FIXTURE_PATH, folderName, 'actual.js'), 'utf8'); const expectedFile = join(FIXTURE_PATH, folderName, 'expected.json'); const result = testPlugin(actual); let expected; // This lets us auto-generate test expected files easily: try { if (updateMode) throw new Error(); expected = readFileSync(expectedFile, 'utf8'); } catch (e) { // eslint-disable-next-line no-console console.log('No expected file found. Generating result file...'); writeFileSync(expectedFile, JSON.stringify(result, null, ' ')); throw new Error('Please re-run tests to compare updates.'); } expect( // Convert to JSON before doing a compare: JSON.parse(JSON.stringify(result)), ).to.deep.equal(JSON.parse(expected)); }); }); }); acorn-dynamic-import-3.0.0/test/mocha.opts000066400000000000000000000000311322773261700205270ustar00rootroot00000000000000--require babel-register acorn-dynamic-import-3.0.0/test/testPlugin.js000066400000000000000000000005611322773261700212350ustar00rootroot00000000000000import acorn from '../src'; export default function testPlugin(code) { let result; try { result = acorn.parse(code, { ecmaVersion: 7, locations: true, ranges: true, plugins: { dynamicImport: true, }, sourceType: 'module', }); } catch (e) { result = { error: e.message, }; } return result; }