-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Description
Bug report
Unsupported import.meta methods to not replaced since v5.99.
Minimal example
- Source code:
function main() {
if (!import.meta.webpackHot) {
return;
}
if (import.meta.webpackHot.status() !== 'idle') {
console.log('idle');
}
}
main();- webpack.config.mjs:
export default {
mode: "development",
devtool: false,
};- Output (5.97):
/******/ (() => { // webpackBootstrap
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
function main() {
if (true) {
return;
}
if (/* unsupported import.meta.webpackHot */ undefined.status() !== 'idle') {
console.log('idle');
}
}
main();
/******/ })()
;- Output (5.99.8):
/******/ (() => { // webpackBootstrap
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
function main() {
if (true) {
return;
}
if (import.meta.webpackHot.status() !== 'idle') {
console.log('idle');
}
}
main();
/******/ })()
;This results in a "Uncaught SyntaxError: Cannot use 'import.meta' outside a module" runtime error
Reproduction
- https://github.com/chenjiahan/webpack-repro-0511
- pnpm i
- pnpm build
Other relevant information
webpack version: 5.99.8
Node.js version: 22
Operating System: macOS
Additional tools: none
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels