-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
babel-loader doesn't run on symlinked files #3898
Comments
@vjpr: having a similar issue with typescript outside of the main root. Managed to solve that part with a modified version of your snippet, thanks! Do any of the modules you're importing themselves import npm packages? I'm having a follow-on issue where, for example, 'immutablejs' cannot be found, because it's looking for it relative to the "real" home of the symlinked code. Trying to figure out whether that's a typescript, ts-loader, or webpack related thing. For people also having ts issues, here's the modified snippet I'm using: function supportSymlinkedFilesInNextTypescriptLoader(config) {
const nextTypescriptLoader = config.module.rules.find(({ use, include, test }) => {
const isTypescriptLoader = use && use.length && use.find(({ loader }) => loader === 'ts-loader')
return isTypescriptLoader && test.toString() === '/\\.+(ts|tsx)$/'
})
if (!nextTypescriptLoader) return
nextTypescriptLoader.include = undefined
} Update: I got this working end-to-end by also setting
|
Unfortunately, this no longer seems to work for Next 6 and next-plugin-typescript 1.0.0, which moved to using babel-loader as well. The files are found, and executed, but if the file is outside the main tree, typescript compilation does not happen:
where most of the code resides under The updated function I'm using is:
Explicitly setting include to have both paths, rather than deleting it, does not work either. Have tried lots of different approaches to get this to work, but no luck. Will be stuck on Next 5.1 until there's a workaround. |
For others struggling with this, in Next 6 the loader is now With those changes, I have it working for next 6.0.3 and next typescript plugin 1.0.1. |
@majelbstoat thanks for digging out. I wonder if you can share your config files. I am using Next 6 with Typescript. I am facing the same problem with symlinks (lerna). My settings for the Next app
I copied |
My babelrc is the same as yours. However, I have a single babelrc file sitting in my root directory. You may need to run with "execMap": {
"ts": "NODE_PRESERVE_SYMLINKS=1 ts-node --project tsconfig.server.json"
} (I'm using a custom server for routing.) |
@majelbstoat thanks. However, as far as I can tell, |
ts-node runs the custom server. webpack/nextjs use babel loader. But symlinks don't work without that environment variable for me 🤷♂️ . |
Tracking this here: #706 |
https://github.com/zeit/next.js/blob/1bcd2e0575c40b577380b0bc5ad5104111cbf510/server/build/webpack.js#L181-L186
The
include: [dir]
means that only files in the current tree can be transpiled.Say you have a dir like:
The symlinked package is resolved to its "realpath" (
/src/symlinked-package
instead of/app/packages/symlinked-package
) by webpack. Theinclude: [dir]
prevents symlinked dirs from being transpiled.I am wondering what is the reason for having the
include
option?Your Environment
Workaround
The text was updated successfully, but these errors were encountered: