question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Bug report

Current behavior

Not generated webpack runtime global code in bundled file

Reproduce

Minimal reproducible Github repository

How to reproduce

  1. npm i
  2. node ./addGlobalModule.js
  3. npm run build --workspaces
  4. 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:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
TrickyPicommented, Nov 30, 2021

Ok ! I get it . Many thanks for your reply .

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found