webpack@5.x.x can't detected and polyfilled global variable when imported npm package which package.json's `type` value is "module"
See original GitHub issueBug report
Current behavior
Not generated webpack runtime global code in bundled file
Reproduce
Minimal reproducible Github repository
How to reproduce
- npm i
- node ./addGlobalModule.js
- npm run build --workspaces
- See packages/webpack5/dist/bundle.js
Expected behavior
genreate webpack runtime global code in bundled file
/******/ /* webpack/runtime/global */
/******/ (() => {
/******/ __webpack_require__.g = (function() {
/******/ if (typeof globalThis === 'object') return globalThis;
/******/ try {
/******/ return this || new Function('return this')();
/******/ } catch (e) {
/******/ if (typeof window === 'object') return window;
/******/ }
/******/ })();
/******/ })();
Fixed ?
I guess the reason is no javascript/esm handler in NodeStuffPlugin.js Target code
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Define global variable with webpack - Stack Overflow
There are several way to approach globals: 1. Put your variables in a module. Webpack evaluates modules only once, so your instance remains ......
Read more >infinity-modules-xx - npm
create-react-app is a global command-line utility that you use to create new projects. react-scripts is a development dependency in the generated projects ( ......
Read more >Module Variables - webpack
This section covers all variables available in code compiled with webpack. Modules will have access to certain data from the compilation process through ......
Read more >Infinity-modules-xx NPM | npm.io
In most cases bumping the react-scripts version in package.json and running npm install in this folder should be enough, but it's good to...
Read more >MessagePack: It's like JSON. but fast and small.
open Msgpack_conv type t = { int : int; str : string; } with conv(msgpack) (* serialize *) let bytes = Msgpack.Serialize.serialize_string (msgpack_of_t ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok ! I get it . Many thanks for your reply .
this one https://nodejs.org/api/esm.html#differences-between-es-modules-and-commonjs