next-transpile-modules: baseUrl doesn't work within transpiled repo
- I HAVE READ THE FAQ AND MY PROBLEM WAS NOT DESCRIBED THERE
- I WILL GIVE 10$ TO CHARITY IF MY SOLUTION WAS ACTUALLY IN THE README/FAQ
Are you trying to transpile a local package or an npm package? npm package (a github dependency)
Describe the bug
Using baseUrl to have absolute imports doesn’t work within the transpiled repo.
To Reproduce
- Repo A is a Next.js Repo
- Repo B is a Next.js Repo
- Repo A & Repo B use
baseUrlto have absolute imports. - In Repo A, import a component in Repo B that uses an absolute import and you receive an error.
Expected behavior It should not break. 😇
Setup
- Next.js version: 10.0.4
next-transpile-modulesversion: 6.0.0- Node.js version: 12.20.0
npm/yarnversion: 6.14.8- Operating System: OS X 10.15.6
- Webpack 4 or 5: 4.44.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (8 by maintainers)
bump! this is necessary especially now that its being used with Vercel’s turborepo - will try to contribute here!
EDIT: nextjs app needs to reference the aliased paths in packages for compilation to work. I must have had a typo.
@martpie I found a solution with
tsconfig-paths-webpack-plugin.Nevertheless, in the end I decided to change the absolute paths to relative ones, because more problems followed. Thanks for your quick answers.
Never tried this feature, I’ll have to have a look 😃
@amlcodes can you open a new issue and fill the issue template there? This issue is quite old.
I think it’s worth adding into the README that ntm does not have baseUrl support. When deciding to use this repo, I looked at its restrictions and support to make sure I can use it so it would be good to rule it out up front.