The issue involves module system interop problems when using yalc with Next.js 12.1.0.
The issue occurs when using yalc-linked packages with ESM exports in Next.js 12.1.0, causing module parsing errors. The problem relates to how Next.js handles symlinked packages in its webpack configuration. There's a reproduction available but the fix may require understanding both module systems and Next.js's build pipeline.
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.13.1
npm: 8.5.3
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.1.0
react: 17.0.2
react-dom: 17.0.2
No response
No response
Since I use version NextJS "12.1.0", when I launch my application in development mode, I have an error in the server console:
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from C:\dev\dev\XXX\XXX-core\.env.local
info - Loaded env from C:\dev\dev\XXX\XXX-core\.env
warn - SWC minify release candidate enabled. https://nextjs.org/docs/messages/swc-minify-enabled
Prepare XXX build client side
Prepare XXX build server side
error - ./.yalc/@XXX/XXX-customers/dist/customers/XXX/index.js
Module parse failed: Cannot use 'import.meta' outside a module (219:16)
File was processed with these loaders:
* ./node_modules/next/dist/compiled/@next/react-refresh-utils/loader.js
* ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js
You may need an additional loader to handle the result of these loaders.
| // still a Refresh Boundary later.
| // @ts-ignore importMeta is replaced in the loader
> import.meta.webpackHot.accept();
| // This field is set when the previous version of this module was a
| // Refresh Boundary, letting us know we need to check for invalidation or
Note that before I was using version 12.0.4 and that I use yalc link to reference my custom library locally
my application launches correctly in development mode (
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!