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
gulpfile.babel.js does not compile imported es6 modules from node_modules #1234
Comments
All node modules should be compiled before publishing to npm. What you are doing is an anti-pattern. |
It's not on npm, its installed using an npm git url. |
I'd also like to point out that what I'm doing here is not making package A in es6; package A is compiled from es6, using its own gulpfile. What I'm trying to do is use package A's gulp config which is in es6. |
Your prepublish script might run on install from github, if not, you can use an install script. No matter what, it is a packaging problem (thus the npm client) not a gulp problem. |
So you're suggesting the work around here is to have package A's gulpfile compile it's own gulpfile.babel.js to js and put that into some dist/gulp folder? Seems like a hack, but fair enough. /shrug |
https://babeljs.io/docs/usage/require/
This isn't a gulp issue |
It actually reads:
Is there some way to control how gulp imports babel to customize this from On Mon, Sep 7, 2015 at 5:12 PM, Callum Macrae notifications@github.com
|
Could try this #830 (comment). Also read the other comments |
oh, thats quite a reasonable way of doing it~ On Monday, September 7, 2015, Callum Macrae notifications@github.com
|
You could use the "ignore" option in your .babelrc but it's broken right now -- neither babel-cli nor babel-register are reading it: https://phabricator.babeljs.io/T6726 |
@shadowmint & All, I am facing the same issue..? May I know what is the good approach..? I am bit confused by above comment.. The situation is same as @shadowmint has discussed, "dev-tools" is lib which has gulp task and "CAPP" imports the tasks from "dev-tools" module in gulpfile.babel.js when I run the gulp build it shows below error: `C:\projects\app\CAPP>gulp build SyntaxError: Unexpected token import |
Support questions should be directed to StackOverflow. I am going to lock this issue, as it has become a dumping ground for all comments about babel. |
tldr; When running in 'babel' mode, gulp compiles local files from es6 to js to run them.
However, modules in node_modules are assumed to already be compiled and are not modified.
What's up with that?
long version
Repo showing the issue: https://github.com/shadowmint/tmp-gulp-test-babel
The error:
Modules in node_modules seem to not be compiled?
Although this... kind of makes sense, it's annoying in a very real sense.
This is the situation I currently have:
Ideally, B could npm install A, and then use this from the local gulpfile.babel.js:
...and indeed, if A is in raw javascript, it works. However, if A uses es6 gulp files, the import fails (as shown in the linked example).
The solution is to clone A as a submodule in B, and that works too... but it's not ideal, for all the reasons that using npm at all makes sense.
So, two questions:
Is there a good reason not to invoke babel on node_modules?
Is this a 'bug' or a 'feature'; in that, will it ever be fixed, or is this something that I need to find a long term work around for?
...or am I just 'doing it wrong'? The documentation on gulpfile.bable.js is pretty sparse, but as far as I can see I would expect what I'm doing to work...?
The text was updated successfully, but these errors were encountered: