-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Symlinks in project - loader not working when using include? #1643
Comments
Having a similar issue with symlinks... I have all my modules under a
Tried a few things in the config such adding the actual path of the directory I symlinked to in This issue seems similar but none of the solutions there solved the issue. Feel like I'm missing something obvious... |
+1, I have this exact problem, the loader (babel) does not seem to be getting applied to files under a symlink. Replacing the symlink with an actual directory works. |
I think that the main issue here is that webpack resolves symlinks and it actually 'sees' this files by their absolute path. And this absolute path doesn't match your Could you please check this? |
Some info about this behavior can be found here #554 |
I was able to fix this by doing the following in webpack.config.js (this is for importing our components library using the jsx files rather than the compiled umd): var includePaths = [
fs.realpathSync(__dirname + '/app'),
fs.realpathSync(__dirname + '/node_modules/my-repo/lib'),
]; And then later: module: {
loaders: [{
test: /\.js?$/,
include: includePaths,
loader: 'babel'
}, {
test: /\.jsx?$/,
include: includePaths,
loader: 'babel'
},{
test: /\.json?$/,
loader: 'json'
}, {
test: /\.css$/,
loader: 'style!css?modules&localIdentName=[name]---[local]---[hash:base64:5]'
}]
}, |
I got this to work by setting the includePaths but also by setting both resolve.root and resolveLoader.root to
|
@jraede would it be possible for you to provide your webpack.config I'm running into a similar problem and even after implementing your suggested solution i get the following error
Note: /LifeInYourWay/ is a symlink pointing to a folder on a mounted drive |
I tried the I used |
@eagsalazar's suggestion of using |
For anyone trying the Anyway, @eagsalazar's suggestion of using an absolute path for the value of |
The |
@DenisVuyka Yep. Trying to work with linked modules in Webpack 2 is proving to be nightmare. I've wasted a horrible amount of time on related issues. |
@Undistraction It is much better than Webpack 1 based on my experiments. Setting up 1 project with 1 symlink it usually a breeze. The problem is that it seems nobody tested the flow beyond 1 symlink. |
Trying to remove the emotion here, but this really needs to be fixed: Ticket still unresolved for 68 weeks... |
Updating followers of this ticket:I ditched the symlink approach; instead, I created another node module which compiles on its own with babel that is locally linked. That package has this in "name": "awesome-module",
"main": "lib/index.js",
"scripts": {
"build:clean": "rimraf dist lib",
"build:ensure": "mkdir -p lib",
"build:js": "npm run build:ensure && babel -d lib/ src/ -s inline",
"build": "npm run build:clean && npm run build:ensure && npm run build:js",
"watch:js": "npm run build:js -- -w",
"watch": "npm run build && npm run watch:js",
"postinstall": "npm run build",
// ...
} And Then execute Also running |
@elado Thanks for the info, but using |
@Undistraction correct, but the idea is to have webpack only include the other module without transpiling it with babel-loader. It's already compiled by babel on its own, and looks like any other ES5 module. |
Still can't quite get this to work with Webpack 2.2.1 on node 6.10.0 even using the fs.realpathsync approach.
I have external javascript modules in a separate package that need to be compiled. When I console log the includePaths I see
However when I run webpack all the javascript in the npm linked module throws compile errors as it doesn't recognize the syntax I'm using. Not sure what I'm missing here. Any ideas? |
Not the same problem but similar to this is resolved for me by I needed to load with |
I am on the latest webpack 2.11.1 and latest wds. These lines allow me to use my file:.. linked packages in package.json for local dev symlinked and have them update when I change it. The key is the path.resolve you want to make sure you point it to the TOP and only the top node_modules.
|
hi, i have been working on a web app using reactjs but when i run "npm start" it is there anything i can do to solve this please. i tried running npm install commondir but still did not work. thanks |
I was able to fix that problem modifying webpack.dev.conf.js which is in build folder. I added some files to copy which are symlinks (lib for example). So I have static/lib --> ../../../lib |
Also worked for us! If you have a symlink to a folder outside of your project root, this seems to be the way. Because otherwise the symlinked folder is resolved in an absolute path which is outside the project root and is then being ignored |
This allows to install npm packages locally or via npm link. See webpack/webpack#1643 (comment) for more details.
the following works for me.
|
I figured out that However, after moving all my babel configs (originally from // [...]
{
test: /\.tsx$/,
exclude: /(disposables)/,
use: {
loader: "babel-loader?cacheDirectory",
options: require("./package.json")).babel
}
}
// [...] References: |
This work for me. Try this solution when using lerna(monorepo with symlink) with webpack, you might find the loader trying to load what should be excluded. Keywords for search engine: typescript ts-loader symlink lerna webpack |
Should work with |
For me (webpack {
module: {
rules: [
{
oneOf: [
{
//The rule I want to fix
// This is to also include monorepo packages
include: [/node_modules\/@organization/]
}
]
}
],
},
resolve: {
symlinks: false
}
} |
It works for me, thank you! |
It does not work for me with v5.71.0 on Windows. npm linked Using The hack from https://medium.com/capriza-engineering/sharing-source-code-and-libraries-in-react-bd30926df312 step 5.1/5 is still required. @vankop Are you sure webpack checks the paths against the include patterns both before and after resolving the symlinks? |
there is nothing todo with Otherwise please add |
That was enough for me. Thank you folks. |
Can webpack read through symlinks? I have a simple symlink under
/src
with.jsx
files. I have{ test: /\.jsx?$/, loader: 'babel-loader?...', include: path.resolve(__dirname, 'src') }
but it won't load files withbabel-loader
, I get ES5 compilation error.If I replace the symlink with the actual folder and files - it works.
If I replace the
include
withexclude: /node_modules/
it also works.Bug, or am I doing it wrong?
The text was updated successfully, but these errors were encountered: