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
When using the edge runtime, Node APIs are implicitly bundled into edge routes (e.g., generateMetadata or middleware) even though they should be excluded or aliased. For example, a package (@intlayer/config/built which includes esbuild) should never be bundled in the edge runtime, yet it is.
Error :
npm run dev:turbo
> [email protected] dev:turbo > next dev --turbopack
▲ Next.js 15.3.0 (Turbopack)
- Local: http://localhost:3000
- Network: http://192.168.1.37:3000
✓ Starting...
⨯ ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.
Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders
✓ Compiled middleware in 402ms
✓ Ready in 9.5s
⨯ Error [TypeError]: Cannot read properties of undefined (reading 'node')
at [project]/packages/@intlayer/config/dist/esm/loadExternalFile.mjs [middleware-edge] (ecmascript) (packages/@intlayer/config/src/loadExternalFile.ts:2:63)
1 | import { runInNewContext } from 'vm';
> 2 | import { type BuildOptions, buildSync, type BuildResult } from 'esbuild';
| ^
3 | import { getSandBoxContext } from './getSandboxContext';
4 | import { ESMxCJSRequire } from './utils/ESMxCJSRequire';
5 | import { logger } from './logger';
⚠ ./packages/@intlayer/config/dist/esm/configFile/buildConfigurationFields.mjs:166:57
esbuild, fs, path etc are imported via the @intlayer/config/built package
Aliasing the package via a custom withIntlayer plugin seems to have no effect in the edge runtime with turbopack.
As a result, dev and built fail using turbopack because the package references Node APIs not supported in the Edge environment.
Current behavior:
A runtime error is thrown in routes that runs on the Edge runtime.
This happens despite the package being aliased away via a custom plugin (withIntlayer) or excluded using the serverExternalPackages option in next.config.js.
Expected behavior:
The aliasing or externalization should prevent the package from being bundled into the edge runtime, similar to how it behaves with webpack
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://github.com/aymericzip/intlayer-next-15-template
To Reproduce
Current vs. Expected behavior
Bug description
When using the edge runtime, Node APIs are implicitly bundled into edge routes (e.g.,
generateMetadata
ormiddleware
) even though they should be excluded or aliased. For example, a package (@intlayer/config/built
which includesesbuild
) should never be bundled in the edge runtime, yet it is.Error :
withIntlayer
plugin seems to have no effect in the edge runtime with turbopack.serverExternalPackages
also has no effect.As a result, dev and built fail using turbopack because the package references Node APIs not supported in the Edge environment.
Current behavior:
A runtime error is thrown in routes that runs on the Edge runtime.
This happens despite the package being aliased away via a custom plugin (
withIntlayer
) or excluded using theserverExternalPackages
option innext.config.js
.Expected behavior:
The aliasing or externalization should prevent the package from being bundled into the edge runtime, similar to how it behaves with webpack
Provide environment information
Operating System: Platform: macos Arch: x64 Binaries: Node: 20.11.0 npm: 10.2.4 pnpm: 9.14.3 Relevant Packages: next: <14.2.28 to 15.3.0, react: 18.3.1 react-dom: 18.3.1 typescript: 5.7.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Runtime, Turbopack, Middleware, Metadata
Which stage(s) are affected? (Select all that apply)
next dev (local)
next build (local)
Additional context
Related issue:
aymericzip/intlayer#109
Started since next 14.x.x
Reproducible example repo:
https://github.com/aymericzip/intlayer-next-14-template
The text was updated successfully, but these errors were encountered: