@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.
@@ -1,6 +1,6 @@
1
1
  import { WebSocketResponse, pickContentType, ServerEvents, jsenvServiceCORS, jsenvAccessControlAllowedHeaders, composeTwoResponses, serveDirectory, jsenvServiceErrorHandler, startServer } from "@jsenv/server";
2
2
  import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/internal/convertFileSystemErrorToResponseProperties.js";
3
- import { lookupPackageDirectory, registerDirectoryLifecycle, urlToRelativeUrl, moveUrl, urlIsInsideOf, ensureWindowsDriveLetter, createDetailedMessage, stringifyUrlSite, generateContentFrame, validateResponseIntegrity, setUrlFilename, getCallerPosition, urlToBasename, urlToExtension, asSpecifierWithoutSearch, asUrlWithoutSearch, injectQueryParamsIntoSpecifier, bufferToEtag, isFileSystemPath, urlToPathname, setUrlBasename, urlToFileSystemPath, writeFileSync, createLogger, URL_META, applyNodeEsmResolution, RUNTIME_COMPAT, normalizeUrl, ANSI, CONTENT_TYPE, errorToHTML, DATA_URL, normalizeImportMap, composeTwoImportMaps, resolveImport, JS_QUOTES, defaultLookupPackageScope, defaultReadPackageJson, readCustomConditionsFromProcessArgs, readEntryStatSync, urlToFilename, ensurePathnameTrailingSlash, compareFileUrls, applyFileSystemMagicResolution, getExtensionsToTry, setUrlExtension, isSpecifierForNodeBuiltin, memoizeByFirstArgument, assertAndNormalizeDirectoryUrl, createTaskLog, readPackageAtOrNull } from "../jsenv_core_packages.js";
3
+ import { lookupPackageDirectory, registerDirectoryLifecycle, urlToRelativeUrl, moveUrl, urlIsInsideOf, ensureWindowsDriveLetter, createDetailedMessage, stringifyUrlSite, generateContentFrame, validateResponseIntegrity, setUrlFilename, getCallerPosition, urlToBasename, urlToExtension, asSpecifierWithoutSearch, asUrlWithoutSearch, injectQueryParamsIntoSpecifier, bufferToEtag, isFileSystemPath, urlToPathname, setUrlBasename, urlToFileSystemPath, writeFileSync, createLogger, URL_META, applyNodeEsmResolution, RUNTIME_COMPAT, normalizeUrl, ANSI, CONTENT_TYPE, errorToHTML, DATA_URL, normalizeImportMap, composeTwoImportMaps, resolveImport, JS_QUOTES, defaultLookupPackageScope, defaultReadPackageJson, readCustomConditionsFromProcessArgs, readEntryStatSync, urlToFilename, ensurePathnameTrailingSlash, compareFileUrls, applyFileSystemMagicResolution, getExtensionsToTry, setUrlExtension, isSpecifierForNodeBuiltin, memoizeByFirstArgument, assertAndNormalizeDirectoryUrl, createTaskLog, readPackageAtOrNull } from "./jsenv_core_packages.js";
4
4
  import { readFileSync, existsSync, readdirSync, lstatSync, realpathSync } from "node:fs";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { generateSourcemapFileUrl, createMagicSource, composeTwoSourcemaps, generateSourcemapDataUrl, SOURCEMAP } from "@jsenv/sourcemap";
@@ -10,7 +10,7 @@ import { jsenvPluginSupervisor } from "@jsenv/plugin-supervisor";
10
10
  import { jsenvPluginTranspilation } from "@jsenv/plugin-transpilation";
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { createRequire } from "node:module";
13
- import "../jsenv_core_node_modules.js";
13
+ import "./jsenv_core_node_modules.js";
14
14
  import "node:process";
15
15
  import "node:os";
16
16
  import "node:tty";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "40.3.3",
3
+ "version": "40.4.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -51,8 +51,7 @@
51
51
  "./src/kitchen/client/inline_content.js",
52
52
  "./dist/client/new_stylesheet/new_stylesheet.js",
53
53
  "./dist/client/inline_content/inline_content.js",
54
- "./dist/client/directory_listing/jsenv_core_node_modules.js",
55
- "./dist/jsenv_core_node_modules.js"
54
+ "./dist/client/directory_listing/jsenv_core_node_modules.js"
56
55
  ],
57
56
  "scripts": {
58
57
  "eslint": "npx eslint .",
@@ -129,4 +128,4 @@
129
128
  "prettier-plugin-organize-imports": "4.1.0",
130
129
  "strip-ansi": "7.1.0"
131
130
  }
132
- }
131
+ }
@@ -62,7 +62,6 @@ export const createBuildSpecifierManager = ({
62
62
  buildUrl = generateSourcemapFileUrl(parentBuildUrl);
63
63
  reference.generatedSpecifier = buildUrl;
64
64
  } else {
65
- const url = reference.generatedUrl;
66
65
  const rawUrlInfo = rawKitchen.graph.getUrlInfo(reference.url);
67
66
  let urlInfo;
68
67
  if (rawUrlInfo) {
@@ -72,6 +71,7 @@ export const createBuildSpecifierManager = ({
72
71
  buildUrlInfo.subtype = reference.expectedSubtype;
73
72
  urlInfo = buildUrlInfo;
74
73
  }
74
+ const url = reference.generatedUrl;
75
75
  buildUrl = buildUrlsGenerator.generate(url, {
76
76
  urlInfo,
77
77
  ownerUrlInfo: reference.ownerUrlInfo,
@@ -249,7 +249,7 @@ export const createBuildSpecifierManager = ({
249
249
  js_classic: undefined, // TODO: add comment to explain who is using this
250
250
  entry_point: undefined,
251
251
  dynamic_import: undefined,
252
- dynamic_import_id: undefined,
252
+ // dynamic_import_id: undefined,
253
253
  };
254
254
  },
255
255
  formatReference: (reference) => {
@@ -1,5 +1,10 @@
1
1
  // import { ANSI } from "@jsenv/humanize";
2
- import { urlIsInsideOf, urlToFilename, urlToRelativeUrl } from "@jsenv/urls";
2
+ import {
3
+ injectQueryParams,
4
+ urlIsInsideOf,
5
+ urlToFilename,
6
+ urlToRelativeUrl,
7
+ } from "@jsenv/urls";
3
8
 
4
9
  export const createBuildUrlsGenerator = ({
5
10
  // logger,
@@ -32,6 +37,20 @@ export const createBuildUrlsGenerator = ({
32
37
  return buildUrlFromMap;
33
38
  }
34
39
  if (urlIsInsideOf(url, buildDirectoryUrl)) {
40
+ if (ownerUrlInfo.searchParams.has("dynamic_import_id")) {
41
+ const ownerDirectoryPath = determineDirectoryPath({
42
+ sourceDirectoryUrl,
43
+ assetsDirectory,
44
+ urlInfo: ownerUrlInfo,
45
+ });
46
+ const buildRelativeUrl = urlToRelativeUrl(url, buildDirectoryUrl);
47
+ let buildUrl = `${buildDirectoryUrl}${ownerDirectoryPath}${buildRelativeUrl}`;
48
+ buildUrl = injectQueryParams(buildUrl, {
49
+ dynamic_import_id: undefined,
50
+ });
51
+ associateBuildUrl(url, buildUrl);
52
+ return buildUrl;
53
+ }
35
54
  associateBuildUrl(url, url);
36
55
  return url;
37
56
  }
@@ -52,7 +71,8 @@ export const createBuildUrlsGenerator = ({
52
71
  } else {
53
72
  directoryPath = urlToRelativeUrl(url, sourceDirectoryUrl);
54
73
  }
55
- const { search } = new URL(url);
74
+ const urlObject = new URL(url);
75
+ const { search } = urlObject;
56
76
  const buildUrl = `${buildDirectoryUrl}${directoryPath}${search}`;
57
77
  associateBuildUrl(url, buildUrl);
58
78
  return buildUrl;
@@ -70,6 +90,7 @@ export const createBuildUrlsGenerator = ({
70
90
  nameSetPerDirectoryMap.set(directoryPath, nameSet);
71
91
  }
72
92
  const urlObject = new URL(url);
93
+ injectQueryParams(urlObject, { dynamic_import_id: undefined });
73
94
  let { search, hash } = urlObject;
74
95
  let urlName = getUrlName(url, urlInfo);
75
96
  let [basename, extension] = splitFileExtension(urlName);
@@ -116,7 +137,7 @@ const determineDirectoryPath = ({
116
137
  sourceDirectoryUrl,
117
138
  assetsDirectory,
118
139
  urlInfo,
119
- ownerUrlInfo,
140
+ ownerUrlInfo = urlInfo.firstReference.ownerUrlInfo,
120
141
  }) => {
121
142
  if (urlInfo.dirnameHint) {
122
143
  return urlInfo.dirnameHint;
@@ -128,13 +149,29 @@ const determineDirectoryPath = ({
128
149
  const parentDirectoryPath = determineDirectoryPath({
129
150
  sourceDirectoryUrl,
130
151
  assetsDirectory,
131
- urlInfo: ownerUrlInfo || urlInfo.firstReference.ownerUrlInfo,
152
+ urlInfo: ownerUrlInfo,
132
153
  });
133
154
  return parentDirectoryPath;
134
155
  }
135
156
  const dynamicImportId = urlInfo.searchParams.get("dynamic_import_id");
136
157
  if (dynamicImportId) {
137
- return `${assetsDirectory}${dynamicImportId}/`;
158
+ const ancestorImportIds = [];
159
+ let ancestorUrlInfo = ownerUrlInfo;
160
+ let currentImportId = dynamicImportId;
161
+ while (ancestorUrlInfo) {
162
+ const ancestorDynamicImportId =
163
+ ancestorUrlInfo.searchParams.get("dynamic_import_id");
164
+ if (!ancestorDynamicImportId) {
165
+ break;
166
+ }
167
+ if (ancestorDynamicImportId !== currentImportId) {
168
+ ancestorImportIds.push(ancestorDynamicImportId);
169
+ currentImportId = ancestorDynamicImportId;
170
+ }
171
+ ancestorUrlInfo = ancestorUrlInfo.firstReference?.ownerUrlInfo;
172
+ }
173
+ const importIdPath = [...ancestorImportIds, dynamicImportId].join("/");
174
+ return `${assetsDirectory}${importIdPath}/`;
138
175
  }
139
176
  if (urlInfo.isEntryPoint && !urlInfo.isDynamicEntryPoint) {
140
177
  return "";