-
-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
WIP: Use babylon as the parser #4308
Conversation
lib/Parser.js
Outdated
@@ -536,8 +536,10 @@ Parser.prototype.walkForOfStatement = function walkForOfStatement(statement) { | |||
|
|||
// Declarations | |||
Parser.prototype.walkFunctionDeclaration = function walkFunctionDeclaration(statement) { | |||
this.scope.renames["$" + statement.id.name] = undefined; | |||
this.scope.definitions.push(statement.id.name); | |||
if(statement.id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary fix
Ref estree/estree#98
the error before was trying to access name
of null (since id is null) for export default function() {}
Acorn: FunctionExpression
Babel: FunctionDeclaration + null id
Need to figure out why https://github.com/hzoo/webpack/blob/test-babylon/test/cases/parsing/issue-2570/fn.js
turns into
webpack + babylon
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function() { return [].slice.call(arguments); } // invalid
/***/ }),
webpack master + acorn
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony default export */ __webpack_exports__["a"] = (function() { return [].slice.call(arguments); });
/***/ }),
I ran a build against I use the programmatic API from Webpack. I had issues linking modules with npm, I ended up requiring directly the module: + "webpack": "git@github.com:hzoo/webpack.git#test-babylon",
- "webpack": "^2.2.0-rc.1", |
I guess you won't continue this? Can this be closed or do you want to rebase it to get more results? |
It should be fixed after that acorn change, I can rebase |
c9dd163
to
ac193f9
Compare
How is |
Yeah, every available parser seems to fundamentally error on that, apart from acorn. @hzoo @sokra Is it worth taking the time to explore making the parser pluggable as part of this, rather than just a straight replacement? I started a fork quite a while ago attempting to use |
@hzoo Please review the following output log for errors:
See complete report here. |
Discontinued, acorn seem to be faster |
Are you open to switch the parser for a more performant alternative? What’s the time spent parsing on average on a large project? I think the parser is the major bottleneck in current webpack build times |
What kind of change does this PR introduce?
Testing out babylon parser instead of acorn
Did you add tests for your changes?
No extra tests, more of an internal change (parser swap)
Summary
Use babylon for other syntax support