@jsenv/core 27.0.0-alpha.74 → 27.0.0-alpha.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,10 @@ window.__html_supervisor__ = {
32
32
  lastWindowError = e.error
33
33
  }
34
34
  const cleanup = () => {
35
- document.body.removeChild(script)
35
+ // the execution of the script itself can remove script from the page
36
+ if (script.parentNode) {
37
+ script.parentNode.removeChild(script)
38
+ }
36
39
  window.removeEventListener("error", windowErrorCallback)
37
40
  }
38
41
  window.addEventListener("error", windowErrorCallback)
package/dist/main.js CHANGED
@@ -2459,78 +2459,6 @@ const babelPluginMetadataImportMetaScenarios = () => {
2459
2459
  };
2460
2460
  };
2461
2461
 
2462
- const jsenvPluginInjectGlobals = (globals = {}) => {
2463
- if (Object.keys(globals).length === 0) {
2464
- return [];
2465
- }
2466
-
2467
- return {
2468
- name: "jsenv:inject_globals",
2469
- appliesDuring: "*",
2470
- transformUrlContent: {
2471
- html: injectGlobals,
2472
- js_classic: injectGlobals,
2473
- js_module: injectGlobals
2474
- }
2475
- };
2476
- };
2477
- const injectGlobals = (urlInfo, globals) => {
2478
- if (urlInfo.type === "html") {
2479
- return globalInjectorOnHtmlEntryPoint(urlInfo, globals);
2480
- }
2481
-
2482
- if (urlInfo.type === "js_classic" || urlInfo.type === "js_module") {
2483
- return globalsInjectorOnJsEntryPoints(urlInfo, globals);
2484
- }
2485
-
2486
- throw new Error(`cannot inject globals into "${urlInfo.type}"`);
2487
- };
2488
-
2489
- const globalInjectorOnHtmlEntryPoint = async (urlInfo, globals) => {
2490
- if (!urlInfo.data.isEntryPoint) {
2491
- return null;
2492
- } // ideally we would inject an importmap but browser support is too low
2493
- // (even worse for worker/service worker)
2494
- // so for now we inject code into entry points
2495
-
2496
-
2497
- const htmlAst = parseHtmlString(urlInfo.content, {
2498
- storeOriginalPositions: false
2499
- });
2500
- const clientCode = generateClientCodeForGlobals({
2501
- globals,
2502
- isWebWorker: false
2503
- });
2504
- injectScriptAsEarlyAsPossible(htmlAst, createHtmlNode({
2505
- "tagName": "script",
2506
- "textContent": clientCode,
2507
- "injected-by": "jsenv:inject_globals"
2508
- }));
2509
- return stringifyHtmlAst(htmlAst);
2510
- };
2511
-
2512
- const globalsInjectorOnJsEntryPoints = async (urlInfo, globals) => {
2513
- if (!urlInfo.data.isEntryPoint && !urlInfo.data.isWebWorkerEntryPoint) {
2514
- return null;
2515
- }
2516
-
2517
- const clientCode = generateClientCodeForGlobals({
2518
- globals,
2519
- isWebWorker: isWebWorkerUrlInfo(urlInfo)
2520
- });
2521
- const magicSource = createMagicSource(urlInfo.content);
2522
- magicSource.prepend(clientCode);
2523
- return magicSource.toContentAndSourcemap();
2524
- };
2525
-
2526
- const generateClientCodeForGlobals = ({
2527
- isWebWorker = false,
2528
- globals
2529
- }) => {
2530
- const globalName = isWebWorker ? "self" : "window";
2531
- return `Object.assign(${globalName}, ${JSON.stringify(globals, null, " ")});`;
2532
- };
2533
-
2534
2462
  const jsenvPluginCssParcel = () => {
2535
2463
  return {
2536
2464
  name: "jsenv:css_parcel",
@@ -6027,7 +5955,6 @@ const getCorePlugins = ({
6027
5955
  nodeEsmResolution,
6028
5956
  fileSystemMagicResolution,
6029
5957
  directoryReferenceAllowed,
6030
- injectedGlobals,
6031
5958
  transpilation = true,
6032
5959
  minification = false,
6033
5960
  bundling = false,
@@ -6057,7 +5984,7 @@ const getCorePlugins = ({
6057
5984
  rootDirectoryUrl,
6058
5985
  runtimeCompat,
6059
5986
  ...nodeEsmResolution
6060
- }), jsenvPluginUrlResolution(), jsenvPluginUrlVersion(), jsenvPluginInjectGlobals(injectedGlobals), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), jsenvPluginNodeRuntime({
5987
+ }), jsenvPluginUrlResolution(), jsenvPluginUrlVersion(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), jsenvPluginNodeRuntime({
6061
5988
  runtimeCompat
6062
5989
  }), jsenvPluginBundling(bundling), jsenvPluginMinification(minification), jsenvPluginImportMetaHot(), ...(clientAutoreload ? [jsenvPluginAutoreload({
6063
5990
  rootDirectoryUrl,
@@ -8396,11 +8323,10 @@ const startDevServer = async ({
8396
8323
  // (because node cluster won't work)
8397
8324
  devServerAutoreload = typeof process.send !== "function" && !parentPort && !process.env.VSCODE_INSPECTOR_OPTIONS,
8398
8325
  clientFiles = {
8399
- "./**": true,
8400
- "./**/.*/": false,
8326
+ "./src/": true,
8327
+ "./src/**/.*/": false,
8401
8328
  // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
8402
- "./**/dist/": false,
8403
- "./**/node_modules/": false
8329
+ "./src/**/node_modules/": false
8404
8330
  },
8405
8331
  cooldownBetweenFileEvents,
8406
8332
  clientAutoreload = true,
@@ -8417,8 +8343,7 @@ const startDevServer = async ({
8417
8343
  },
8418
8344
  plugins = [],
8419
8345
  urlAnalysis = {},
8420
- htmlSupervisor = true,
8421
- injectedGlobals,
8346
+ htmlSupervisor = false,
8422
8347
  nodeEsmResolution,
8423
8348
  fileSystemMagicResolution,
8424
8349
  transpilation,
@@ -8577,7 +8502,6 @@ const startDevServer = async ({
8577
8502
  runtimeCompat,
8578
8503
  urlAnalysis,
8579
8504
  htmlSupervisor,
8580
- injectedGlobals,
8581
8505
  nodeEsmResolution,
8582
8506
  fileSystemMagicResolution,
8583
8507
  transpilation,
@@ -9135,7 +9059,6 @@ const executePlan = async (plan, {
9135
9059
  scenario,
9136
9060
  sourcemaps,
9137
9061
  plugins,
9138
- injectedGlobals,
9139
9062
  nodeEsmResolution,
9140
9063
  fileSystemMagicResolution,
9141
9064
  transpilation,
@@ -9220,7 +9143,6 @@ const executePlan = async (plan, {
9220
9143
  htmlSupervisor: true,
9221
9144
  nodeEsmResolution,
9222
9145
  fileSystemMagicResolution,
9223
- injectedGlobals,
9224
9146
  transpilation: { ...transpilation,
9225
9147
  getCustomBabelPlugins: ({
9226
9148
  clientRuntimeCompat
@@ -9738,7 +9660,6 @@ const executeTestPlan = async ({
9738
9660
  coverageSkipFull = false,
9739
9661
  sourcemaps = "inline",
9740
9662
  plugins = [],
9741
- injectedGlobals,
9742
9663
  nodeEsmResolution,
9743
9664
  fileSystemMagicResolution,
9744
9665
  writeGeneratedFiles = false,
@@ -9819,7 +9740,6 @@ const executeTestPlan = async ({
9819
9740
  scenario: "test",
9820
9741
  sourcemaps,
9821
9742
  plugins,
9822
- injectedGlobals,
9823
9743
  nodeEsmResolution,
9824
9744
  fileSystemMagicResolution,
9825
9745
  writeGeneratedFiles,
@@ -11899,7 +11819,6 @@ const build = async ({
11899
11819
  nodeEsmResolution,
11900
11820
  fileSystemMagicResolution,
11901
11821
  directoryReferenceAllowed,
11902
- injectedGlobals,
11903
11822
  transpilation = {},
11904
11823
  bundling = true,
11905
11824
  minification = true,
@@ -11908,11 +11827,10 @@ const build = async ({
11908
11827
  // "filename", "search_param"
11909
11828
  lineBreakNormalization = process.platform === "win32",
11910
11829
  clientFiles = {
11911
- "./**": true,
11912
- "./**/.*/": false,
11830
+ "./src/": true,
11831
+ "./src/**/.*/": false,
11913
11832
  // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
11914
- "./dist/": false,
11915
- "./**/node_modules/": false
11833
+ "./src/**/node_modules/": false
11916
11834
  },
11917
11835
  cooldownBetweenFileEvents,
11918
11836
  watch = false,
@@ -12012,7 +11930,6 @@ build ${entryPointKeys.length} entry points`);
12012
11930
  nodeEsmResolution,
12013
11931
  fileSystemMagicResolution,
12014
11932
  directoryReferenceAllowed,
12015
- injectedGlobals,
12016
11933
  transpilation: { ...transpilation,
12017
11934
  babelHelpersAsImport: !useExplicitJsClassicConversion,
12018
11935
  jsModuleAsJsClassic: false
@@ -13307,7 +13224,6 @@ const execute = async ({
13307
13224
  plugins = [],
13308
13225
  nodeEsmResolution,
13309
13226
  fileSystemMagicResolution,
13310
- injectedGlobals,
13311
13227
  transpilation,
13312
13228
  htmlSupervisor = true,
13313
13229
  writeGeneratedFiles = false,
@@ -13361,7 +13277,6 @@ const execute = async ({
13361
13277
  scenario,
13362
13278
  runtimeCompat,
13363
13279
  htmlSupervisor,
13364
- injectedGlobals,
13365
13280
  nodeEsmResolution,
13366
13281
  fileSystemMagicResolution,
13367
13282
  transpilation
@@ -13436,4 +13351,81 @@ const execute = async ({
13436
13351
  }
13437
13352
  };
13438
13353
 
13439
- export { build, chromium, chromiumIsolatedTab, defaultCoverageConfig, execute, executeTestPlan, firefox, firefoxIsolatedTab, injectGlobals, nodeProcess, startBuildServer, startDevServer, webkit, webkitIsolatedTab };
13354
+ const injectGlobals = (urlInfo, globals) => {
13355
+ if (urlInfo.type === "html") {
13356
+ return globalInjectorOnHtml(urlInfo, globals);
13357
+ }
13358
+
13359
+ if (urlInfo.type === "js_classic" || urlInfo.type === "js_module") {
13360
+ return globalsInjectorOnJs(urlInfo, globals);
13361
+ }
13362
+
13363
+ throw new Error(`cannot inject globals into "${urlInfo.type}"`);
13364
+ };
13365
+
13366
+ const globalInjectorOnHtml = async (urlInfo, globals) => {
13367
+ // ideally we would inject an importmap but browser support is too low
13368
+ // (even worse for worker/service worker)
13369
+ // so for now we inject code into entry points
13370
+ const htmlAst = parseHtmlString(urlInfo.content, {
13371
+ storeOriginalPositions: false
13372
+ });
13373
+ const clientCode = generateClientCodeForGlobals({
13374
+ globals,
13375
+ isWebWorker: false
13376
+ });
13377
+ injectScriptAsEarlyAsPossible(htmlAst, createHtmlNode({
13378
+ "tagName": "script",
13379
+ "textContent": clientCode,
13380
+ "injected-by": "jsenv:inject_globals"
13381
+ }));
13382
+ return stringifyHtmlAst(htmlAst);
13383
+ };
13384
+
13385
+ const globalsInjectorOnJs = async (urlInfo, globals) => {
13386
+ const clientCode = generateClientCodeForGlobals({
13387
+ globals,
13388
+ isWebWorker: urlInfo.subtype === "worker" || urlInfo.subtype === "service_worker" || urlInfo.subtype === "shared_worker"
13389
+ });
13390
+ const magicSource = createMagicSource(urlInfo.content);
13391
+ magicSource.prepend(clientCode);
13392
+ return magicSource.toContentAndSourcemap();
13393
+ };
13394
+
13395
+ const generateClientCodeForGlobals = ({
13396
+ isWebWorker = false,
13397
+ globals
13398
+ }) => {
13399
+ const globalName = isWebWorker ? "self" : "window";
13400
+ return `Object.assign(${globalName}, ${JSON.stringify(globals, null, " ")});`;
13401
+ };
13402
+
13403
+ const jsenvPluginInjectGlobals = urlAssociations => {
13404
+ return {
13405
+ name: "jsenv:inject_globals",
13406
+ appliesDuring: "*",
13407
+ transformUrlContent: async urlInfo => {
13408
+ const url = Object.keys(urlAssociations).find(url => {
13409
+ return url === urlInfo.url;
13410
+ });
13411
+
13412
+ if (!url) {
13413
+ return null;
13414
+ }
13415
+
13416
+ let globals = urlAssociations[url];
13417
+
13418
+ if (typeof globals === "function") {
13419
+ globals = await globals();
13420
+ }
13421
+
13422
+ if (Object.keys(globals).length === 0) {
13423
+ return null;
13424
+ }
13425
+
13426
+ return injectGlobals(urlInfo, globals);
13427
+ }
13428
+ };
13429
+ };
13430
+
13431
+ export { build, chromium, chromiumIsolatedTab, defaultCoverageConfig, execute, executeTestPlan, firefox, firefoxIsolatedTab, jsenvPluginInjectGlobals, nodeProcess, startBuildServer, startDevServer, webkit, webkitIsolatedTab };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.0.0-alpha.74",
3
+ "version": "27.0.0-alpha.75",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -68,7 +68,7 @@
68
68
  "@financial-times/polyfill-useragent-normaliser": "2.0.1",
69
69
  "@jsenv/abort": "4.1.2",
70
70
  "@jsenv/babel-plugins": "1.0.3",
71
- "@jsenv/filesystem": "4.0.4",
71
+ "@jsenv/filesystem": "4.0.5",
72
72
  "@jsenv/importmap": "1.2.0",
73
73
  "@jsenv/integrity": "0.0.1",
74
74
  "@jsenv/log": "1.6.3",
@@ -76,9 +76,9 @@
76
76
  "@jsenv/node-esm-resolution": "0.0.10",
77
77
  "@jsenv/server": "12.6.3",
78
78
  "@jsenv/uneval": "1.6.0",
79
- "@jsenv/utils": "1.8.7",
79
+ "@jsenv/utils": "1.8.8",
80
80
  "@jsenv/url-meta": "7.0.0",
81
- "@jsenv/urls": "1.2.1",
81
+ "@jsenv/urls": "1.2.2",
82
82
  "construct-style-sheets-polyfill": "3.1.0",
83
83
  "cssnano": "5.1.7",
84
84
  "cssnano-preset-default": "5.2.7",
@@ -109,7 +109,6 @@ export const build = async ({
109
109
  nodeEsmResolution,
110
110
  fileSystemMagicResolution,
111
111
  directoryReferenceAllowed,
112
- injectedGlobals,
113
112
  transpilation = {},
114
113
  bundling = true,
115
114
  minification = true,
@@ -118,10 +117,9 @@ export const build = async ({
118
117
  lineBreakNormalization = process.platform === "win32",
119
118
 
120
119
  clientFiles = {
121
- "./**": true,
122
- "./**/.*/": false, // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
123
- "./dist/": false,
124
- "./**/node_modules/": false,
120
+ "./src/": true,
121
+ "./src/**/.*/": false, // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
122
+ "./src/**/node_modules/": false,
125
123
  },
126
124
  cooldownBetweenFileEvents,
127
125
  watch = false,
@@ -224,7 +222,6 @@ build ${entryPointKeys.length} entry points`)
224
222
  nodeEsmResolution,
225
223
  fileSystemMagicResolution,
226
224
  directoryReferenceAllowed,
227
- injectedGlobals,
228
225
  transpilation: {
229
226
  ...transpilation,
230
227
  babelHelpersAsImport: !useExplicitJsClassicConversion,
@@ -44,10 +44,9 @@ export const startDevServer = async ({
44
44
  !parentPort &&
45
45
  !process.env.VSCODE_INSPECTOR_OPTIONS,
46
46
  clientFiles = {
47
- "./**": true,
48
- "./**/.*/": false, // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
49
- "./**/dist/": false,
50
- "./**/node_modules/": false,
47
+ "./src/": true,
48
+ "./src/**/.*/": false, // any folder starting with a dot is ignored (includes .git,.jsenv for instance)
49
+ "./src/**/node_modules/": false,
51
50
  },
52
51
  cooldownBetweenFileEvents,
53
52
  clientAutoreload = true,
@@ -65,8 +64,7 @@ export const startDevServer = async ({
65
64
  },
66
65
  plugins = [],
67
66
  urlAnalysis = {},
68
- htmlSupervisor = true,
69
- injectedGlobals,
67
+ htmlSupervisor = false,
70
68
  nodeEsmResolution,
71
69
  fileSystemMagicResolution,
72
70
  transpilation,
@@ -188,7 +186,6 @@ export const startDevServer = async ({
188
186
 
189
187
  urlAnalysis,
190
188
  htmlSupervisor,
191
- injectedGlobals,
192
189
  nodeEsmResolution,
193
190
  fileSystemMagicResolution,
194
191
  transpilation,
@@ -32,7 +32,6 @@ export const execute = async ({
32
32
  plugins = [],
33
33
  nodeEsmResolution,
34
34
  fileSystemMagicResolution,
35
- injectedGlobals,
36
35
  transpilation,
37
36
  htmlSupervisor = true,
38
37
  writeGeneratedFiles = false,
@@ -87,7 +86,6 @@ export const execute = async ({
87
86
  runtimeCompat,
88
87
 
89
88
  htmlSupervisor,
90
- injectedGlobals,
91
89
  nodeEsmResolution,
92
90
  fileSystemMagicResolution,
93
91
  transpilation,
package/src/main.js CHANGED
@@ -24,4 +24,4 @@ export { startBuildServer } from "./build/start_build_server.js"
24
24
 
25
25
  // advanced
26
26
  export { execute } from "./execute/execute.js"
27
- export { injectGlobals } from "./plugins/inject_globals/jsenv_plugin_inject_globals.js"
27
+ export { jsenvPluginInjectGlobals } from "./plugins/inject_globals/jsenv_plugin_inject_globals.js"
@@ -32,7 +32,10 @@ window.__html_supervisor__ = {
32
32
  lastWindowError = e.error
33
33
  }
34
34
  const cleanup = () => {
35
- document.body.removeChild(script)
35
+ // the execution of the script itself can remove script from the page
36
+ if (script.parentNode) {
37
+ script.parentNode.removeChild(script)
38
+ }
36
39
  window.removeEventListener("error", windowErrorCallback)
37
40
  }
38
41
  window.addEventListener("error", windowErrorCallback)
@@ -0,0 +1,57 @@
1
+ import {
2
+ parseHtmlString,
3
+ injectScriptAsEarlyAsPossible,
4
+ createHtmlNode,
5
+ stringifyHtmlAst,
6
+ } from "@jsenv/utils/html_ast/html_ast.js"
7
+ import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
8
+
9
+ export const injectGlobals = (urlInfo, globals) => {
10
+ if (urlInfo.type === "html") {
11
+ return globalInjectorOnHtml(urlInfo, globals)
12
+ }
13
+ if (urlInfo.type === "js_classic" || urlInfo.type === "js_module") {
14
+ return globalsInjectorOnJs(urlInfo, globals)
15
+ }
16
+ throw new Error(`cannot inject globals into "${urlInfo.type}"`)
17
+ }
18
+
19
+ const globalInjectorOnHtml = async (urlInfo, globals) => {
20
+ // ideally we would inject an importmap but browser support is too low
21
+ // (even worse for worker/service worker)
22
+ // so for now we inject code into entry points
23
+ const htmlAst = parseHtmlString(urlInfo.content, {
24
+ storeOriginalPositions: false,
25
+ })
26
+ const clientCode = generateClientCodeForGlobals({
27
+ globals,
28
+ isWebWorker: false,
29
+ })
30
+ injectScriptAsEarlyAsPossible(
31
+ htmlAst,
32
+ createHtmlNode({
33
+ "tagName": "script",
34
+ "textContent": clientCode,
35
+ "injected-by": "jsenv:inject_globals",
36
+ }),
37
+ )
38
+ return stringifyHtmlAst(htmlAst)
39
+ }
40
+
41
+ const globalsInjectorOnJs = async (urlInfo, globals) => {
42
+ const clientCode = generateClientCodeForGlobals({
43
+ globals,
44
+ isWebWorker:
45
+ urlInfo.subtype === "worker" ||
46
+ urlInfo.subtype === "service_worker" ||
47
+ urlInfo.subtype === "shared_worker",
48
+ })
49
+ const magicSource = createMagicSource(urlInfo.content)
50
+ magicSource.prepend(clientCode)
51
+ return magicSource.toContentAndSourcemap()
52
+ }
53
+
54
+ const generateClientCodeForGlobals = ({ isWebWorker = false, globals }) => {
55
+ const globalName = isWebWorker ? "self" : "window"
56
+ return `Object.assign(${globalName}, ${JSON.stringify(globals, null, " ")});`
57
+ }
@@ -1,76 +1,24 @@
1
- import {
2
- parseHtmlString,
3
- injectScriptAsEarlyAsPossible,
4
- createHtmlNode,
5
- stringifyHtmlAst,
6
- } from "@jsenv/utils/html_ast/html_ast.js"
7
- import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
8
- import { isWebWorkerUrlInfo } from "@jsenv/core/src/omega/web_workers.js"
1
+ import { injectGlobals } from "./inject_globals.js"
9
2
 
10
- export const jsenvPluginInjectGlobals = (globals = {}) => {
11
- if (Object.keys(globals).length === 0) {
12
- return []
13
- }
3
+ export const jsenvPluginInjectGlobals = (urlAssociations) => {
14
4
  return {
15
5
  name: "jsenv:inject_globals",
16
6
  appliesDuring: "*",
17
- transformUrlContent: {
18
- html: injectGlobals,
19
- js_classic: injectGlobals,
20
- js_module: injectGlobals,
7
+ transformUrlContent: async (urlInfo) => {
8
+ const url = Object.keys(urlAssociations).find((url) => {
9
+ return url === urlInfo.url
10
+ })
11
+ if (!url) {
12
+ return null
13
+ }
14
+ let globals = urlAssociations[url]
15
+ if (typeof globals === "function") {
16
+ globals = await globals()
17
+ }
18
+ if (Object.keys(globals).length === 0) {
19
+ return null
20
+ }
21
+ return injectGlobals(urlInfo, globals)
21
22
  },
22
23
  }
23
24
  }
24
-
25
- export const injectGlobals = (urlInfo, globals) => {
26
- if (urlInfo.type === "html") {
27
- return globalInjectorOnHtmlEntryPoint(urlInfo, globals)
28
- }
29
- if (urlInfo.type === "js_classic" || urlInfo.type === "js_module") {
30
- return globalsInjectorOnJsEntryPoints(urlInfo, globals)
31
- }
32
- throw new Error(`cannot inject globals into "${urlInfo.type}"`)
33
- }
34
-
35
- const globalInjectorOnHtmlEntryPoint = async (urlInfo, globals) => {
36
- if (!urlInfo.data.isEntryPoint) {
37
- return null
38
- }
39
- // ideally we would inject an importmap but browser support is too low
40
- // (even worse for worker/service worker)
41
- // so for now we inject code into entry points
42
- const htmlAst = parseHtmlString(urlInfo.content, {
43
- storeOriginalPositions: false,
44
- })
45
- const clientCode = generateClientCodeForGlobals({
46
- globals,
47
- isWebWorker: false,
48
- })
49
- injectScriptAsEarlyAsPossible(
50
- htmlAst,
51
- createHtmlNode({
52
- "tagName": "script",
53
- "textContent": clientCode,
54
- "injected-by": "jsenv:inject_globals",
55
- }),
56
- )
57
- return stringifyHtmlAst(htmlAst)
58
- }
59
-
60
- const globalsInjectorOnJsEntryPoints = async (urlInfo, globals) => {
61
- if (!urlInfo.data.isEntryPoint && !urlInfo.data.isWebWorkerEntryPoint) {
62
- return null
63
- }
64
- const clientCode = generateClientCodeForGlobals({
65
- globals,
66
- isWebWorker: isWebWorkerUrlInfo(urlInfo),
67
- })
68
- const magicSource = createMagicSource(urlInfo.content)
69
- magicSource.prepend(clientCode)
70
- return magicSource.toContentAndSourcemap()
71
- }
72
-
73
- const generateClientCodeForGlobals = ({ isWebWorker = false, globals }) => {
74
- const globalName = isWebWorker ? "self" : "window"
75
- return `Object.assign(${globalName}, ${JSON.stringify(globals, null, " ")});`
76
- }
@@ -10,7 +10,6 @@ import { jsenvPluginInline } from "./inline/jsenv_plugin_inline.js"
10
10
  import { jsenvPluginHtmlSupervisor } from "./html_supervisor/jsenv_plugin_html_supervisor.js"
11
11
  import { jsenvPluginCommonJsGlobals } from "./commonjs_globals/jsenv_plugin_commonjs_globals.js"
12
12
  import { jsenvPluginImportMetaScenarios } from "./import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js"
13
- import { jsenvPluginInjectGlobals } from "./inject_globals/jsenv_plugin_inject_globals.js"
14
13
  import { jsenvPluginTranspilation } from "./transpilation/jsenv_plugin_transpilation.js"
15
14
  import { jsenvPluginNodeRuntime } from "./node_runtime/jsenv_plugin_node_runtime.js"
16
15
  // build only
@@ -32,7 +31,6 @@ export const getCorePlugins = ({
32
31
  nodeEsmResolution,
33
32
  fileSystemMagicResolution,
34
33
  directoryReferenceAllowed,
35
- injectedGlobals,
36
34
  transpilation = true,
37
35
  minification = false,
38
36
  bundling = false,
@@ -67,7 +65,6 @@ export const getCorePlugins = ({
67
65
  }),
68
66
  jsenvPluginUrlResolution(),
69
67
  jsenvPluginUrlVersion(),
70
- jsenvPluginInjectGlobals(injectedGlobals),
71
68
  jsenvPluginCommonJsGlobals(),
72
69
  jsenvPluginImportMetaScenarios(),
73
70
 
@@ -57,7 +57,6 @@ export const executePlan = async (
57
57
  scenario,
58
58
  sourcemaps,
59
59
  plugins,
60
- injectedGlobals,
61
60
  nodeEsmResolution,
62
61
  fileSystemMagicResolution,
63
62
  transpilation,
@@ -144,7 +143,6 @@ export const executePlan = async (
144
143
  htmlSupervisor: true,
145
144
  nodeEsmResolution,
146
145
  fileSystemMagicResolution,
147
- injectedGlobals,
148
146
  transpilation: {
149
147
  ...transpilation,
150
148
  getCustomBabelPlugins: ({ clientRuntimeCompat }) => {
@@ -83,7 +83,6 @@ export const executeTestPlan = async ({
83
83
 
84
84
  sourcemaps = "inline",
85
85
  plugins = [],
86
- injectedGlobals,
87
86
  nodeEsmResolution,
88
87
  fileSystemMagicResolution,
89
88
  writeGeneratedFiles = false,
@@ -168,7 +167,6 @@ export const executeTestPlan = async ({
168
167
  scenario: "test",
169
168
  sourcemaps,
170
169
  plugins,
171
- injectedGlobals,
172
170
  nodeEsmResolution,
173
171
  fileSystemMagicResolution,
174
172
  writeGeneratedFiles,