-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Closed
Description
Bug report
What is the current behavior?
Module parse failed: Cannot read properties of undefined (reading 'type')
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
TypeError: Cannot read properties of undefined (reading 'type')
at collectDeclaration (/Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/ConstPlugin.js:26:16)
at getHoistedDeclarations (/Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/ConstPlugin.js:110:7)
at /Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/ConstPlugin.js:196:25
at Hook.eval [as call] (eval at create (/Users/chenyulun390/learn/testwebpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:16)
at Hook.CALL_DELEGATE [as _call] (/Users/chenyulun390/learn/testwebpack/node_modules/tapable/lib/Hook.js:14:14)
at JavascriptParser.walkIfStatement (/Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/javascript/JavascriptParser.js:1805:41)
at JavascriptParser.walkStatement (/Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/javascript/JavascriptParser.js:1736:10)
at JavascriptParser.walkStatements (/Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/javascript/JavascriptParser.js:1613:9)
at JavascriptParser.parse (/Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/javascript/JavascriptParser.js:3593:9)
at /Users/chenyulun390/learn/testwebpack/node_modules/webpack/lib/NormalModule.js:1092:26
webpack 5.82.0 compiled with 1 error in 98 msIf the current behavior is a bug, please provide the steps to reproduce.
// index.js
var test = {
a: 1,
b: 2,
c: 3
};
if (process.env.NODE_ENV === 'development') {
var {
a,
...other
} = test;
console.log('development:', other);
} else {
var {
b,
..._other, // error here
} = test;
console.log('production:', _other);
}What is the expected behavior?

Do it need to add a non empty judgment here?
for (const property of node.properties) {
+ if(property.value) {
stack.push(property.value);
+ }
}Other relevant information:
webpack version: 5.82.0
Node.js version: v16.17.0
Operating System: macOS
Additional tools:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels