@jsenv/core 28.4.1 → 28.5.0

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.
@@ -277,6 +277,7 @@ window.__supervisor__ = (() => {
277
277
 
278
278
  const getErrorStackWithoutErrorMessage = error => {
279
279
  let stack = error.stack;
280
+ if (!stack) return "";
280
281
  const messageInStack = `${error.name}: ${error.message}`;
281
282
 
282
283
  if (stack.startsWith(messageInStack)) {
package/dist/main.js CHANGED
@@ -10301,15 +10301,24 @@ const jsenvPluginAsJsClassicHtml = ({
10301
10301
  }
10302
10302
 
10303
10303
  if (needsSystemJs) {
10304
- mutations.push(() => {
10305
- const [systemJsReference] = context.referenceUtils.inject({
10304
+ mutations.push(async () => {
10305
+ const systemJsFileContent = readFileSync$1(new URL(systemJsClientFileUrl), {
10306
+ encoding: "utf8"
10307
+ });
10308
+ const [systemJsReference, systemJsUrlInfo] = context.referenceUtils.inject({
10306
10309
  type: "script_src",
10307
10310
  expectedType: "js_classic",
10308
- specifier: systemJsClientFileUrl
10311
+ isInline: true,
10312
+ contentType: "text/javascript",
10313
+ content: systemJsFileContent,
10314
+ specifier: "s.js"
10315
+ });
10316
+ await context.cook(systemJsUrlInfo, {
10317
+ reference: systemJsReference
10309
10318
  });
10310
10319
  injectScriptNodeAsEarlyAsPossible(htmlAst, createHtmlNode({
10311
10320
  tagName: "script",
10312
- src: systemJsReference.generatedSpecifier
10321
+ textContent: systemJsUrlInfo.content
10313
10322
  }), "jsenv:as_js_classic_html");
10314
10323
  });
10315
10324
  }
@@ -10319,7 +10328,7 @@ const jsenvPluginAsJsClassicHtml = ({
10319
10328
  return null;
10320
10329
  }
10321
10330
 
10322
- mutations.forEach(mutation => mutation());
10331
+ await Promise.all(mutations.map(mutation => mutation()));
10323
10332
  return stringifyHtmlAst(htmlAst);
10324
10333
  }
10325
10334
  }
@@ -10556,7 +10565,8 @@ const bundleJsModules = async ({
10556
10565
  const {
10557
10566
  babelHelpersChunk = true,
10558
10567
  include,
10559
- preserveDynamicImport = false
10568
+ preserveDynamicImport = false,
10569
+ strictExports = false
10560
10570
  } = options;
10561
10571
  const {
10562
10572
  jsModuleBundleUrlInfos
@@ -10571,7 +10581,8 @@ const bundleJsModules = async ({
10571
10581
  sourcemaps,
10572
10582
  include,
10573
10583
  babelHelpersChunk,
10574
- preserveDynamicImport
10584
+ preserveDynamicImport,
10585
+ strictExports
10575
10586
  });
10576
10587
  return jsModuleBundleUrlInfos;
10577
10588
  };
@@ -10586,6 +10597,7 @@ const rollupPluginJsenv = ({
10586
10597
  include,
10587
10598
  babelHelpersChunk,
10588
10599
  preserveDynamicImport,
10600
+ strictExports,
10589
10601
  resultRef
10590
10602
  }) => {
10591
10603
  let _rollupEmitFile = () => {
@@ -10636,8 +10648,8 @@ const rollupPluginJsenv = ({
10636
10648
 
10637
10649
  emitChunk({
10638
10650
  id,
10639
- implicitlyLoadedAfterOneOf: previousNonEntryPointModuleId ? [previousNonEntryPointModuleId] : null // preserveSignature: "allow-extension",
10640
-
10651
+ implicitlyLoadedAfterOneOf: previousNonEntryPointModuleId ? [previousNonEntryPointModuleId] : null,
10652
+ preserveSignature: strictExports ? "strict" : jsModuleUrlInfo.dependents.size < 2 ? "allow-extension" : "strict"
10641
10653
  });
10642
10654
  previousNonEntryPointModuleId = id;
10643
10655
  });
@@ -20213,13 +20225,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
20213
20225
  // - happens for "as_js_classic" injecting "s.js"
20214
20226
 
20215
20227
  if (reference.injected) {
20216
- const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({
20217
- type: reference.type,
20218
- expectedType: reference.expectedType,
20219
- expectedSubtype: reference.expectedSubtype,
20220
- parentUrl: buildToRawUrls[reference.parentUrl],
20221
- specifier: reference.specifier,
20222
- injected: true
20228
+ const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({ ...reference,
20229
+ parentUrl: buildToRawUrls[reference.parentUrl]
20223
20230
  });
20224
20231
  await rawGraphKitchen.cook(rawUrlInfo, {
20225
20232
  reference: ref
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "28.4.1",
3
+ "version": "28.5.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -528,12 +528,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
528
528
  // - happens for "as_js_classic" injecting "s.js"
529
529
  if (reference.injected) {
530
530
  const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({
531
- type: reference.type,
532
- expectedType: reference.expectedType,
533
- expectedSubtype: reference.expectedSubtype,
531
+ ...reference,
534
532
  parentUrl: buildToRawUrls[reference.parentUrl],
535
- specifier: reference.specifier,
536
- injected: true,
537
533
  })
538
534
  await rawGraphKitchen.cook(rawUrlInfo, { reference: ref })
539
535
  return rawUrlInfo
@@ -39,6 +39,7 @@ export const bundleJsModules = async ({
39
39
  babelHelpersChunk = true,
40
40
  include,
41
41
  preserveDynamicImport = false,
42
+ strictExports = false,
42
43
  } = options
43
44
  const { jsModuleBundleUrlInfos } = await buildWithRollup({
44
45
  signal,
@@ -54,6 +55,7 @@ export const bundleJsModules = async ({
54
55
  include,
55
56
  babelHelpersChunk,
56
57
  preserveDynamicImport,
58
+ strictExports,
57
59
  })
58
60
  return jsModuleBundleUrlInfos
59
61
  }
@@ -69,6 +71,7 @@ const rollupPluginJsenv = ({
69
71
  include,
70
72
  babelHelpersChunk,
71
73
  preserveDynamicImport,
74
+ strictExports,
72
75
 
73
76
  resultRef,
74
77
  }) => {
@@ -116,7 +119,11 @@ const rollupPluginJsenv = ({
116
119
  implicitlyLoadedAfterOneOf: previousNonEntryPointModuleId
117
120
  ? [previousNonEntryPointModuleId]
118
121
  : null,
119
- // preserveSignature: "allow-extension",
122
+ preserveSignature: strictExports
123
+ ? "strict"
124
+ : jsModuleUrlInfo.dependents.size < 2
125
+ ? "allow-extension"
126
+ : "strict",
120
127
  })
121
128
  previousNonEntryPointModuleId = id
122
129
  })
@@ -237,6 +237,7 @@ window.__supervisor__ = (() => {
237
237
 
238
238
  const getErrorStackWithoutErrorMessage = (error) => {
239
239
  let stack = error.stack
240
+ if (!stack) return ""
240
241
  const messageInStack = `${error.name}: ${error.message}`
241
242
  if (stack.startsWith(messageInStack)) {
242
243
  stack = stack.slice(messageInStack.length)
@@ -5,6 +5,7 @@
5
5
  * - <link rel="modulepreload"> are converted to <link rel="preload">
6
6
  */
7
7
 
8
+ import { readFileSync } from "node:fs"
8
9
  import {
9
10
  parseHtmlString,
10
11
  visitHtmlNodes,
@@ -160,17 +161,28 @@ export const jsenvPluginAsJsClassicHtml = ({
160
161
  }
161
162
  }
162
163
  if (needsSystemJs) {
163
- mutations.push(() => {
164
- const [systemJsReference] = context.referenceUtils.inject({
165
- type: "script_src",
166
- expectedType: "js_classic",
167
- specifier: systemJsClientFileUrl,
164
+ mutations.push(async () => {
165
+ const systemJsFileContent = readFileSync(
166
+ new URL(systemJsClientFileUrl),
167
+ { encoding: "utf8" },
168
+ )
169
+ const [systemJsReference, systemJsUrlInfo] =
170
+ context.referenceUtils.inject({
171
+ type: "script_src",
172
+ expectedType: "js_classic",
173
+ isInline: true,
174
+ contentType: "text/javascript",
175
+ content: systemJsFileContent,
176
+ specifier: "s.js",
177
+ })
178
+ await context.cook(systemJsUrlInfo, {
179
+ reference: systemJsReference,
168
180
  })
169
181
  injectScriptNodeAsEarlyAsPossible(
170
182
  htmlAst,
171
183
  createHtmlNode({
172
184
  tagName: "script",
173
- src: systemJsReference.generatedSpecifier,
185
+ textContent: systemJsUrlInfo.content,
174
186
  }),
175
187
  "jsenv:as_js_classic_html",
176
188
  )
@@ -180,7 +192,7 @@ export const jsenvPluginAsJsClassicHtml = ({
180
192
  if (mutations.length === 0) {
181
193
  return null
182
194
  }
183
- mutations.forEach((mutation) => mutation())
195
+ await Promise.all(mutations.map((mutation) => mutation()))
184
196
  return stringifyHtmlAst(htmlAst)
185
197
  },
186
198
  },