-
-
Notifications
You must be signed in to change notification settings - Fork 744
Description
System Info
System:
OS: macOS 13.2.1
CPU: (20) x64 Apple M1 Ultra
Memory: 354.18 MB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.21.2 - ~/.nvm/versions/node/v14.21.2/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v14.21.2/bin/yarn
npm: 6.14.17 - ~/.nvm/versions/node/v14.21.2/bin/npm
Browsers:
Brave Browser: 107.1.45.118
Chrome: 111.0.5563.64
Safari: 16.3
npmPackages:
@rspack/cli: ^0.1.1 => 0.1.1
@rspack/core: ^0.1.1 => 0.1.1
Details
I am using rspack to compile my lambda handlers / custom server that sits ontop of next.js
As such i want to exclude next.js from being bundled.
This works if i set externals to next: next and require('next')
however, rspack does not externalize something like this:
const NextServer = require("next/dist/server/next-server").default;
I can workaround the issue to some extent with:
const NextServer = __non_webpack_require__("next/dist/server/next-server").default;
const nextConfig = __non_webpack_require__("../../next.config");
const serverConfig = Object.assign({}, defaultConfig, nextConfig);Reasoning:
Externals should allow regex matching expressions like /next/ or /next/$ as well as externals should exclude a string that startsWith a string.
If i make react an external, in webpack we do not need to also include react/jsx-runtime or any other possible files that could be required.
Reproduce link
https://github.com/ScriptedAlchemy/next-rspack-custom-server
Reproduce Steps
- yarn install
- yarn build-server
Look in server.js, currently this server is not hooked up to dev command, so i am purely testing if i can get dist/server.js to emit successfully before i attempt to leverage a bundled server file.