-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
The development mode no longer works with a library imported via Yalc #35110
Comments
I can also reproduce when using Yalc, ESM exports only and 12.1.0. The Yalc symlink is treated as a local package instead of an external, and thus is built again with Next, with "import" transformed as "require", leading to issues with subdependencies of the ESM dependency. The packages works ok when I publish them on NPM. There might be unrelated issue about how cjs+esm exports works as well and maybe a similar issue with Yarn link. |
probably same issue of #34796 |
Here is a minimal reproduction: https://github.com/VulcanJS/repro-bug-yalc-next-12-1 A package that uses ES modules and depends on another package that also uses ES modules (say react-konva) cannot be linked via Yalc (and maybe with yarn link as well though I have only tested Yalc), as it will be treated as a local package by Next instead of an external. Next is probably tricked by the symlink to a local package, and thinks it should build that package. |
I am trying to dig the code in order to help fixing this. The latest commit that modifies it is: 82001f2 It could be interesting to test before and after that commit specifically, or at least debug what happens when it resolve a linked ES module. There is a unit test demo in "test/unit/webpack-config-overrides.test.ts", maybe we can check if it works when the path is outside Next.js directory (for symlinks) OR contains a .yalc in the path (I am not sure if we can solve this without specific rules for specific kind of tools). |
Same issue with Yarn 3 workspaces, with Next 12.1.6, that also use a symlink. git clone https://github.com/VulcanJS/vulcan-npm/tree/feature/remix-starter
cd vulcan-npm
yarn
cd starters/next
yarn run build I get: Failed to compile.
../../packages/mongo/mongoParams.ts
Module parse failed: The keyword 'interface' is reserved (79:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| // TODO: should we use TModel or Vulcan document here??
> interface FilterFunctionOutput {
| selector: FilterQuery<any>;
| options: QueryOptions;
Import trace for requested module:
../../packages/mongo/client/index.ts
../../packages/react-hooks/dist/index.js
./src/pages/vn/admin/crud/VulcanUser.tsx
> Build failed because of webpack errors So Everytime the dependency of the dependency is specifically affected, not necessarily the first-level dependency (here "@vulcanjs/react-hooks" is ok, but not "@vulcanjs/mongo" that it depends on ; both are ES modules with exports map). |
I'm currently facing this issue as well. |
+1 Next 14.0.4 Import trace for requested module: |
Same here, anyone found a solution to this? This is blocking us from upgrading to NextJS 14 |
I'm facing the same issue. NextJS I just tried I'm using |
I'm having the same issue with v14.0.4, but not with v14.0.1. |
Looks like if i remove
from all my local package's Not a real fix on vercel's side, but can get you unblocked. |
I occur the same error message when I upgrade nextjs 13 to 14, but the error related to package: my solution is:
|
I narrowed the problem down to version >14.1.4 in our application. Every Next version higher than that would block the dev mode. For me adding "resolutions": {
"@babel/runtime": "^7.24.6"
}, |
I just had the same issue <3 thanks @joeplaa |
i have also faced same issue and just updated nextjs app |
Seems that fix for that issue in that commit #60563 I've fixed that for my next.js version (13.5) with a webpack hack const transpilePackages = ['...']; // you should have your packages here
const transpilePackagesRegex = new RegExp(
`[/\\\\]node_modules[/\\\\](${transpilePackages?.map((p) => p.replace(/\//g, '[/\\\\]')).join('|')})[/\\\\]`,
);
function createWebpackConfig() {
return (config) => {
const oneOfRule = config.module.rules.find((rule) => 'oneOf' in rule);
oneOfRule.oneOf.forEach((rule) => {
if (
'use' in rule &&
Array.isArray(rule.use) &&
rule.use.some((u) => typeof u === 'string' && u.includes('react-refresh'))
) {
rule.exclude = [rule.exclude, transpilePackagesRegex];
}
});
return config;
};
} So that monkey patching fixed all errors... This isn't the best solution, and it's similar to how I used to manage the configuration for CRA. But we have to go with what we have... |
Run into similar issue like this: vercel/react-tweet#80 solved by adding ``` "resolutions": { "@babel/runtime": "^7.24.6" }, ``` Explained in this [issue](vercel/next.js#35110 (comment))
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Since I use version NextJS "12.1.0", when I launch my application in development mode, I have an error in the server console:
Note that before I was using version 12.0.4 and that I use yalc link to reference my custom library locally
Expected Behavior
my application launches correctly in development mode (without error) and manages to use my custom library imported with "yalc link"
To Reproduce
Use a next application in version 12.1.0, reference an external NPM library with "yalc link"
The text was updated successfully, but these errors were encountered: