@jsenv/core 28.4.2 → 28.5.1

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
@@ -3693,7 +3693,7 @@ const formatters = {
3693
3693
  },
3694
3694
  "css_@import": {
3695
3695
  encode: JSON.stringify,
3696
- code: JSON.stringify
3696
+ decode: JSON.stringify
3697
3697
  },
3698
3698
  // https://github.com/webpack-contrib/css-loader/pull/627/files
3699
3699
  "css_url": {
@@ -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
  }
@@ -20216,13 +20225,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
20216
20225
  // - happens for "as_js_classic" injecting "s.js"
20217
20226
 
20218
20227
  if (reference.injected) {
20219
- const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({
20220
- type: reference.type,
20221
- expectedType: reference.expectedType,
20222
- expectedSubtype: reference.expectedSubtype,
20223
- parentUrl: buildToRawUrls[reference.parentUrl],
20224
- specifier: reference.specifier,
20225
- injected: true
20228
+ const [ref, rawUrlInfo] = rawGraphKitchen.injectReference({ ...reference,
20229
+ parentUrl: buildToRawUrls[reference.parentUrl]
20226
20230
  });
20227
20231
  await rawGraphKitchen.cook(rawUrlInfo, {
20228
20232
  reference: ref
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "28.4.2",
3
+ "version": "28.5.1",
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
@@ -31,7 +31,7 @@ export const urlSpecifierEncoding = {
31
31
  const formatters = {
32
32
  "js_import_export": { encode: JSON.stringify, decode: JSON.parse },
33
33
  "js_url_specifier": { encode: JSON.stringify, decode: JSON.parse },
34
- "css_@import": { encode: JSON.stringify, code: JSON.stringify },
34
+ "css_@import": { encode: JSON.stringify, decode: JSON.stringify },
35
35
  // https://github.com/webpack-contrib/css-loader/pull/627/files
36
36
  "css_url": {
37
37
  encode: (url) => {
@@ -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
  },