@jsenv/core 40.3.3 → 40.4.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.
@@ -4,18 +4,18 @@ import { jsenvPluginMinification } from "@jsenv/plugin-minification";
4
4
  import { jsenvPluginTranspilation, jsenvPluginJsModuleFallback } from "@jsenv/plugin-transpilation";
5
5
  import { memoryUsage } from "node:process";
6
6
  import { readFileSync, existsSync, readdirSync, lstatSync, realpathSync } from "node:fs";
7
- import { lookupPackageDirectory$1 as lookupPackageDirectory, registerDirectoryLifecycle$1 as registerDirectoryLifecycle, urlToRelativeUrl$1 as urlToRelativeUrl, createDetailedMessage$1 as createDetailedMessage, stringifyUrlSite$1 as stringifyUrlSite, generateContentFrame$1 as generateContentFrame, validateResponseIntegrity$1 as validateResponseIntegrity, urlIsInsideOf$1 as urlIsInsideOf, ensureWindowsDriveLetter$1 as ensureWindowsDriveLetter, setUrlFilename$1 as setUrlFilename, moveUrl$1 as moveUrl, getCallerPosition$1 as getCallerPosition, urlToBasename$1 as urlToBasename, urlToExtension$1 as urlToExtension, asSpecifierWithoutSearch$1 as asSpecifierWithoutSearch, asUrlWithoutSearch$1 as asUrlWithoutSearch, injectQueryParamsIntoSpecifier$1 as injectQueryParamsIntoSpecifier, bufferToEtag$1 as bufferToEtag, isFileSystemPath$1 as isFileSystemPath, urlToPathname$1 as urlToPathname, setUrlBasename$1 as setUrlBasename, urlToFileSystemPath$1 as urlToFileSystemPath, writeFileSync$1 as writeFileSync, createLogger$1 as createLogger, URL_META$1 as URL_META, applyNodeEsmResolution$1 as applyNodeEsmResolution, RUNTIME_COMPAT$1 as RUNTIME_COMPAT, normalizeUrl$1 as normalizeUrl, ANSI$1 as ANSI, CONTENT_TYPE$1 as CONTENT_TYPE, urlToFilename$1 as urlToFilename, DATA_URL$1 as DATA_URL, errorToHTML$1 as errorToHTML, normalizeImportMap$1 as normalizeImportMap, composeTwoImportMaps$1 as composeTwoImportMaps, resolveImport$1 as resolveImport, JS_QUOTES$1 as JS_QUOTES, defaultLookupPackageScope$1 as defaultLookupPackageScope, defaultReadPackageJson$1 as defaultReadPackageJson, readCustomConditionsFromProcessArgs$1 as readCustomConditionsFromProcessArgs, readEntryStatSync$1 as readEntryStatSync, ensurePathnameTrailingSlash$1 as ensurePathnameTrailingSlash, compareFileUrls$1 as compareFileUrls, applyFileSystemMagicResolution$1 as applyFileSystemMagicResolution, getExtensionsToTry$1 as getExtensionsToTry, setUrlExtension$1 as setUrlExtension, isSpecifierForNodeBuiltin$1 as isSpecifierForNodeBuiltin, renderDetails, humanizeDuration, humanizeFileSize, renderTable, renderBigSection, distributePercentages, humanizeMemory, comparePathnames, UNICODE, escapeRegexpSpecialChars, injectQueryParamIntoSpecifierWithoutEncoding, renderUrlOrRelativeUrlFilename, assertAndNormalizeDirectoryUrl$1 as assertAndNormalizeDirectoryUrl, Abort, raceProcessTeardownEvents, startMonitoringCpuUsage, startMonitoringMemoryUsage, createLookupPackageDirectory, readPackageAtOrNull$1 as readPackageAtOrNull, inferRuntimeCompatFromClosestPackage, browserDefaultRuntimeCompat, nodeDefaultRuntimeCompat, clearDirectorySync, createTaskLog$1 as createTaskLog, ensureEmptyDirectory, updateJsonFileSync, createDynamicLog } from "../jsenv_core_packages.js";
7
+ import { lookupPackageDirectory, registerDirectoryLifecycle, urlToRelativeUrl, createDetailedMessage, stringifyUrlSite, generateContentFrame, validateResponseIntegrity, urlIsInsideOf, ensureWindowsDriveLetter, setUrlFilename, moveUrl, getCallerPosition, urlToBasename, urlToExtension, asSpecifierWithoutSearch, asUrlWithoutSearch, injectQueryParamsIntoSpecifier, bufferToEtag, isFileSystemPath, urlToPathname, setUrlBasename, urlToFileSystemPath, writeFileSync, createLogger, URL_META, applyNodeEsmResolution, RUNTIME_COMPAT, normalizeUrl, ANSI, CONTENT_TYPE, urlToFilename, DATA_URL, errorToHTML, normalizeImportMap, composeTwoImportMaps, resolveImport, JS_QUOTES, defaultLookupPackageScope, defaultReadPackageJson, readCustomConditionsFromProcessArgs, readEntryStatSync, ensurePathnameTrailingSlash, compareFileUrls, applyFileSystemMagicResolution, getExtensionsToTry, setUrlExtension, isSpecifierForNodeBuiltin, renderDetails, humanizeDuration, humanizeFileSize, renderTable, renderBigSection, distributePercentages, humanizeMemory, comparePathnames, UNICODE, escapeRegexpSpecialChars, injectQueryParamIntoSpecifierWithoutEncoding, renderUrlOrRelativeUrlFilename, injectQueryParams, assertAndNormalizeDirectoryUrl, Abort, raceProcessTeardownEvents, startMonitoringCpuUsage, startMonitoringMemoryUsage, createLookupPackageDirectory, readPackageAtOrNull, inferRuntimeCompatFromClosestPackage, browserDefaultRuntimeCompat, nodeDefaultRuntimeCompat, clearDirectorySync, createTaskLog, ensureEmptyDirectory, updateJsonFileSync, createDynamicLog } from "./jsenv_core_packages.js";
8
8
  import { pathToFileURL } from "node:url";
9
9
  import { generateSourcemapFileUrl, createMagicSource, composeTwoSourcemaps, generateSourcemapDataUrl, SOURCEMAP } from "@jsenv/sourcemap";
10
10
  import { performance } from "node:perf_hooks";
11
11
  import { jsenvPluginSupervisor } from "@jsenv/plugin-supervisor";
12
12
  import { WebSocketResponse, pickContentType } from "@jsenv/server";
13
13
  import { randomUUID, createHash } from "node:crypto";
14
- import "../jsenv_core_node_modules.js";
14
+ import "./jsenv_core_node_modules.js";
15
15
  import "node:os";
16
16
  import "node:tty";
17
- import "node:util";
18
17
  import "node:path";
18
+ import "node:util";
19
19
 
20
20
  const getDirectoryWatchPatterns = (
21
21
  directoryUrl,
@@ -9020,7 +9020,6 @@ const createBuildSpecifierManager = ({
9020
9020
  buildUrl = generateSourcemapFileUrl(parentBuildUrl);
9021
9021
  reference.generatedSpecifier = buildUrl;
9022
9022
  } else {
9023
- const url = reference.generatedUrl;
9024
9023
  const rawUrlInfo = rawKitchen.graph.getUrlInfo(reference.url);
9025
9024
  let urlInfo;
9026
9025
  if (rawUrlInfo) {
@@ -9030,6 +9029,7 @@ const createBuildSpecifierManager = ({
9030
9029
  buildUrlInfo.subtype = reference.expectedSubtype;
9031
9030
  urlInfo = buildUrlInfo;
9032
9031
  }
9032
+ const url = reference.generatedUrl;
9033
9033
  buildUrl = buildUrlsGenerator.generate(url, {
9034
9034
  urlInfo,
9035
9035
  ownerUrlInfo: reference.ownerUrlInfo,
@@ -9207,7 +9207,7 @@ const createBuildSpecifierManager = ({
9207
9207
  js_classic: undefined, // TODO: add comment to explain who is using this
9208
9208
  entry_point: undefined,
9209
9209
  dynamic_import: undefined,
9210
- dynamic_import_id: undefined,
9210
+ // dynamic_import_id: undefined,
9211
9211
  };
9212
9212
  },
9213
9213
  formatReference: (reference) => {
@@ -10349,6 +10349,20 @@ const createBuildUrlsGenerator = ({
10349
10349
  return buildUrlFromMap;
10350
10350
  }
10351
10351
  if (urlIsInsideOf(url, buildDirectoryUrl)) {
10352
+ if (ownerUrlInfo.searchParams.has("dynamic_import_id")) {
10353
+ const ownerDirectoryPath = determineDirectoryPath({
10354
+ sourceDirectoryUrl,
10355
+ assetsDirectory,
10356
+ urlInfo: ownerUrlInfo,
10357
+ });
10358
+ const buildRelativeUrl = urlToRelativeUrl(url, buildDirectoryUrl);
10359
+ let buildUrl = `${buildDirectoryUrl}${ownerDirectoryPath}${buildRelativeUrl}`;
10360
+ buildUrl = injectQueryParams(buildUrl, {
10361
+ dynamic_import_id: undefined,
10362
+ });
10363
+ associateBuildUrl(url, buildUrl);
10364
+ return buildUrl;
10365
+ }
10352
10366
  associateBuildUrl(url, url);
10353
10367
  return url;
10354
10368
  }
@@ -10369,7 +10383,8 @@ const createBuildUrlsGenerator = ({
10369
10383
  } else {
10370
10384
  directoryPath = urlToRelativeUrl(url, sourceDirectoryUrl);
10371
10385
  }
10372
- const { search } = new URL(url);
10386
+ const urlObject = new URL(url);
10387
+ const { search } = urlObject;
10373
10388
  const buildUrl = `${buildDirectoryUrl}${directoryPath}${search}`;
10374
10389
  associateBuildUrl(url, buildUrl);
10375
10390
  return buildUrl;
@@ -10387,6 +10402,7 @@ const createBuildUrlsGenerator = ({
10387
10402
  nameSetPerDirectoryMap.set(directoryPath, nameSet);
10388
10403
  }
10389
10404
  const urlObject = new URL(url);
10405
+ injectQueryParams(urlObject, { dynamic_import_id: undefined });
10390
10406
  let { search, hash } = urlObject;
10391
10407
  let urlName = getUrlName(url, urlInfo);
10392
10408
  let [basename, extension] = splitFileExtension(urlName);
@@ -10433,7 +10449,7 @@ const determineDirectoryPath = ({
10433
10449
  sourceDirectoryUrl,
10434
10450
  assetsDirectory,
10435
10451
  urlInfo,
10436
- ownerUrlInfo,
10452
+ ownerUrlInfo = urlInfo.firstReference.ownerUrlInfo,
10437
10453
  }) => {
10438
10454
  if (urlInfo.dirnameHint) {
10439
10455
  return urlInfo.dirnameHint;
@@ -10445,13 +10461,29 @@ const determineDirectoryPath = ({
10445
10461
  const parentDirectoryPath = determineDirectoryPath({
10446
10462
  sourceDirectoryUrl,
10447
10463
  assetsDirectory,
10448
- urlInfo: ownerUrlInfo || urlInfo.firstReference.ownerUrlInfo,
10464
+ urlInfo: ownerUrlInfo,
10449
10465
  });
10450
10466
  return parentDirectoryPath;
10451
10467
  }
10452
10468
  const dynamicImportId = urlInfo.searchParams.get("dynamic_import_id");
10453
10469
  if (dynamicImportId) {
10454
- return `${assetsDirectory}${dynamicImportId}/`;
10470
+ const ancestorImportIds = [];
10471
+ let ancestorUrlInfo = ownerUrlInfo;
10472
+ let currentImportId = dynamicImportId;
10473
+ while (ancestorUrlInfo) {
10474
+ const ancestorDynamicImportId =
10475
+ ancestorUrlInfo.searchParams.get("dynamic_import_id");
10476
+ if (!ancestorDynamicImportId) {
10477
+ break;
10478
+ }
10479
+ if (ancestorDynamicImportId !== currentImportId) {
10480
+ ancestorImportIds.push(ancestorDynamicImportId);
10481
+ currentImportId = ancestorDynamicImportId;
10482
+ }
10483
+ ancestorUrlInfo = ancestorUrlInfo.firstReference?.ownerUrlInfo;
10484
+ }
10485
+ const importIdPath = [...ancestorImportIds, dynamicImportId].join("/");
10486
+ return `${assetsDirectory}${importIdPath}/`;
10455
10487
  }
10456
10488
  if (urlInfo.isEntryPoint && !urlInfo.isDynamicEntryPoint) {
10457
10489
  return "";