-
Notifications
You must be signed in to change notification settings - Fork 70
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
Unable to transpile node_modules #141
Comments
Hi. I'm sure you could modify the library or maybe even symlink the dependency into a src folder so babel-watch can see it. But generally this is not a supported use case. Your node modules, not being project source, should be runnable as they sit on disk. Given they should only be transpiled once in any case, it makes little sense to have them watched by a file watcher. |
I agree with you, but unfortunately the packages I am using are not runnable as they are because they are not distributed in CJS format and I can't do much about it. I'll try to find a working configuration for my project. |
Yeah - packages shouldn't be distributed that way! But that said a symlink or a pre build step before babel watch runs, might fix it for you. |
babel-watch is meant to extend the behaviour of @babel/node with fast reload. According to the conversation: babel/babel#8802 @babel/node has "ignore" regex option that is set to node_modules by default, but it can be overridden. Might be a viable idea to add a similar setting to babel-watch. As long as it doesn't cause issues with cascaded dependencies. As for only transpiling it once, a lot of different builds use webpack or similar tools, setting exception for node_modules they support. I used to always write nodejs dependencies in pure cjs, without transpilation to avoid this but recently I had to pull some ts-dependencies into NodeJS - and yep, had to rewrite the distribution system to provide both esm/cjs, while generating package.json "exports" on the fly. |
Hello,
My application requires certain dependencies in
node_modules
to be transpiled. However, it seems thatbabel-watch
completely ignoresnode_modules
no matter what my config is.I looked in the source code and noticed this if at line 68 in
runner.js
:which could explain the exclusion. I am not a babel expert by any means, but is there a way to circumvent this restriction?
The text was updated successfully, but these errors were encountered: