@jsenv/core 32.2.1 → 32.2.3

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.
@@ -7467,6 +7467,8 @@ const createUrlInfo = url => {
7467
7467
  // "html", "css", "js_classic", "js_module", "importmap", "json", "webmanifest", ...
7468
7468
  subtype: undefined,
7469
7469
  // "worker", "service_worker", "shared_worker" for js, otherwise undefined
7470
+ typeHint: undefined,
7471
+ subtypeHint: undefined,
7470
7472
  contentType: "",
7471
7473
  // "text/html", "text/css", "text/javascript", "application/json", ...
7472
7474
  url,
@@ -7488,7 +7490,8 @@ const createUrlInfo = url => {
7488
7490
  // maybe move to inlineUrlSite?
7489
7491
 
7490
7492
  timing: {},
7491
- headers: {}
7493
+ headers: {},
7494
+ debug: false
7492
7495
  };
7493
7496
  // Object.preventExtensions(urlInfo) // useful to ensure all properties are declared here
7494
7497
  return urlInfo;
@@ -9067,8 +9070,8 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
9067
9070
  }
9068
9071
  urlInfo.contentType = contentType;
9069
9072
  urlInfo.headers = headers;
9070
- urlInfo.type = type || reference.expectedType || inferUrlInfoType(contentType);
9071
- urlInfo.subtype = subtype || reference.expectedSubtype || "";
9073
+ urlInfo.type = type || reference.expectedType || inferUrlInfoType(urlInfo);
9074
+ urlInfo.subtype = subtype || reference.expectedSubtype || urlInfo.subtypeHint || "";
9072
9075
  // during build urls info are reused and load returns originalUrl/originalContent
9073
9076
  urlInfo.originalUrl = originalUrl || urlInfo.originalUrl;
9074
9077
  if (originalContent !== urlInfo.originalContent) {
@@ -9491,6 +9494,15 @@ const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
9491
9494
  urlInfo.originalContent = context.build ? urlInfo.originalContent === undefined ? reference.content : urlInfo.originalContent : reference.content;
9492
9495
  urlInfo.content = reference.content;
9493
9496
  }
9497
+ if (reference.debug) {
9498
+ urlInfo.debug = true;
9499
+ }
9500
+ if (reference.expectedType) {
9501
+ urlInfo.typeHint = reference.expectedType;
9502
+ }
9503
+ if (reference.expectedSubtype) {
9504
+ urlInfo.subtypeHint = reference.expectedSubtype;
9505
+ }
9494
9506
  };
9495
9507
  const adjustUrlSite = (urlInfo, {
9496
9508
  urlGraph,
@@ -9524,7 +9536,10 @@ const adjustUrlSite = (urlInfo, {
9524
9536
  column
9525
9537
  }, urlInfo);
9526
9538
  };
9527
- const inferUrlInfoType = contentType => {
9539
+ const inferUrlInfoType = urlInfo => {
9540
+ const {
9541
+ contentType
9542
+ } = urlInfo;
9528
9543
  if (contentType === "text/html") {
9529
9544
  return "html";
9530
9545
  }
@@ -9532,6 +9547,7 @@ const inferUrlInfoType = contentType => {
9532
9547
  return "css";
9533
9548
  }
9534
9549
  if (contentType === "text/javascript") {
9550
+ if (urlInfo.typeHint === "js_classic") return "js_classic";
9535
9551
  return "js_module";
9536
9552
  }
9537
9553
  if (contentType === "application/importmap+json") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "32.2.1",
3
+ "version": "32.2.3",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -25,7 +25,7 @@
25
25
  ".": {
26
26
  "import": {
27
27
  "development": "./src/main.js",
28
- "default": "./dist/main.js"
28
+ "default": "./dist/jsenv.js"
29
29
  }
30
30
  },
31
31
  "./*": "./*"
@@ -377,9 +377,9 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
377
377
  }
378
378
  urlInfo.contentType = contentType
379
379
  urlInfo.headers = headers
380
- urlInfo.type =
381
- type || reference.expectedType || inferUrlInfoType(contentType)
382
- urlInfo.subtype = subtype || reference.expectedSubtype || ""
380
+ urlInfo.type = type || reference.expectedType || inferUrlInfoType(urlInfo)
381
+ urlInfo.subtype =
382
+ subtype || reference.expectedSubtype || urlInfo.subtypeHint || ""
383
383
  // during build urls info are reused and load returns originalUrl/originalContent
384
384
  urlInfo.originalUrl = originalUrl || urlInfo.originalUrl
385
385
  if (originalContent !== urlInfo.originalContent) {
@@ -860,6 +860,16 @@ const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
860
860
  : reference.content
861
861
  urlInfo.content = reference.content
862
862
  }
863
+
864
+ if (reference.debug) {
865
+ urlInfo.debug = true
866
+ }
867
+ if (reference.expectedType) {
868
+ urlInfo.typeHint = reference.expectedType
869
+ }
870
+ if (reference.expectedSubtype) {
871
+ urlInfo.subtypeHint = reference.expectedSubtype
872
+ }
863
873
  }
864
874
 
865
875
  const adjustUrlSite = (urlInfo, { urlGraph, url, line, column }) => {
@@ -902,7 +912,8 @@ const adjustUrlSite = (urlInfo, { urlGraph, url, line, column }) => {
902
912
  )
903
913
  }
904
914
 
905
- const inferUrlInfoType = (contentType) => {
915
+ const inferUrlInfoType = (urlInfo) => {
916
+ const { contentType } = urlInfo
906
917
  if (contentType === "text/html") {
907
918
  return "html"
908
919
  }
@@ -910,6 +921,7 @@ const inferUrlInfoType = (contentType) => {
910
921
  return "css"
911
922
  }
912
923
  if (contentType === "text/javascript") {
924
+ if (urlInfo.typeHint === "js_classic") return "js_classic"
913
925
  return "js_module"
914
926
  }
915
927
  if (contentType === "application/importmap+json") {
@@ -260,6 +260,8 @@ const createUrlInfo = (url) => {
260
260
  implicitUrls: new Set(),
261
261
  type: undefined, // "html", "css", "js_classic", "js_module", "importmap", "json", "webmanifest", ...
262
262
  subtype: undefined, // "worker", "service_worker", "shared_worker" for js, otherwise undefined
263
+ typeHint: undefined,
264
+ subtypeHint: undefined,
263
265
  contentType: "", // "text/html", "text/css", "text/javascript", "application/json", ...
264
266
  url,
265
267
  originalUrl: undefined,
@@ -283,6 +285,7 @@ const createUrlInfo = (url) => {
283
285
 
284
286
  timing: {},
285
287
  headers: {},
288
+ debug: false,
286
289
  }
287
290
  // Object.preventExtensions(urlInfo) // useful to ensure all properties are declared here
288
291
  return urlInfo