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

wrap the import? #3

Open
oliviertassinari opened this issue Aug 23, 2016 · 2 comments
Open

wrap the import? #3

oliviertassinari opened this issue Aug 23, 2016 · 2 comments

Comments

@oliviertassinari
Copy link

oliviertassinari commented Aug 23, 2016

I'm wondering if it would aslo make sens to let the plugin wrap the import/require of the warning dependency with a process.env.NODE_ENV !== 'production' block.

That shouldn't make any different when using a flat bundler like rollup but I think that would save us some module tree traversal when using a bundler like webpack.

@taion
Copy link
Contributor

taion commented Aug 23, 2016

Could work. Right now this is a literal copy/paste of https://github.com/facebook/fbjs/blob/master/packages/babel-preset-fbjs/plugins/dev-expression.js. That would take it away a bit.

It wouldn't necessarily be 100% maybe? e.g. I use it for https://github.com/reactjs/react-router/blob/8707d05b00273590e4d054771b8ae7ae9ad312e3/modules/RoutingContext.js#L3. But maybe that doesn't matter.

@anilanar
Copy link

anilanar commented Feb 13, 2017

There's one catch to this proposal: wrapping an import is not valid ES6 and will cause babel to complain as such:

'import' and 'export' may only appear at the top level

However, I don't see harm in making it an option.

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

No branches or pull requests

3 participants