GeezerVison is showing github.com — Upgrade acorn to v6 · webpack/webpack@ef67132
File treeExpand file treeCollapse file tree Open diff view settings test/cases/parsing/precreated-ast
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/Parser.js +11-7Lines changed: 11 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 |
| 7 | 7 | // Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API | 8 | 8 |
| 9 | | -const acorn = require("acorn-dynamic-import").default; | | 9 | +const acorn = require("acorn"); | | 10 | +const acornDynamicImport = require("acorn-dynamic-import").default; | 10 | 11 | const { Tapable, SyncBailHook, HookMap } = require("tapable"); | 11 | 12 | const util = require("util"); | 12 | 13 | const vm = require("vm"); | 13 | 14 | const BasicEvaluatedExpression = require("./BasicEvaluatedExpression"); | 14 | 15 | const StackedSetMap = require("./util/StackedSetMap"); | 15 | 16 | const TrackingSet = require("./util/TrackingSet"); | 16 | 17 |
| | 18 | +const acornParser = acorn.Parser.extend(acornDynamicImport); | | 19 | + | 17 | 20 | const joinRanges = (startRange, endRange) => { | 18 | 21 | if (!endRange) return startRange; | 19 | 22 | if (!startRange) return endRange; | @@ -25,10 +28,7 @@ const defaultParserOptions = { | 25 | 28 | locations: true, | 26 | 29 | ecmaVersion: 2019, | 27 | 30 | sourceType: "module", | 28 | | - onComment: null, | 29 | | - plugins: { | 30 | | - dynamicImport: true | 31 | | - } | | 31 | + onComment: null | 32 | 32 | }; | 33 | 33 |
| 34 | 34 | // regexp to match at lease one "magic comment" | @@ -2133,9 +2133,13 @@ class Parser extends Tapable { | 2133 | 2133 | sourceType: this.sourceType, | 2134 | 2134 | locations: false | 2135 | 2135 | }); | | 2136 | + // TODO(https://github.com/acornjs/acorn/issues/741) | | 2137 | + // @ts-ignore | 2136 | 2138 | if (ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement") { | 2137 | 2139 | throw new Error("evaluate: Source is not a expression"); | 2138 | 2140 | } | | 2141 | + // TODO(https://github.com/acornjs/acorn/issues/741) | | 2142 | + // @ts-ignore | 2139 | 2143 | return this.evaluateExpression(ast.body[0].expression); | 2140 | 2144 | } | 2141 | 2145 |
| @@ -2226,7 +2230,7 @@ class Parser extends Tapable { | 2226 | 2230 | let error; | 2227 | 2231 | let threw = false; | 2228 | 2232 | try { | 2229 | | - ast = acorn.parse(code, parserOptions); | | 2233 | + ast = acornParser.parse(code, parserOptions); | 2230 | 2234 | } catch (e) { | 2231 | 2235 | error = e; | 2232 | 2236 | threw = true; | @@ -2238,7 +2242,7 @@ class Parser extends Tapable { | 2238 | 2242 | parserOptions.onComment.length = 0; | 2239 | 2243 | } | 2240 | 2244 | try { | 2241 | | - ast = acorn.parse(code, parserOptions); | | 2245 | + ast = acornParser.parse(code, parserOptions); | 2242 | 2246 | threw = false; | 2243 | 2247 | } catch (e) { | 2244 | 2248 | threw = true; | |
Collapse file Copy file name to clipboardExpand all lines: package.json +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | "@webassemblyjs/helper-module-context": "1.7.11", | 10 | 10 | "@webassemblyjs/wasm-edit": "1.7.11", | 11 | 11 | "@webassemblyjs/wasm-parser": "1.7.11", | 12 | | - "acorn": "^5.6.2", | 13 | | - "acorn-dynamic-import": "^3.0.0", | | 12 | + "acorn": "^6.0.5", | | 13 | + "acorn-dynamic-import": "^4.0.0", | 14 | 14 | "ajv": "^6.1.0", | 15 | 15 | "ajv-keywords": "^3.1.0", | 16 | 16 | "chrome-trace-event": "^1.0.0", | |
Collapse file Copy file name to clipboardExpand all lines: test/cases/parsing/precreated-ast/ast-loader.js +3-5Lines changed: 3 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | "use strict"; | 2 | 2 |
| 3 | | -const acorn = require("acorn-dynamic-import").default; | | 3 | +const acorn = require("acorn"); | | 4 | +const acornParser = acorn.Parser.extend(require("acorn-dynamic-import").default); | 4 | 5 |
| 5 | 6 | module.exports = function(source) { | 6 | 7 | const comments = []; | 7 | | - const ast = acorn.parse(source, { | | 8 | + const ast = acornParser.parse(source, { | 8 | 9 | ranges: true, | 9 | 10 | locations: true, | 10 | 11 | ecmaVersion: 2017, | 11 | 12 | sourceType: "module", | 12 | | - plugins: { | 13 | | - dynamicImport: true | 14 | | - }, | 15 | 13 | onComment: comments | 16 | 14 | }); | 17 | 15 |
| |
Collapse file Copy file name to clipboardExpand all lines: yarn.lock +10-7Lines changed: 10 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -279,12 +279,10 @@ accepts@~1.2.12: | 279 | 279 | mime-types "~2.1.6" | 280 | 280 | negotiator "0.5.3" | 281 | 281 |
| 282 | | -acorn-dynamic-import@^3.0.0: | 283 | | - version "3.0.0" | 284 | | - resolved "https://registry.yarnpkg.com/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz#901ceee4c7faaef7e07ad2a47e890675da50a278" | 285 | | - integrity sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg== | 286 | | - dependencies: | 287 | | - acorn "^5.0.0" | | 282 | +acorn-dynamic-import@^4.0.0: | | 283 | + version "4.0.0" | | 284 | + resolved "https://registry.yarnpkg.com/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz#482210140582a36b83c3e342e1cfebcaa9240948" | | 285 | + integrity sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw== | 288 | 286 |
| 289 | 287 | acorn-globals@^1.0.3: | 290 | 288 | version "1.0.9" | @@ -339,11 +337,16 @@ acorn@^5.0.0, acorn@^5.3.0: | 339 | 337 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8" | 340 | 338 | integrity sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ== | 341 | 339 |
| 342 | | -acorn@^5.0.3, acorn@^5.6.0, acorn@^5.6.2: | | 340 | +acorn@^5.0.3, acorn@^5.6.0: | 343 | 341 | version "5.7.2" | 344 | 342 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.2.tgz#91fa871883485d06708800318404e72bfb26dcc5" | 345 | 343 | integrity sha512-cJrKCNcr2kv8dlDnbw+JPUGjHZzo4myaxOLmpOX8a+rgX94YeTcTMv/LFJUSByRpc+i4GgVnnhLxvMu/2Y+rqw== | 346 | 344 |
| | 345 | +acorn@^6.0.5: | | 346 | + version "6.0.5" | | 347 | + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.5.tgz#81730c0815f3f3b34d8efa95cb7430965f4d887a" | | 348 | + integrity sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg== | | 349 | + | 347 | 350 | ajv-errors@^1.0.0: | 348 | 351 | version "1.0.0" | 349 | 352 | resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59" | |
|