Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to parse the code of @babel/core #962

Closed
aminya opened this issue Jun 29, 2020 · 4 comments
Closed

Failing to parse the code of @babel/core #962

aminya opened this issue Jun 29, 2020 · 4 comments

Comments

@aminya
Copy link

aminya commented Jun 29, 2020

Bug Report

Acorn 7.3.1 fails to parse the code of @babel/core. Particularly this file:

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = import_;

function import_(filepath) {
  return import(filepath);
}
Details
2020-06-29T02:36:43.2059234Z Generating snapshot script at "/__w/1/s/out/startup.js" (3770)Unable to transform source code for module /__w/1/s/out/app/node_modules/@babel/core/lib/config/files/import.js.
2020-06-29T02:36:43.2059872Z SyntaxError: Unexpected token (9:9)
2020-06-29T02:36:43.2060285Z   at Parser.pp$4.raise (/__w/1/s/script/node_modules/acorn/dist/acorn.js:2825:15)
2020-06-29T02:36:43.2060817Z   at Parser.pp.unexpected (/__w/1/s/script/node_modules/acorn/dist/acorn.js:689:10)
2020-06-29T02:36:43.2061403Z   at Parser.pp$3.parseExprAtom (/__w/1/s/script/node_modules/acorn/dist/acorn.js:2266:21)
2020-06-29T02:36:43.2061975Z   at Parser.pp$3.parseExprSubscripts (/__w/1/s/script/node_modules/acorn/dist/acorn.js:2089:21)
2020-06-29T02:36:43.2062562Z   at Parser.pp$3.parseMaybeUnary (/__w/1/s/script/node_modules/acorn/dist/acorn.js:2066:19)
2020-06-29T02:36:43.2063135Z   at Parser.pp$3.parseExprOps (/__w/1/s/script/node_modules/acorn/dist/acorn.js:2010:21)
2020-06-29T02:36:43.2063813Z   at Parser.pp$3.parseMaybeConditional (/__w/1/s/script/node_modules/acorn/dist/acorn.js:1993:21)
2020-06-29T02:36:43.2070126Z   at Parser.pp$3.parseMaybeAssign (/__w/1/s/script/node_modules/acorn/dist/acorn.js:1968:21)
2020-06-29T02:36:43.2071153Z   at Parser.pp$3.parseExpression (/__w/1/s/script/node_modules/acorn/dist/acorn.js:1933:21)
2020-06-29T02:36:43.2073238Z   at Parser.pp$1.parseReturnStatement (/__w/1/s/script/node_modules/acorn/dist/acorn.js:1005:33)
2020-06-29T02:36:43.2074002Z   at Parser.pp$1.parseStatement (/__w/1/s/script/node_modules/acorn/dist/acorn.js:835:37)
2020-06-29T02:36:43.2075304Z   at Parser.pp$1.parseBlock (/__w/1/s/script/node_modules/acorn/dist/acorn.js:1161:23)
2020-06-29T02:36:43.2076941Z   at Parser.pp$3.parseFunctionBody (/__w/1/s/script/node_modules/acorn/dist/acorn.js:2671:24)
2020-06-29T02:36:43.2078497Z   at Parser.pp$1.parseFunction (/__w/1/s/script/node_modules/acorn/dist/acorn.js:1283:10)
2020-06-29T02:36:43.2080618Z   at Parser.pp$1.parseFunctionStatement (/__w/1/s/script/node_modules/acorn/dist/acorn.js:983:17)
2020-06-29T02:36:43.2081360Z   at Parser.pp$1.parseStatement (/__w/1/s/script/node_modules/acorn/dist/acorn.js:830:19)
2020-06-29T02:36:43.2090492Z   at Parser.pp$1.parseTopLevel (/__w/1/s/script/node_modules/acorn/dist/acorn.js:746:23)
2020-06-29T02:36:43.2091224Z   at Parser.parse (/__w/1/s/script/node_modules/acorn/dist/acorn.js:553:17)
2020-06-29T02:36:43.2093874Z   at Function.parse (/__w/1/s/script/node_modules/acorn/dist/acorn.js:576:37)
2020-06-29T02:36:43.2094399Z   at Object.parse (/__w/1/s/script/node_modules/acorn/dist/acorn.js:4949:19)
2020-06-29T02:36:43.2095688Z   at Object.parse (/__w/1/s/script/node_modules/electron-link/node_modules/recast/parsers/acorn.js:14:32)
2020-06-29T02:36:43.2096565Z   at Object.parse (/__w/1/s/script/node_modules/electron-link/lib/file-require-transform.js:26:50)
2020-06-29T02:36:43.2097408Z   at Object.parse (/__w/1/s/script/node_modules/electron-link/node_modules/recast/lib/parser.js:31:30)
2020-06-29T02:36:43.2098265Z   at FileRequireTransform.apply (/__w/1/s/script/node_modules/electron-link/lib/file-require-transform.js:23:23)
2020-06-29T02:36:43.2099091Z   at /__w/1/s/script/node_modules/electron-link/lib/generate-snapshot-script.js:55:56
2020-06-29T02:36:43.2099563Z   at Generator.next (<anonymous>:null:null)
2020-06-29T02:36:43.2100279Z   at step (/__w/1/s/script/node_modules/electron-link/lib/generate-snapshot-script.js:3:191)
2020-06-29T02:36:43.2101049Z   at /__w/1/s/script/node_modules/electron-link/lib/generate-snapshot-script.js:3:361

https://github.visualstudio.com/Atom/_build/results?buildId=74019&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb&t=b525c197-f769-5e52-d38a-e6301f5260f2&l=3829

Environment

  System:
    OS: Windows 10 10.0.19041
  Binaries:
	apm  2.5.0
	npm  6.14.5
	node 10.20.1 x64
	atom unknown
	python 2.7.6
	git 1.9.1
  npmPackages:
    @babel/cli: 7.10.3 => 7.10.3
    @babel/core: 7.10.3 => 7.10.3
    @babel/plugin-proposal-class-properties: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-decorators: ^7.10.3 => 7.10.3
    @babel/plugin-proposal-do-expressions: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-export-default-from: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-export-namespace-from: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-function-bind: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-function-sent: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-json-strings: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-logical-assignment-operators: ^7.10.3 => 7.10.3
    @babel/plugin-proposal-nullish-coalescing-operator: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-numeric-separator: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-optional-chaining: ^7.10.3 => 7.10.3
    @babel/plugin-proposal-pipeline-operator: ^7.10.1 => 7.10.1
    @babel/plugin-proposal-throw-expressions: ^7.10.1 => 7.10.1
    @babel/plugin-syntax-dynamic-import: ^7.8.3 => 7.8.3
    @babel/plugin-syntax-import-meta: ^7.10.1 => 7.10.1
    @babel/plugin-transform-async-to-generator: 7.10.1 => 7.10.1
    @babel/preset-env: 7.10.3 => 7.10.3
    @babel/preset-flow: ^7.10.1 => 7.10.1
    @babel/preset-react: ^7.10.1 => 7.10.1

Additional context

  • I am trying to update the babel plugin that is used in Atom internally. Atom uses electron-link for bundling the dependencies (including @babel/core)
  • Previously Atom used babel 5.8.38.
  • Atom now uses Electron 5, which is based on Node 10.
  • Here is the WIP PR: Upgrade babel to 7 atom/atom#20965
@marijnh
Copy link
Member

marijnh commented Jun 29, 2020

Are you setting ecmaVersion to 2020?

@RReverser
Copy link
Member

I wonder if we should emit a different error message for version-specific errors, given how common this mistake is.

@aminya
Copy link
Author

aminya commented Jun 29, 2020

Are you setting ecmaVersion to 2020?

No, I did not know about that. It was set to 9! I just updated it. Let me see if it resolves the issue.

@aminya
Copy link
Author

aminya commented Jun 29, 2020

The issue is resolved by setting that option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants