You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run next info (available from version 12.0.8 and up)
'yarn' is not recognized as an internal or external command,
operable program or batch file.
'pnpm' is not recognized as an internal or external command,
operable program or batch file.
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.13.1
npm: 8.1.2
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.0.11-canary.1
react: 17.0.2
react-dom: 17.0.2
What version of Next.js are you using?
12.0.11-canary.1
What version of Node.js are you using?
v16.13.1
What browser are you using?
Unrelated
What operating system are you using?
Windows 11
How are you deploying your application?
Unrelated
Describe the Bug
When a dependency package has "type": "module" in package.json, and uses new Worker(new URL("./worker.js", import.meta.url)) to create a web worker, next build failed with
Module not found: ESM packages (./worker.js) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
While next dev and a barebone webpack configuration all works.
I'm experiencing a similar issue. In my case the error during next build is
> next build
▲ Next.js 14.0.4
- Experiments (use at your own risk):
· esmExternals
Failed to compile.
static/media/worker.1494bc9b.js from Terser
x 'import', and 'export' cannot be used outside of module code
,-[38:1]
[...]
Caused by:
0: failed to parse input file
1: Syntax Error
> Build failed because of webpack errors
Creating an optimized production build . ELIFECYCLE Command failed with exit code 1.
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.11-canary.1
What version of Node.js are you using?
v16.13.1
What browser are you using?
Unrelated
What operating system are you using?
Windows 11
How are you deploying your application?
Unrelated
Describe the Bug
When a dependency package has
"type": "module"
in package.json, and usesnew Worker(new URL("./worker.js", import.meta.url))
to create a web worker,next build
failed withWhile
next dev
and a barebone webpack configuration all works.This issue originated near here:
next.js/packages/next/build/webpack-config.ts
Lines 849 to 851 in 5365f41
dependencyType
is"worker"
in this case.Expected Behavior
next build
successfully create a build.To Reproduce
The
webpack-app
folder is a barebone webpack configuration, which can correctly import and bundle the worker.The text was updated successfully, but these errors were encountered: