Skip to content

Add sourceType option#19

Closed
goto-bus-stop wants to merge 2 commits intobrowserify:masterfrom
goto-bus-stop:sourcetype
Closed

Add sourceType option#19
goto-bus-stop wants to merge 2 commits intobrowserify:masterfrom
goto-bus-stop:sourcetype

Conversation

@goto-bus-stop
Copy link
Member

Allows using syntaxError on ES modules source files.

@mattdesl
Copy link
Collaborator

What are the implications?

I’m 👍 on this since browserify is in need of more es6/import/export support.

@goto-bus-stop
Copy link
Member Author

goto-bus-stop commented Dec 24, 2017

yeah, actually PRing this b/c i'm working on a node-compatible --experimental-modules for browserify haha.

by default nothing changes. ES modules will still always fail the eval() syntax check. users can pass { sourceType: 'module' } to make the acorn syntax check accept ES modules syntax. so ES modules will always need a full parse with this code. it's optional so that import/export can still throw an error in commonjs files (browserify would set sourceType: 'module' for .mjs files and sourceType: 'script' for .js files).

goto-bus-stop added a commit to goto-bus-stop/node-syntax-error that referenced this pull request Jan 31, 2018
Uses acorn-node which is Acorn + some plugins and default options to
match recent Node.js.

This also changes the `opts` parameter to a simple pass thru, so that we
only need to update acorn-node when a new `ecmaVersion` is supported in
Node.

If this is merged we don't need browserify#19 because you will already be able to
pass the `sourceType`.
@goto-bus-stop
Copy link
Member Author

#20

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

Successfully merging this pull request may close these issues.

2 participants