Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Conversation

@rafeca
Copy link
Contributor

@rafeca rafeca commented Apr 25, 2019

When trying to land an upgrade of the markdown-preview package, we realized that electron-link does not support some modern JS syntax features. This was due to the esprima parser which is quite old.

To solve this, I've changed the esprima configuration to use acorn as a parser, specifying that we want to support the 9th edition syntax features.

Verification process

This allows electron-link to handle code with ecmaScipt 9th edition features.
@rafeca
Copy link
Contributor Author

rafeca commented Apr 25, 2019

I've verified that Atom can be built correctly with this change 🎉

Edit: There's an error when using this modified version 😟

Generating snapshot script at "/Users/rafeca/github/atom/atom/out/startup.js" (836)Unable to transform source code for module /Users/rafeca/github/atom/atom/out/app/node_modules/typescript/bin/typescriptServices.js.
SyntaxError: Binding arguments in strict mode (6347:32)

Don't know why the whole typescript is trying to be added to the startup snapshot

Copy link
Contributor

@smashwilson smashwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, then this should be good to go.

Co-Authored-By: rafeca <[email protected]>
@rafeca rafeca requested a review from smashwilson April 25, 2019 13:42
Copy link
Contributor

@as-cii as-cii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 💯

By default, `recast` sets it to `module` (even if `acorn` has it set as
`script`). This causes parsing issues since all files are treated in strict mode.
@rafeca
Copy link
Contributor Author

rafeca commented Apr 25, 2019

The previous TypeScript error was caused by recast, which treats JS files as modules by default (source), even when acorn treats them as scripts.

This caused issues with some non-strict JS files that were parsed as strict and lead to syntax errors.

@rafeca rafeca merged commit e52ddbf into master Apr 25, 2019
@rafeca rafeca deleted the upgrade-recast branch April 25, 2019 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants