next.js
4669a153 - fix(turbopack): webpack-loaders failed to resolve relative path (#82720)

Commit
178 days ago
fix(turbopack): webpack-loaders failed to resolve relative path (#82720) fixed: #82106 The error was cause by the follow reason, when pass: ```ts const nextConfig: NextConfig = { /* config options here */ turbopack: { rules: { '*.txt': { loaders: ['./test-file-loader.js'], as: '*.js', }, } } }; ``` and the project directory as follows: ```bash src |_ app |_ index.tsx |_ text.txt ``` The loader will deal the `text.txt` under `src/app`, then the loader will resolve path like: ```ts require.resolve('./test-file-loader.js', paths: ['/Users/next-app/src/app']) ``` Because the resource dir the `dirname(resoucePath)`, and the resourcePath is `/Users/next-app/src/app/text.txt`, this will never resolve the right loader path here. So I just add a more `path` param(which is `contextDir`) for the require.resolve function, it will help the loader to find the right path here.
Author
Parents
Loading