-
-
Notifications
You must be signed in to change notification settings - Fork 781
Closed
Labels
featNew feature or requestNew feature or requestteamThe issue/pr is created by the member of Rspack.The issue/pr is created by the member of Rspack.
Description
What problem does this feature solve?
Align webpack's DefinePlugin for destructuring optimization.
For example:
new DefinePlugin({
"process.env": {
NODE_ENV: '"development"',
PUBLIC_URL: '""',
WDS_SOCKET_HOST: undefined,
WDS_SOCKET_PATH: undefined,
WDS_SOCKET_PORT: undefined,
FAST_REFRESH: "true",
},
})- Input:
const { NODE_ENV } = process.env;
console.log("process.env.NODE_ENV", NODE_ENV);- Output (webpack):
const { NODE_ENV } = ({"NODE_ENV":"development"});
console.log("process.env.NODE_ENV", NODE_ENV);- Output (Rspack):
const { NODE_ENV } = ({ "NODE_ENV":"development","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true });
console.log("process.env.NODE_ENV", NODE_ENV);A minimal demo: https://github.com/chenjiahan/rspack-repro-define-destructuring
What does the proposed API of configuration look like?
Internal optimization, no public API required.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featNew feature or requestNew feature or requestteamThe issue/pr is created by the member of Rspack.The issue/pr is created by the member of Rspack.