-
-
Notifications
You must be signed in to change notification settings - Fork 449
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
Doesn't compile a npm linked module #149
Comments
interesting, I just ran into this issue as well. however, i did unlink, make a copy, clear my node modules, and retry in the copy, with no results. unsure at this point. will continue to debug |
Your config is not right. You need to include babel presets in your loader config as well as your babelrc or babelConfig in your package.json. The presets for babel loader can be added with query params or query object. Review the babel 6 docs on presets for your babel config. The preset packages must also be included your project. Currently things are working for me with babel-loader@6.01 with babel presets and babel-core@6.1.4 |
perhaps you're right. I never installed all of the deps. Likely part of a major bump? Readme ref |
I have the same issue. I have a package at Webpack loader config in
Output from running webpack:
How can I make babel-loader use the presets installed in the project the same way it did when the dependency where located inside the project directory instead of looking for it in the linked project directory? |
@henit Try putting the presets in your package.json instead with a babel property:
|
@scriptjs Gave the same webpack error as in my post above Having the presets in neither the loader config or directly in the webpack config makes it complain about the syntax (since the file it is trying to include is in ES6). Once I include the presets in one of the two places, the syntax error is replaced by complaining that it does not find the preset modules. Whatever I do, I cannot get the loader to use the presets from the current project modules when importing files from a dependency that is located outside of the root of the package (since I have put the npm linked module in the directory above as described earlier). I tried adding the resolve.fallback with the parent dir (where the linked dependency is located), did not help. |
@henrit Perhaps there is something not sane in your babel dependencies impacting your project but you will need to investigate this. I am faced with something just about as strange. This is having an impact on a react native app project in a monorepo. If I remove the project out of the monorepo it compiles and runs. Within the monorepo it compiles but will not run due to an exception being thrown in react native since there is something global leaking into it from babel – from where is the question – and it is bugging the hell out of me. I too take advantage of npm link in this work. There are a lot of moving parts atm. React, babel, npm are all moving simultaneously at a significant speed which only makes getting to the bottom of these things more difficult. |
Seeing the same issue, building failed with an
|
I'm pretty sure I've got those modules installed and it's not about the presets, babel-loader simply fails with symlinks |
I can confirm that this has something to do with the location of the presets package.
I've first tried to use
When installing it in the node_modules folder of the project root, it magically works. This made no sense to me, as So there must be something wrong with either the webpack option |
+++, related stackoverflow answer: http://stackoverflow.com/questions/34574403/how-to-set-resolve-for-babel-loader-presets/ |
Thanks @mqklin, this works, but unfortunately when you use multiple loaders you can't use a query object. Here is the workaround in this case: var queryObject = {presets: [require.resolve('babel-preset-es2015')]};
var query = require('querystring').stringify(queryObject);
config.loaders = [{
test: /\.js$/,
loaders: ['ng-annotate', 'babel?' + query]
}]; |
I have the same setup as @nirazul. Using Additionally I set |
An update on this issue: while this workaround works for most babel presets, it doesn't work for babel-transform-runtime, i.e. setting up the loader with:
doesn't work. Has anyone found a workaround for symlinks and babel-transform-runtime ? |
same problem for me, this workaround seemed to help: The query-stringify solution seems to have helped for me. |
Chiming in on this thread as I've got a variant scenario (I think). I've developing a CLI tool that functions like a black box site generator. My intent is that the tool be installed globally and executed from the command line where it locates a containing package.json relative to cwd() that it parses to retrieve some options. Subsequently, the contents of the target project (i.e. the dir structure rooted at the directory where package.json was found) is processed into a site, and the generated resources are written back out to the target project directory structure. Internal to the tool, I synthesize webpack configuration objects and delegate to webpack which in turn delegates to babel-loader, babel ... and fails when resolving the es2015 and react presets as described here (for slightly different reasons than typical but same root cause I think). Currently, webpack and babel loader are correctly resolved in the node_modules dir of my tool where they're declared as regular dependencies in the tool's package.json. This isn't a global install of anything more than a random Node.js derived CLI tool that happens to depend on webpack, babel... as an implementation detail. So although I agree with the rationale of wanting to install babel on a per-project basis, this sharp edge with presets makes it difficult to embed in automation scripts. For now I've modifying the dev-dependencies of the target project package.json and going to force an npm install prior to the first invocation of webpack (occurs as one of many steps in the site generation process encapsulated by the tool). But I think this extra complexity is not really necessary. This thread: https://discuss.babeljs.io/t/error-parsing-jsx-with-global-installation-babel-preset-react/59/14 on Babel discussion is fairly recent and seems related. Anyone know how to get this sort of wholly encapsulated embedding to work elegantly? Thanks. |
This is happening to me as as well. @barroudjo's suggested workaround seems to work in my case:
|
I don't think it does. At least in my case this solution caused the presets to be packaged with the source code. Have you checked yours? P.S. Actually, I don't know if that's what caused that... but when doing either:
resulting bundle includes stuff like:
|
I'm a big fan of @seantimm's solution in #179:
Easier than all those |
Added tests to the PR few days ago (finally), I'll see if I can give someone a nudge. |
@scriptjs I guess you are right. My project ran into this error in my mac but everything is ok on my firend's mac, and the difference is he never us react native. And my Solution is using a .babelrc file to config babel not in webpack config file. I guess babel will search for .babelrc file if project folder not contain one |
I still can't get this to work. I've tried everything in this thread. Seems to be specific with
|
@hitchcott that's something else since the loaders are found, this might be the order of your loaders? Hard to tell without the config, don't hijack this issue though ;) |
Using Webpack 4 I did not use the symlink: false in resolve but simply had to use
|
For some reason, over the last couple months the exclude solution stopped working for me. The fix was simply to switch exclude to include!
|
@coomysky's approach worked for me. #149 (comment) |
The issue here is most likely that As of Babel 7, this is restricted even further, and |
What should I put in |
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
I had a .babel.rc at the project root folder. I just renamed it to
|
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
* fix(internals): Fix babel relative preset Fix webpack issue with relative babel preset paths: babel/babel-loader#149 * feat(docs): Add docs for extracting components Add draft version of docs describing how to extract components to their own npm packages.
Not sure this is a babel loader issue or a webpack issue.
I am developing two modules and one of them has a dependency on the other. So I have npm linked it.
I have the following config on webpack:
This works fine if I install dependency as a local dependency but if I use npm link, babel doesn't process it.
Am I missing something? Or is there a workaround for this?
The text was updated successfully, but these errors were encountered: