File tree Expand file tree Collapse file tree
test/configCases/plugins/add-lazy-runtime-module Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use strict" ;
22
3+ const RuntimeGlobals = require ( "../../../../lib/RuntimeGlobals" ) ;
34const RuntimeModule = require ( "../../../../lib/RuntimeModule" ) ;
45
56// Loaded through `addLazyRuntimeModule`, so it must reach the chunk's runtime.
@@ -12,7 +13,8 @@ class MarkerRuntimeModule extends RuntimeModule {
1213 * @returns {string } runtime code
1314 */
1415 generate ( ) {
15- return 'globalThis.__lazyRuntimeMarker = "attached";' ;
16+ // the portable global: `globalThis` does not exist on the node baseline
17+ return `${ RuntimeGlobals . global } .__lazyRuntimeMarker = "attached";` ;
1618 }
1719}
1820
Original file line number Diff line number Diff line change 11it ( "should attach a runtime module queued through addLazyRuntimeModule" , ( ) => {
2- expect ( globalThis . __lazyRuntimeMarker ) . toBe ( "attached" ) ;
2+ expect ( global . __lazyRuntimeMarker ) . toBe ( "attached" ) ;
33} ) ;
Original file line number Diff line number Diff line change 11"use strict" ;
22
3+ const RuntimeGlobals = require ( "../../../../lib/RuntimeGlobals" ) ;
4+
35const PLUGIN_NAME = "AddLazyRuntimeModuleTestPlugin" ;
46
57/** @type {import("../../../../types").Configuration } */
@@ -10,7 +12,8 @@ module.exports = {
1012 compiler . hooks . thisCompilation . tap ( PLUGIN_NAME , ( compilation ) => {
1113 compilation . hooks . additionalTreeRuntimeRequirements . tap (
1214 PLUGIN_NAME ,
13- ( chunk ) => {
15+ ( chunk , set ) => {
16+ set . add ( RuntimeGlobals . global ) ;
1417 compilation . addLazyRuntimeModule (
1518 chunk ,
1619 ( ) => Promise . resolve ( require ( "./MarkerRuntimeModule" ) ) ,
You can’t perform that action at this time.
0 commit comments