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

Provide an option to parse a file as a script. #175

Closed
cameron-martin opened this issue Nov 23, 2018 · 3 comments
Closed

Provide an option to parse a file as a script. #175

cameron-martin opened this issue Nov 23, 2018 · 3 comments
Labels

Comments

@cameron-martin
Copy link

I am creating a codemod for converting a script into a module while retaining the same behaviour - the idea is to use it to integrate legacy scripts into a webpack build.

However, the issue is that the sourceType option to babel's parser is hardcoded to 'module' in this library, when I need it to parsed as a script.

Could this be added as an option to the CLI?

eventualbuddha added a commit that referenced this issue Nov 24, 2018
Previously babel-codemod hardcoded a value of `module` for the source type when parsing. This meant that any code not valid in strict mode could not be processed. Now babel-codemod uses a default source type of `unambiguous`, which means that babel will try to infer the source type. Additionally, this source type can be overridden with the `--source-type` option.

Closes #175
eventualbuddha added a commit that referenced this issue Nov 24, 2018
Previously babel-codemod hardcoded a value of `module` for the source type when parsing. This meant that any code not valid in strict mode could not be processed. Now babel-codemod uses a default source type of `unambiguous`, which means that babel will try to infer the source type. Additionally, this source type can be overridden with the `--source-type` option.

Closes #175
@babel-codemod-bot
Copy link

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@eventualbuddha
Copy link
Collaborator

Thanks for the suggestion! This should hopefully just work as-is if you update to v2.1.0, but you also have the option to specify the source type if you have to.

@cameron-martin
Copy link
Author

Thanks for this!

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

No branches or pull requests

3 participants