@jsenv/core 40.5.3 → 40.6.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.
- package/dist/build/build.js +163 -61
- package/dist/build/jsenv_core_packages.js +259 -259
- package/dist/start_build_server/jsenv_core_packages.js +29 -29
- package/dist/start_dev_server/jsenv_core_packages.js +312 -260
- package/dist/start_dev_server/start_dev_server.js +164 -62
- package/package.json +33 -30
- package/src/build/build.js +1 -1
- package/src/dev/start_dev_server.js +2 -2
- package/src/kitchen/errors.js +62 -43
- package/src/kitchen/kitchen.js +45 -3
- package/src/plugins/protocol_file/jsenv_plugin_protocol_file.js +3 -0
- package/src/plugins/resolution_node_esm/jsenv_plugin_node_esm_resolution.js +9 -4
- package/src/plugins/resolution_node_esm/node_esm_resolver.js +43 -10
|
@@ -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, formatError, 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";
|
|
@@ -242,6 +242,12 @@ ${reason}`,
|
|
|
242
242
|
});
|
|
243
243
|
return error;
|
|
244
244
|
}
|
|
245
|
+
if (error.code === "PROTOCOL_NOT_SUPPORTED") {
|
|
246
|
+
const notSupportedError = createFailedToResolveUrlError({
|
|
247
|
+
reason: error.message,
|
|
248
|
+
});
|
|
249
|
+
return notSupportedError;
|
|
250
|
+
}
|
|
245
251
|
return createFailedToResolveUrlError({
|
|
246
252
|
reason: `An error occured during specifier resolution`,
|
|
247
253
|
...detailsFromValueThrown(error),
|
|
@@ -282,7 +288,6 @@ ${reason}`,
|
|
|
282
288
|
});
|
|
283
289
|
return fetchError;
|
|
284
290
|
};
|
|
285
|
-
|
|
286
291
|
if (error.code === "EPERM") {
|
|
287
292
|
return createFailedToFetchUrlContentError({
|
|
288
293
|
code: "NOT_ALLOWED",
|
|
@@ -329,6 +334,9 @@ const createTransformUrlContentError = ({
|
|
|
329
334
|
if (error.code === "MODULE_NOT_FOUND") {
|
|
330
335
|
return error;
|
|
331
336
|
}
|
|
337
|
+
if (error.code === "PROTOCOL_NOT_SUPPORTED") {
|
|
338
|
+
return error;
|
|
339
|
+
}
|
|
332
340
|
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
333
341
|
return error;
|
|
334
342
|
}
|
|
@@ -336,47 +344,8 @@ const createTransformUrlContentError = ({
|
|
|
336
344
|
if (error.isJsenvCookingError) {
|
|
337
345
|
return error;
|
|
338
346
|
}
|
|
347
|
+
const trace = getErrorTrace(error, urlInfo.firstReference);
|
|
339
348
|
const reference = urlInfo.firstReference;
|
|
340
|
-
let trace = reference.trace;
|
|
341
|
-
let line = error.line;
|
|
342
|
-
let column = error.column;
|
|
343
|
-
if (urlInfo.isInline) {
|
|
344
|
-
line = trace.line + line;
|
|
345
|
-
line = line - 1;
|
|
346
|
-
trace = {
|
|
347
|
-
...trace,
|
|
348
|
-
line,
|
|
349
|
-
column,
|
|
350
|
-
codeFrame: generateContentFrame({
|
|
351
|
-
line,
|
|
352
|
-
column,
|
|
353
|
-
content: urlInfo.inlineUrlSite.content,
|
|
354
|
-
}),
|
|
355
|
-
message: stringifyUrlSite({
|
|
356
|
-
url: urlInfo.inlineUrlSite.url,
|
|
357
|
-
line,
|
|
358
|
-
column,
|
|
359
|
-
content: urlInfo.inlineUrlSite.content,
|
|
360
|
-
}),
|
|
361
|
-
};
|
|
362
|
-
} else {
|
|
363
|
-
trace = {
|
|
364
|
-
url: urlInfo.url,
|
|
365
|
-
line,
|
|
366
|
-
column: error.column,
|
|
367
|
-
codeFrame: generateContentFrame({
|
|
368
|
-
line,
|
|
369
|
-
column: error.column,
|
|
370
|
-
content: urlInfo.content,
|
|
371
|
-
}),
|
|
372
|
-
message: stringifyUrlSite({
|
|
373
|
-
url: urlInfo.url,
|
|
374
|
-
line,
|
|
375
|
-
column: error.column,
|
|
376
|
-
content: urlInfo.content,
|
|
377
|
-
}),
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
349
|
const transformError = new Error(
|
|
381
350
|
createDetailedMessage(
|
|
382
351
|
`parse error on "${urlInfo.type}"
|
|
@@ -467,9 +436,55 @@ ${reference.trace.message}`,
|
|
|
467
436
|
return finalizeError;
|
|
468
437
|
};
|
|
469
438
|
|
|
439
|
+
const getErrorTrace = (error, reference) => {
|
|
440
|
+
const urlInfo = reference.urlInfo;
|
|
441
|
+
let trace = reference.trace;
|
|
442
|
+
let line = error.line;
|
|
443
|
+
let column = error.column;
|
|
444
|
+
if (urlInfo.isInline) {
|
|
445
|
+
line = trace.line + line;
|
|
446
|
+
line = line - 1;
|
|
447
|
+
return {
|
|
448
|
+
...trace,
|
|
449
|
+
line,
|
|
450
|
+
column,
|
|
451
|
+
codeFrame: generateContentFrame({
|
|
452
|
+
line,
|
|
453
|
+
column,
|
|
454
|
+
content: urlInfo.inlineUrlSite.content,
|
|
455
|
+
}),
|
|
456
|
+
message: stringifyUrlSite({
|
|
457
|
+
url: urlInfo.inlineUrlSite.url,
|
|
458
|
+
line,
|
|
459
|
+
column,
|
|
460
|
+
content: urlInfo.inlineUrlSite.content,
|
|
461
|
+
}),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
url: urlInfo.url,
|
|
466
|
+
line,
|
|
467
|
+
column: error.column,
|
|
468
|
+
codeFrame: generateContentFrame({
|
|
469
|
+
line,
|
|
470
|
+
column: error.column,
|
|
471
|
+
content: urlInfo.content,
|
|
472
|
+
}),
|
|
473
|
+
message: stringifyUrlSite({
|
|
474
|
+
url: urlInfo.url,
|
|
475
|
+
line,
|
|
476
|
+
column: error.column,
|
|
477
|
+
content: urlInfo.content,
|
|
478
|
+
}),
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
|
|
470
482
|
const detailsFromFirstReference = (reference) => {
|
|
471
483
|
const referenceInProject = getFirstReferenceInProject(reference);
|
|
472
|
-
if (
|
|
484
|
+
if (
|
|
485
|
+
referenceInProject === reference ||
|
|
486
|
+
referenceInProject.type === "http_request"
|
|
487
|
+
) {
|
|
473
488
|
return {};
|
|
474
489
|
}
|
|
475
490
|
return {
|
|
@@ -478,6 +493,9 @@ const detailsFromFirstReference = (reference) => {
|
|
|
478
493
|
};
|
|
479
494
|
const getFirstReferenceInProject = (reference) => {
|
|
480
495
|
const ownerUrlInfo = reference.ownerUrlInfo;
|
|
496
|
+
if (ownerUrlInfo.isRoot) {
|
|
497
|
+
return reference;
|
|
498
|
+
}
|
|
481
499
|
if (
|
|
482
500
|
!ownerUrlInfo.url.includes("/node_modules/") &&
|
|
483
501
|
ownerUrlInfo.packageDirectoryUrl ===
|
|
@@ -485,7 +503,8 @@ const getFirstReferenceInProject = (reference) => {
|
|
|
485
503
|
) {
|
|
486
504
|
return reference;
|
|
487
505
|
}
|
|
488
|
-
|
|
506
|
+
const { firstReference } = ownerUrlInfo;
|
|
507
|
+
return getFirstReferenceInProject(firstReference);
|
|
489
508
|
};
|
|
490
509
|
|
|
491
510
|
const detailsFromPluginController = (pluginController) => {
|
|
@@ -2708,7 +2727,28 @@ const createKitchen = ({
|
|
|
2708
2727
|
|
|
2709
2728
|
ignore,
|
|
2710
2729
|
ignoreProtocol = "remove",
|
|
2711
|
-
supportedProtocols = [
|
|
2730
|
+
supportedProtocols = [
|
|
2731
|
+
"file:",
|
|
2732
|
+
"data:",
|
|
2733
|
+
// eslint-disable-next-line no-script-url
|
|
2734
|
+
"javascript:",
|
|
2735
|
+
"virtual:",
|
|
2736
|
+
"ignore:",
|
|
2737
|
+
"http:",
|
|
2738
|
+
"https:",
|
|
2739
|
+
"chrome:",
|
|
2740
|
+
"chrome-extension:",
|
|
2741
|
+
"chrome-untrusted:",
|
|
2742
|
+
"isolated-app:",
|
|
2743
|
+
],
|
|
2744
|
+
includedProtocols = [
|
|
2745
|
+
"file:",
|
|
2746
|
+
"data:",
|
|
2747
|
+
"virtual:",
|
|
2748
|
+
"ignore:",
|
|
2749
|
+
"http:",
|
|
2750
|
+
"https:",
|
|
2751
|
+
],
|
|
2712
2752
|
|
|
2713
2753
|
// during dev/test clientRuntimeCompat is a single runtime
|
|
2714
2754
|
// during build clientRuntimeCompat is runtimeCompat
|
|
@@ -2728,6 +2768,9 @@ const createKitchen = ({
|
|
|
2728
2768
|
|
|
2729
2769
|
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node");
|
|
2730
2770
|
const packageConditions = [nodeRuntimeEnabled ? "node" : "browser", "import"];
|
|
2771
|
+
if (nodeRuntimeEnabled) {
|
|
2772
|
+
supportedProtocols.push("node:");
|
|
2773
|
+
}
|
|
2731
2774
|
|
|
2732
2775
|
if (packageDependencies === "auto") {
|
|
2733
2776
|
packageDependencies = build && nodeRuntimeEnabled ? "ignore" : "include";
|
|
@@ -2799,8 +2842,11 @@ const createKitchen = ({
|
|
|
2799
2842
|
|
|
2800
2843
|
const isIgnoredByProtocol = (url) => {
|
|
2801
2844
|
const { protocol } = new URL(url);
|
|
2802
|
-
const
|
|
2803
|
-
|
|
2845
|
+
const protocolIsIncluded = includedProtocols.includes(protocol);
|
|
2846
|
+
if (protocolIsIncluded) {
|
|
2847
|
+
return false;
|
|
2848
|
+
}
|
|
2849
|
+
return true;
|
|
2804
2850
|
};
|
|
2805
2851
|
const isIgnoredBecauseInPackageDependencies = (() => {
|
|
2806
2852
|
if (packageDependencies === undefined) {
|
|
@@ -3007,6 +3053,21 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
3007
3053
|
}
|
|
3008
3054
|
reference.generatedUrl = reference.url;
|
|
3009
3055
|
reference.generatedSearchParams = reference.searchParams;
|
|
3056
|
+
if (dev) {
|
|
3057
|
+
let url = reference.url;
|
|
3058
|
+
let { protocol } = new URL(url);
|
|
3059
|
+
if (protocol === "ignore:") {
|
|
3060
|
+
url = url.slice("ignore:".length);
|
|
3061
|
+
protocol = new URL(url, "http://example.com").protocol;
|
|
3062
|
+
}
|
|
3063
|
+
if (!supportedProtocols.includes(protocol)) {
|
|
3064
|
+
const protocolNotSupportedError = new Error(
|
|
3065
|
+
`Unsupported protocol "${protocol}" for url "${url}"`,
|
|
3066
|
+
);
|
|
3067
|
+
protocolNotSupportedError.code = "PROTOCOL_NOT_SUPPORTED";
|
|
3068
|
+
throw protocolNotSupportedError;
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3010
3071
|
return reference;
|
|
3011
3072
|
} catch (error) {
|
|
3012
3073
|
throw createResolveUrlError({
|
|
@@ -5299,13 +5360,32 @@ const createNodeEsmResolver = ({
|
|
|
5299
5360
|
return null; // let it to jsenv_web_resolution
|
|
5300
5361
|
}
|
|
5301
5362
|
const { specifier } = reference;
|
|
5302
|
-
|
|
5303
|
-
|
|
5363
|
+
// specifiers like "#something" have a special meaning for Node.js
|
|
5364
|
+
// but can also be used in .css and .html files for example and should not be modified
|
|
5365
|
+
// by node esm resolution
|
|
5366
|
+
const webResolutionFallback =
|
|
5367
|
+
ownerUrlInfo.type !== "js_module" ||
|
|
5368
|
+
reference.type === "sourcemap_comment";
|
|
5369
|
+
const conditions = buildPackageConditions(specifier, parentUrl, {
|
|
5370
|
+
webResolutionFallback,
|
|
5371
|
+
});
|
|
5372
|
+
let resolution;
|
|
5373
|
+
const nodeEsmResolutionParams = {
|
|
5304
5374
|
conditions,
|
|
5305
5375
|
parentUrl,
|
|
5306
5376
|
specifier,
|
|
5307
5377
|
preservesSymlink,
|
|
5308
|
-
}
|
|
5378
|
+
};
|
|
5379
|
+
if (webResolutionFallback) {
|
|
5380
|
+
try {
|
|
5381
|
+
resolution = applyNodeEsmResolution(nodeEsmResolutionParams);
|
|
5382
|
+
} catch {
|
|
5383
|
+
return null; // delegate to web_resolution plugin
|
|
5384
|
+
}
|
|
5385
|
+
} else {
|
|
5386
|
+
resolution = applyNodeEsmResolution(nodeEsmResolutionParams);
|
|
5387
|
+
}
|
|
5388
|
+
const { url, type, isMain, packageDirectoryUrl } = resolution;
|
|
5309
5389
|
// try to give a more meaningful filename after build
|
|
5310
5390
|
if (isMain && packageDirectoryUrl) {
|
|
5311
5391
|
const basename = urlToBasename(url);
|
|
@@ -5374,12 +5454,26 @@ const createBuildPackageConditions = (
|
|
|
5374
5454
|
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node");
|
|
5375
5455
|
// https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
|
5376
5456
|
const processArgConditions = readCustomConditionsFromProcessArgs();
|
|
5377
|
-
const devResolver = (specifier, importer) => {
|
|
5457
|
+
const devResolver = (specifier, importer, { webResolutionFallback }) => {
|
|
5378
5458
|
if (isBareSpecifier(specifier)) {
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5459
|
+
let url;
|
|
5460
|
+
if (webResolutionFallback) {
|
|
5461
|
+
try {
|
|
5462
|
+
const resolution = applyNodeEsmResolution({
|
|
5463
|
+
specifier,
|
|
5464
|
+
parentUrl: importer,
|
|
5465
|
+
});
|
|
5466
|
+
url = resolution.url;
|
|
5467
|
+
} catch {
|
|
5468
|
+
url = new URL(specifier, importer).href;
|
|
5469
|
+
}
|
|
5470
|
+
} else {
|
|
5471
|
+
const resolution = applyNodeEsmResolution({
|
|
5472
|
+
specifier,
|
|
5473
|
+
parentUrl: importer,
|
|
5474
|
+
});
|
|
5475
|
+
url = resolution.url;
|
|
5476
|
+
}
|
|
5383
5477
|
return !url.includes("/node_modules/");
|
|
5384
5478
|
}
|
|
5385
5479
|
return !importer.includes("/node_modules/");
|
|
@@ -5483,12 +5577,12 @@ const createBuildPackageConditions = (
|
|
|
5483
5577
|
}
|
|
5484
5578
|
|
|
5485
5579
|
const conditionCandidateArray = Object.keys(conditionResolvers);
|
|
5486
|
-
return (specifier, importer) => {
|
|
5580
|
+
return (specifier, importer, params) => {
|
|
5487
5581
|
const conditions = [];
|
|
5488
5582
|
for (const conditionCandidate of conditionCandidateArray) {
|
|
5489
5583
|
const conditionResolver = conditionResolvers[conditionCandidate];
|
|
5490
5584
|
if (typeof conditionResolver === "function") {
|
|
5491
|
-
if (conditionResolver(specifier, importer)) {
|
|
5585
|
+
if (conditionResolver(specifier, importer, params)) {
|
|
5492
5586
|
conditions.push(conditionCandidate);
|
|
5493
5587
|
}
|
|
5494
5588
|
} else if (conditionResolver) {
|
|
@@ -5612,8 +5706,7 @@ const jsenvPluginNodeEsmResolution = (
|
|
|
5612
5706
|
if (config === true) {
|
|
5613
5707
|
resolver = nodeEsmResolverDefault;
|
|
5614
5708
|
} else if (config === false) {
|
|
5615
|
-
|
|
5616
|
-
continue;
|
|
5709
|
+
resolver = null;
|
|
5617
5710
|
} else if (typeof config === "object") {
|
|
5618
5711
|
resolver = resolverFromObject(config, { kitchenContext, urlType });
|
|
5619
5712
|
} else {
|
|
@@ -5628,6 +5721,9 @@ const jsenvPluginNodeEsmResolution = (
|
|
|
5628
5721
|
resolverMap.set(urlType, resolver);
|
|
5629
5722
|
}
|
|
5630
5723
|
}
|
|
5724
|
+
if (!anyTypeResolver) {
|
|
5725
|
+
anyTypeResolver = nodeEsmResolverDefault;
|
|
5726
|
+
}
|
|
5631
5727
|
|
|
5632
5728
|
if (!resolverMap.has("js_module")) {
|
|
5633
5729
|
resolverMap.set("js_module", nodeEsmResolverDefault);
|
|
@@ -5653,8 +5749,11 @@ const jsenvPluginNodeEsmResolution = (
|
|
|
5653
5749
|
}
|
|
5654
5750
|
const urlType = urlTypeFromReference(reference);
|
|
5655
5751
|
const resolver = resolverMap.get(urlType);
|
|
5656
|
-
if (resolver) {
|
|
5657
|
-
|
|
5752
|
+
if (resolver !== undefined) {
|
|
5753
|
+
if (typeof resolver === "function") {
|
|
5754
|
+
return resolver(reference);
|
|
5755
|
+
}
|
|
5756
|
+
return resolver;
|
|
5658
5757
|
}
|
|
5659
5758
|
if (anyTypeResolver) {
|
|
5660
5759
|
return anyTypeResolver(reference);
|
|
@@ -6510,6 +6609,9 @@ const jsenvPluginProtocolFile = ({
|
|
|
6510
6609
|
name: "jsenv:directory_as_json",
|
|
6511
6610
|
appliesDuring: "*",
|
|
6512
6611
|
fetchUrlContent: (urlInfo) => {
|
|
6612
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
6613
|
+
return null;
|
|
6614
|
+
}
|
|
6513
6615
|
const { firstReference } = urlInfo;
|
|
6514
6616
|
let { fsStat } = firstReference;
|
|
6515
6617
|
if (!fsStat) {
|
|
@@ -9361,7 +9463,7 @@ const startDevServer = async ({
|
|
|
9361
9463
|
url: reference.url,
|
|
9362
9464
|
status: 500,
|
|
9363
9465
|
statusText: error.reason,
|
|
9364
|
-
statusMessage: error
|
|
9466
|
+
statusMessage: formatError(error),
|
|
9365
9467
|
headers: {
|
|
9366
9468
|
"cache-control": "no-store",
|
|
9367
9469
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.6.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,18 +34,20 @@
|
|
|
34
34
|
"/src/"
|
|
35
35
|
],
|
|
36
36
|
"volta": {
|
|
37
|
-
"node": "23.11.0"
|
|
37
|
+
"node": "23.11.0",
|
|
38
|
+
"npm": "11.3.0"
|
|
38
39
|
},
|
|
39
|
-
"packageManager": "npm@11.
|
|
40
|
+
"packageManager": "npm@11.3.0",
|
|
40
41
|
"workspaces": [
|
|
41
|
-
"./packages/
|
|
42
|
-
"./packages/
|
|
43
|
-
"./packages/
|
|
44
|
-
"./packages/independent/tooling/*",
|
|
45
|
-
"./packages/independent/shared/*",
|
|
42
|
+
"./packages/back_and_front/*",
|
|
43
|
+
"./packages/backend/*",
|
|
44
|
+
"./packages/frontend/*",
|
|
46
45
|
"./packages/internal/*",
|
|
46
|
+
"./packages/private/*",
|
|
47
|
+
"./packages/private/oto/packages/*",
|
|
47
48
|
"./packages/related/*",
|
|
48
|
-
"./packages/related/cli/*"
|
|
49
|
+
"./packages/related/cli/*",
|
|
50
|
+
"./packages/tooling/*"
|
|
49
51
|
],
|
|
50
52
|
"sideEffects": [
|
|
51
53
|
"./src/kitchen/client/inline_content.js",
|
|
@@ -72,61 +74,62 @@
|
|
|
72
74
|
"test:packages:ci": "CI=1 npm run workspace:test",
|
|
73
75
|
"test:only_dev_server_errors": "node --conditions=dev:jsenv ./tests/dev_server/errors/dev_errors_snapshots.test.mjs",
|
|
74
76
|
"dev": "node --watch --conditions=dev:jsenv ./scripts/dev/dev.mjs",
|
|
75
|
-
"dev:route-inspector": "node --watch --conditions=dev:jsenv ./packages/
|
|
77
|
+
"dev:route-inspector": "node --watch --conditions=dev:jsenv ./packages/backend/server/tests/route_inspector/start_server.js",
|
|
76
78
|
"playwright:install": "npx playwright install-deps && npx playwright install",
|
|
77
79
|
"https:setup": "npx @jsenv/https-local setup",
|
|
78
|
-
"prepublishOnly": "npm run build"
|
|
80
|
+
"prepublishOnly": "npm run build",
|
|
81
|
+
"oto:start": "npm run start -w oto"
|
|
79
82
|
},
|
|
80
83
|
"dependencies": {
|
|
81
84
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
82
|
-
"@jsenv/ast": "6.7.
|
|
83
|
-
"@jsenv/js-module-fallback": "1.4.
|
|
84
|
-
"@jsenv/plugin-bundling": "2.9.
|
|
85
|
+
"@jsenv/ast": "6.7.2",
|
|
86
|
+
"@jsenv/js-module-fallback": "1.4.12",
|
|
87
|
+
"@jsenv/plugin-bundling": "2.9.7",
|
|
85
88
|
"@jsenv/plugin-minification": "1.7.0",
|
|
86
|
-
"@jsenv/plugin-supervisor": "1.
|
|
87
|
-
"@jsenv/plugin-transpilation": "1.5.
|
|
88
|
-
"@jsenv/
|
|
89
|
-
"@jsenv/
|
|
89
|
+
"@jsenv/plugin-supervisor": "1.7.0",
|
|
90
|
+
"@jsenv/plugin-transpilation": "1.5.19",
|
|
91
|
+
"@jsenv/server": "16.1.2",
|
|
92
|
+
"@jsenv/sourcemap": "1.3.8"
|
|
90
93
|
},
|
|
91
94
|
"devDependencies": {
|
|
92
95
|
"@babel/plugin-syntax-decorators": "7.25.9",
|
|
93
96
|
"@babel/plugin-syntax-import-attributes": "7.26.0",
|
|
94
97
|
"@babel/plugin-syntax-optional-chaining-assign": "7.25.9",
|
|
98
|
+
"@jsenv/abort": "workspace:*",
|
|
95
99
|
"@jsenv/assert": "workspace:*",
|
|
96
100
|
"@jsenv/cli": "workspace:*",
|
|
97
101
|
"@jsenv/core": "./",
|
|
98
102
|
"@jsenv/eslint-config-relax": "workspace:*",
|
|
99
103
|
"@jsenv/file-size-impact": "workspace:*",
|
|
104
|
+
"@jsenv/filesystem": "workspace:*",
|
|
100
105
|
"@jsenv/https-local": "workspace:*",
|
|
106
|
+
"@jsenv/humanize": "workspace:*",
|
|
107
|
+
"@jsenv/importmap": "workspace:*",
|
|
108
|
+
"@jsenv/integrity": "workspace:*",
|
|
101
109
|
"@jsenv/md-up": "workspace:*",
|
|
102
110
|
"@jsenv/monorepo": "workspace:*",
|
|
111
|
+
"@jsenv/node-esm-resolution": "workspace:*",
|
|
112
|
+
"@jsenv/os-metrics": "workspace:*",
|
|
103
113
|
"@jsenv/performance-impact": "workspace:*",
|
|
104
114
|
"@jsenv/plugin-as-js-classic": "workspace:*",
|
|
105
115
|
"@jsenv/router": "workspace:*",
|
|
116
|
+
"@jsenv/runtime-compat": "workspace:*",
|
|
106
117
|
"@jsenv/snapshot": "workspace:*",
|
|
107
|
-
"@jsenv/test": "workspace:*",
|
|
108
118
|
"@jsenv/terminal-table": "workspace:*",
|
|
109
|
-
"@jsenv/
|
|
110
|
-
"@jsenv/runtime-compat": "workspace:*",
|
|
119
|
+
"@jsenv/test": "workspace:*",
|
|
111
120
|
"@jsenv/url-meta": "workspace:*",
|
|
112
121
|
"@jsenv/urls": "workspace:*",
|
|
113
122
|
"@jsenv/utils": "workspace:*",
|
|
114
|
-
"@jsenv/abort": "workspace:*",
|
|
115
|
-
"@jsenv/filesystem": "workspace:*",
|
|
116
|
-
"@jsenv/humanize": "workspace:*",
|
|
117
|
-
"@jsenv/importmap": "workspace:*",
|
|
118
|
-
"@jsenv/integrity": "workspace:*",
|
|
119
|
-
"@jsenv/node-esm-resolution": "workspace:*",
|
|
120
123
|
"@playwright/browser-chromium": "1.51.1",
|
|
121
124
|
"@playwright/browser-firefox": "1.51.1",
|
|
122
125
|
"@playwright/browser-webkit": "1.51.1",
|
|
123
126
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
124
127
|
"eslint": "9.24.0",
|
|
125
|
-
"open": "10.1.
|
|
128
|
+
"open": "10.1.1",
|
|
126
129
|
"playwright": "1.51.1",
|
|
130
|
+
"preact": "10.26.5",
|
|
127
131
|
"prettier": "3.5.3",
|
|
128
132
|
"prettier-plugin-organize-imports": "4.1.0",
|
|
129
|
-
"strip-ansi": "7.1.0"
|
|
130
|
-
"preact": "10.26.5"
|
|
133
|
+
"strip-ansi": "7.1.0"
|
|
131
134
|
}
|
|
132
135
|
}
|
package/src/build/build.js
CHANGED
|
@@ -1144,7 +1144,7 @@ const prepareEntryPointBuild = async (
|
|
|
1144
1144
|
// - no plugin putting reference.mustIgnore on https urls
|
|
1145
1145
|
// At this stage it's only about redirecting urls to the build directory
|
|
1146
1146
|
// consequently only a subset or urls are supported
|
|
1147
|
-
|
|
1147
|
+
includedProtocols: ["file:", "data:", "virtual:", "ignore:"],
|
|
1148
1148
|
ignore,
|
|
1149
1149
|
ignoreProtocol: "remove",
|
|
1150
1150
|
build: true,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
lookupPackageDirectory,
|
|
5
5
|
readPackageAtOrNull,
|
|
6
6
|
} from "@jsenv/filesystem";
|
|
7
|
-
import { createLogger, createTaskLog } from "@jsenv/humanize";
|
|
7
|
+
import { createLogger, createTaskLog, formatError } from "@jsenv/humanize";
|
|
8
8
|
import {
|
|
9
9
|
composeTwoResponses,
|
|
10
10
|
jsenvAccessControlAllowedHeaders,
|
|
@@ -605,7 +605,7 @@ export const startDevServer = async ({
|
|
|
605
605
|
url: reference.url,
|
|
606
606
|
status: 500,
|
|
607
607
|
statusText: error.reason,
|
|
608
|
-
statusMessage: error
|
|
608
|
+
statusMessage: formatError(error),
|
|
609
609
|
headers: {
|
|
610
610
|
"cache-control": "no-store",
|
|
611
611
|
},
|
package/src/kitchen/errors.js
CHANGED
|
@@ -53,6 +53,12 @@ ${reason}`,
|
|
|
53
53
|
});
|
|
54
54
|
return error;
|
|
55
55
|
}
|
|
56
|
+
if (error.code === "PROTOCOL_NOT_SUPPORTED") {
|
|
57
|
+
const notSupportedError = createFailedToResolveUrlError({
|
|
58
|
+
reason: error.message,
|
|
59
|
+
});
|
|
60
|
+
return notSupportedError;
|
|
61
|
+
}
|
|
56
62
|
return createFailedToResolveUrlError({
|
|
57
63
|
reason: `An error occured during specifier resolution`,
|
|
58
64
|
...detailsFromValueThrown(error),
|
|
@@ -93,7 +99,6 @@ ${reason}`,
|
|
|
93
99
|
});
|
|
94
100
|
return fetchError;
|
|
95
101
|
};
|
|
96
|
-
|
|
97
102
|
if (error.code === "EPERM") {
|
|
98
103
|
return createFailedToFetchUrlContentError({
|
|
99
104
|
code: "NOT_ALLOWED",
|
|
@@ -140,6 +145,9 @@ export const createTransformUrlContentError = ({
|
|
|
140
145
|
if (error.code === "MODULE_NOT_FOUND") {
|
|
141
146
|
return error;
|
|
142
147
|
}
|
|
148
|
+
if (error.code === "PROTOCOL_NOT_SUPPORTED") {
|
|
149
|
+
return error;
|
|
150
|
+
}
|
|
143
151
|
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
144
152
|
return error;
|
|
145
153
|
}
|
|
@@ -147,47 +155,8 @@ export const createTransformUrlContentError = ({
|
|
|
147
155
|
if (error.isJsenvCookingError) {
|
|
148
156
|
return error;
|
|
149
157
|
}
|
|
158
|
+
const trace = getErrorTrace(error, urlInfo.firstReference);
|
|
150
159
|
const reference = urlInfo.firstReference;
|
|
151
|
-
let trace = reference.trace;
|
|
152
|
-
let line = error.line;
|
|
153
|
-
let column = error.column;
|
|
154
|
-
if (urlInfo.isInline) {
|
|
155
|
-
line = trace.line + line;
|
|
156
|
-
line = line - 1;
|
|
157
|
-
trace = {
|
|
158
|
-
...trace,
|
|
159
|
-
line,
|
|
160
|
-
column,
|
|
161
|
-
codeFrame: generateContentFrame({
|
|
162
|
-
line,
|
|
163
|
-
column,
|
|
164
|
-
content: urlInfo.inlineUrlSite.content,
|
|
165
|
-
}),
|
|
166
|
-
message: stringifyUrlSite({
|
|
167
|
-
url: urlInfo.inlineUrlSite.url,
|
|
168
|
-
line,
|
|
169
|
-
column,
|
|
170
|
-
content: urlInfo.inlineUrlSite.content,
|
|
171
|
-
}),
|
|
172
|
-
};
|
|
173
|
-
} else {
|
|
174
|
-
trace = {
|
|
175
|
-
url: urlInfo.url,
|
|
176
|
-
line,
|
|
177
|
-
column: error.column,
|
|
178
|
-
codeFrame: generateContentFrame({
|
|
179
|
-
line,
|
|
180
|
-
column: error.column,
|
|
181
|
-
content: urlInfo.content,
|
|
182
|
-
}),
|
|
183
|
-
message: stringifyUrlSite({
|
|
184
|
-
url: urlInfo.url,
|
|
185
|
-
line,
|
|
186
|
-
column: error.column,
|
|
187
|
-
content: urlInfo.content,
|
|
188
|
-
}),
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
160
|
const transformError = new Error(
|
|
192
161
|
createDetailedMessage(
|
|
193
162
|
`parse error on "${urlInfo.type}"
|
|
@@ -278,9 +247,55 @@ ${reference.trace.message}`,
|
|
|
278
247
|
return finalizeError;
|
|
279
248
|
};
|
|
280
249
|
|
|
250
|
+
const getErrorTrace = (error, reference) => {
|
|
251
|
+
const urlInfo = reference.urlInfo;
|
|
252
|
+
let trace = reference.trace;
|
|
253
|
+
let line = error.line;
|
|
254
|
+
let column = error.column;
|
|
255
|
+
if (urlInfo.isInline) {
|
|
256
|
+
line = trace.line + line;
|
|
257
|
+
line = line - 1;
|
|
258
|
+
return {
|
|
259
|
+
...trace,
|
|
260
|
+
line,
|
|
261
|
+
column,
|
|
262
|
+
codeFrame: generateContentFrame({
|
|
263
|
+
line,
|
|
264
|
+
column,
|
|
265
|
+
content: urlInfo.inlineUrlSite.content,
|
|
266
|
+
}),
|
|
267
|
+
message: stringifyUrlSite({
|
|
268
|
+
url: urlInfo.inlineUrlSite.url,
|
|
269
|
+
line,
|
|
270
|
+
column,
|
|
271
|
+
content: urlInfo.inlineUrlSite.content,
|
|
272
|
+
}),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
url: urlInfo.url,
|
|
277
|
+
line,
|
|
278
|
+
column: error.column,
|
|
279
|
+
codeFrame: generateContentFrame({
|
|
280
|
+
line,
|
|
281
|
+
column: error.column,
|
|
282
|
+
content: urlInfo.content,
|
|
283
|
+
}),
|
|
284
|
+
message: stringifyUrlSite({
|
|
285
|
+
url: urlInfo.url,
|
|
286
|
+
line,
|
|
287
|
+
column: error.column,
|
|
288
|
+
content: urlInfo.content,
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
|
|
281
293
|
const detailsFromFirstReference = (reference) => {
|
|
282
294
|
const referenceInProject = getFirstReferenceInProject(reference);
|
|
283
|
-
if (
|
|
295
|
+
if (
|
|
296
|
+
referenceInProject === reference ||
|
|
297
|
+
referenceInProject.type === "http_request"
|
|
298
|
+
) {
|
|
284
299
|
return {};
|
|
285
300
|
}
|
|
286
301
|
return {
|
|
@@ -289,6 +304,9 @@ const detailsFromFirstReference = (reference) => {
|
|
|
289
304
|
};
|
|
290
305
|
const getFirstReferenceInProject = (reference) => {
|
|
291
306
|
const ownerUrlInfo = reference.ownerUrlInfo;
|
|
307
|
+
if (ownerUrlInfo.isRoot) {
|
|
308
|
+
return reference;
|
|
309
|
+
}
|
|
292
310
|
if (
|
|
293
311
|
!ownerUrlInfo.url.includes("/node_modules/") &&
|
|
294
312
|
ownerUrlInfo.packageDirectoryUrl ===
|
|
@@ -296,7 +314,8 @@ const getFirstReferenceInProject = (reference) => {
|
|
|
296
314
|
) {
|
|
297
315
|
return reference;
|
|
298
316
|
}
|
|
299
|
-
|
|
317
|
+
const { firstReference } = ownerUrlInfo;
|
|
318
|
+
return getFirstReferenceInProject(firstReference);
|
|
300
319
|
};
|
|
301
320
|
|
|
302
321
|
const detailsFromPluginController = (pluginController) => {
|