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

Allow import and export statement #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fabiosantoscode
Copy link

Currently, static-module crashes when reading modules which use the 'import' statement. This makes it fail to parse those modules and crash with the cryptic error message:

'import' and 'export' may appear only with 'sourceType: module' 

Which after some research I found comes from acorn, which is the crashing entity here :)

(my use case, IE how this crash affects me): This failure cascades to brfs, and from then on webpack's transform-loader. Webpack 2 now supports ES6 modules, which create-react-app favours. This made webpack fail to compile my project as it uses import statements.

@fabiosantoscode
Copy link
Author

fabiosantoscode commented Jul 27, 2017

Googlers from the future:

I worked around this issue by setting the acorn options myself. Since this module doesn't use acorn directly to parse, you need to get the same acorn as the one falafel is using. Which is a bit weird with npm3.

require('falafel/node_modules/acorn').defaultOptions.sourceType = 'module'

It's quite quirky and confusing, but that will do for this prototype.

Cheers!

@chengqiaozhi
Copy link

@fabiosantoscode Hi, i check the falafel but got nothing for acorn, i use webpack 3.0, thanks

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