@jsenv/core 32.0.1 → 32.1.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/js/v8_coverage.js +33 -22
- package/dist/main.js +182 -180
- package/package.json +7 -7
- package/src/build/build.js +30 -23
- package/src/dev/file_service.js +4 -10
- package/src/dev/start_dev_server.js +14 -4
- package/src/kitchen/errors.js +9 -0
- package/src/kitchen/kitchen.js +3 -4
- package/src/kitchen/url_graph/url_info_transformations.js +16 -6
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +65 -58
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_library.js +1 -1
- package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +0 -9
- package/src/test/execute_test_plan.js +1 -1
- package/src/jsenv_internal_directory.js +0 -18
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
2
2
|
import { chmod, stat, lstat, readdir, promises, unlink, openSync, closeSync, rmdir, readFile as readFile$1, readFileSync as readFileSync$1, watch, readdirSync, statSync, writeFile as writeFile$1, writeFileSync as writeFileSync$1, mkdirSync, createReadStream, existsSync, realpathSync } from "node:fs";
|
|
3
3
|
import crypto, { createHash } from "node:crypto";
|
|
4
|
-
import { dirname, extname
|
|
4
|
+
import { dirname, extname } from "node:path";
|
|
5
5
|
import { URL_META, filterV8Coverage } from "./js/v8_coverage.js";
|
|
6
6
|
import process$1, { memoryUsage } from "node:process";
|
|
7
7
|
import os, { networkInterfaces } from "node:os";
|
|
@@ -6965,6 +6965,38 @@ const generateAccessControlHeaders = ({
|
|
|
6965
6965
|
};
|
|
6966
6966
|
};
|
|
6967
6967
|
|
|
6968
|
+
const lookupPackageDirectory = currentUrl => {
|
|
6969
|
+
if (currentUrl === "file:///") {
|
|
6970
|
+
return null;
|
|
6971
|
+
}
|
|
6972
|
+
const packageJsonFileUrl = `${currentUrl}package.json`;
|
|
6973
|
+
if (existsSync(new URL(packageJsonFileUrl))) {
|
|
6974
|
+
return currentUrl;
|
|
6975
|
+
}
|
|
6976
|
+
return lookupPackageDirectory(getParentUrl$1(currentUrl));
|
|
6977
|
+
};
|
|
6978
|
+
const getParentUrl$1 = url => {
|
|
6979
|
+
if (url.startsWith("file://")) {
|
|
6980
|
+
// With node.js new URL('../', 'file:///C:/').href
|
|
6981
|
+
// returns "file:///C:/" instead of "file:///"
|
|
6982
|
+
const resource = url.slice("file://".length);
|
|
6983
|
+
const slashLastIndex = resource.lastIndexOf("/");
|
|
6984
|
+
if (slashLastIndex === -1) {
|
|
6985
|
+
return url;
|
|
6986
|
+
}
|
|
6987
|
+
const lastCharIndex = resource.length - 1;
|
|
6988
|
+
if (slashLastIndex === lastCharIndex) {
|
|
6989
|
+
const slashBeforeLastIndex = resource.lastIndexOf("/", slashLastIndex - 1);
|
|
6990
|
+
if (slashBeforeLastIndex === -1) {
|
|
6991
|
+
return url;
|
|
6992
|
+
}
|
|
6993
|
+
return `file://${resource.slice(0, slashBeforeLastIndex + 1)}`;
|
|
6994
|
+
}
|
|
6995
|
+
return `file://${resource.slice(0, slashLastIndex + 1)}`;
|
|
6996
|
+
}
|
|
6997
|
+
return new URL(url.endsWith("/") ? "../" : "./", url).href;
|
|
6998
|
+
};
|
|
6999
|
+
|
|
6968
7000
|
const createServerEventsDispatcher = () => {
|
|
6969
7001
|
const clients = [];
|
|
6970
7002
|
const MAX_CLIENTS = 100;
|
|
@@ -7058,52 +7090,6 @@ const createServerEventsDispatcher = () => {
|
|
|
7058
7090
|
};
|
|
7059
7091
|
};
|
|
7060
7092
|
|
|
7061
|
-
const lookupPackageDirectory = currentUrl => {
|
|
7062
|
-
if (currentUrl === "file:///") {
|
|
7063
|
-
return null;
|
|
7064
|
-
}
|
|
7065
|
-
const packageJsonFileUrl = `${currentUrl}package.json`;
|
|
7066
|
-
if (existsSync(new URL(packageJsonFileUrl))) {
|
|
7067
|
-
return currentUrl;
|
|
7068
|
-
}
|
|
7069
|
-
return lookupPackageDirectory(getParentUrl$1(currentUrl));
|
|
7070
|
-
};
|
|
7071
|
-
const getParentUrl$1 = url => {
|
|
7072
|
-
if (url.startsWith("file://")) {
|
|
7073
|
-
// With node.js new URL('../', 'file:///C:/').href
|
|
7074
|
-
// returns "file:///C:/" instead of "file:///"
|
|
7075
|
-
const resource = url.slice("file://".length);
|
|
7076
|
-
const slashLastIndex = resource.lastIndexOf("/");
|
|
7077
|
-
if (slashLastIndex === -1) {
|
|
7078
|
-
return url;
|
|
7079
|
-
}
|
|
7080
|
-
const lastCharIndex = resource.length - 1;
|
|
7081
|
-
if (slashLastIndex === lastCharIndex) {
|
|
7082
|
-
const slashBeforeLastIndex = resource.lastIndexOf("/", slashLastIndex - 1);
|
|
7083
|
-
if (slashBeforeLastIndex === -1) {
|
|
7084
|
-
return url;
|
|
7085
|
-
}
|
|
7086
|
-
return `file://${resource.slice(0, slashBeforeLastIndex + 1)}`;
|
|
7087
|
-
}
|
|
7088
|
-
return `file://${resource.slice(0, slashLastIndex + 1)}`;
|
|
7089
|
-
}
|
|
7090
|
-
return new URL(url.endsWith("/") ? "../" : "./", url).href;
|
|
7091
|
-
};
|
|
7092
|
-
|
|
7093
|
-
const determineJsenvInternalDirectoryUrl = currentUrl => {
|
|
7094
|
-
const packageDirectoryUrl = lookupPackageDirectory(currentUrl);
|
|
7095
|
-
if (packageDirectoryUrl) {
|
|
7096
|
-
return `${packageDirectoryUrl}.jsenv/${getDirectoryName(packageDirectoryUrl)}/`;
|
|
7097
|
-
}
|
|
7098
|
-
return `${currentUrl}.jsenv/`;
|
|
7099
|
-
};
|
|
7100
|
-
const getDirectoryName = directoryUrl => {
|
|
7101
|
-
const {
|
|
7102
|
-
pathname
|
|
7103
|
-
} = new URL(directoryUrl);
|
|
7104
|
-
return basename(pathname);
|
|
7105
|
-
};
|
|
7106
|
-
|
|
7107
7093
|
const watchSourceFiles = (sourceDirectoryUrl, callback, {
|
|
7108
7094
|
sourceFileConfig = {},
|
|
7109
7095
|
keepProcessAlive,
|
|
@@ -7884,18 +7870,19 @@ const createUrlInfoTransformer = ({
|
|
|
7884
7870
|
generatedUrlObject.searchParams.delete("as_js_classic_library");
|
|
7885
7871
|
const urlForSourcemap = generatedUrlObject.href;
|
|
7886
7872
|
urlInfo.sourcemapGeneratedUrl = generateSourcemapFileUrl(urlForSourcemap);
|
|
7887
|
-
const [sourcemapReference, sourcemapUrlInfo] = injectSourcemapPlaceholder({
|
|
7888
|
-
urlInfo,
|
|
7889
|
-
specifier: urlInfo.sourcemapGeneratedUrl
|
|
7890
|
-
});
|
|
7891
|
-
urlInfo.sourcemapReference = sourcemapReference;
|
|
7892
|
-
sourcemapUrlInfo.isInline = sourcemaps === "inline";
|
|
7893
7873
|
|
|
7894
7874
|
// already loaded during "load" hook (happens during build)
|
|
7895
7875
|
if (urlInfo.sourcemap) {
|
|
7876
|
+
const [sourcemapReference, sourcemapUrlInfo] = injectSourcemapPlaceholder({
|
|
7877
|
+
urlInfo,
|
|
7878
|
+
specifier: urlInfo.sourcemapGeneratedUrl
|
|
7879
|
+
});
|
|
7880
|
+
sourcemapUrlInfo.isInline = sourcemaps === "inline";
|
|
7881
|
+
urlInfo.sourcemapReference = sourcemapReference;
|
|
7896
7882
|
urlInfo.sourcemap = normalizeSourcemap(urlInfo, urlInfo.sourcemap);
|
|
7897
7883
|
return;
|
|
7898
7884
|
}
|
|
7885
|
+
|
|
7899
7886
|
// check for existing sourcemap for this content
|
|
7900
7887
|
const sourcemapFound = SOURCEMAP.readComment({
|
|
7901
7888
|
contentType: urlInfo.contentType,
|
|
@@ -7919,6 +7906,7 @@ const createUrlInfoTransformer = ({
|
|
|
7919
7906
|
await context.cook(sourcemapUrlInfo, {
|
|
7920
7907
|
reference: sourcemapReference
|
|
7921
7908
|
});
|
|
7909
|
+
sourcemapUrlInfo.isInline = sourcemaps === "inline";
|
|
7922
7910
|
const sourcemapRaw = JSON.parse(sourcemapUrlInfo.content);
|
|
7923
7911
|
const sourcemap = normalizeSourcemap(urlInfo, sourcemapRaw);
|
|
7924
7912
|
urlInfo.sourcemap = sourcemap;
|
|
@@ -7926,6 +7914,12 @@ const createUrlInfoTransformer = ({
|
|
|
7926
7914
|
logger.error(`Error while handling existing sourcemap: ${e.message}`);
|
|
7927
7915
|
return;
|
|
7928
7916
|
}
|
|
7917
|
+
} else {
|
|
7918
|
+
const [, sourcemapUrlInfo] = injectSourcemapPlaceholder({
|
|
7919
|
+
urlInfo,
|
|
7920
|
+
specifier: urlInfo.sourcemapGeneratedUrl
|
|
7921
|
+
});
|
|
7922
|
+
sourcemapUrlInfo.isInline = sourcemaps === "inline";
|
|
7929
7923
|
}
|
|
7930
7924
|
};
|
|
7931
7925
|
const applyIntermediateTransformations = (urlInfo, transformations) => {
|
|
@@ -8389,6 +8383,12 @@ const createResolveUrlError = ({
|
|
|
8389
8383
|
reason: `no plugin has handled the specifier during "resolveUrl" hook`
|
|
8390
8384
|
});
|
|
8391
8385
|
}
|
|
8386
|
+
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
8387
|
+
error.message = createDetailedMessage$1(error.message, {
|
|
8388
|
+
"reference trace": reference.trace.message
|
|
8389
|
+
});
|
|
8390
|
+
return error;
|
|
8391
|
+
}
|
|
8392
8392
|
return createFailedToResolveUrlError({
|
|
8393
8393
|
reason: `An error occured during specifier resolution`,
|
|
8394
8394
|
...detailsFromValueThrown(error)
|
|
@@ -8467,6 +8467,9 @@ const createTransformUrlContentError = ({
|
|
|
8467
8467
|
urlInfo,
|
|
8468
8468
|
error
|
|
8469
8469
|
}) => {
|
|
8470
|
+
if (error.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
8471
|
+
return error;
|
|
8472
|
+
}
|
|
8470
8473
|
const createFailedToTransformError = ({
|
|
8471
8474
|
code = error.code || "TRANSFORM_URL_CONTENT_ERROR",
|
|
8472
8475
|
reason,
|
|
@@ -8751,7 +8754,6 @@ const createKitchen = ({
|
|
|
8751
8754
|
signal,
|
|
8752
8755
|
logLevel,
|
|
8753
8756
|
rootDirectoryUrl,
|
|
8754
|
-
jsenvInternalDirectoryUrl,
|
|
8755
8757
|
urlGraph,
|
|
8756
8758
|
dev = false,
|
|
8757
8759
|
build = false,
|
|
@@ -8767,7 +8769,6 @@ const createKitchen = ({
|
|
|
8767
8769
|
sourcemapsSourcesProtocol,
|
|
8768
8770
|
sourcemapsSourcesContent,
|
|
8769
8771
|
sourcemapsSourcesRelative,
|
|
8770
|
-
writeGeneratedFiles,
|
|
8771
8772
|
outDirectoryUrl
|
|
8772
8773
|
}) => {
|
|
8773
8774
|
const logger = createLogger({
|
|
@@ -8777,7 +8778,6 @@ const createKitchen = ({
|
|
|
8777
8778
|
signal,
|
|
8778
8779
|
logger,
|
|
8779
8780
|
rootDirectoryUrl,
|
|
8780
|
-
jsenvInternalDirectoryUrl,
|
|
8781
8781
|
urlGraph,
|
|
8782
8782
|
dev,
|
|
8783
8783
|
build,
|
|
@@ -8837,6 +8837,7 @@ const createKitchen = ({
|
|
|
8837
8837
|
assert,
|
|
8838
8838
|
assertNode,
|
|
8839
8839
|
typePropertyNode,
|
|
8840
|
+
leadsToADirectory = false,
|
|
8840
8841
|
debug = false
|
|
8841
8842
|
}) => {
|
|
8842
8843
|
if (typeof specifier !== "string") {
|
|
@@ -8890,6 +8891,7 @@ const createKitchen = ({
|
|
|
8890
8891
|
assert,
|
|
8891
8892
|
assertNode,
|
|
8892
8893
|
typePropertyNode,
|
|
8894
|
+
leadsToADirectory,
|
|
8893
8895
|
mutation: null,
|
|
8894
8896
|
debug
|
|
8895
8897
|
};
|
|
@@ -9312,7 +9314,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9312
9314
|
});
|
|
9313
9315
|
};
|
|
9314
9316
|
const cook = memoizeCook(async (urlInfo, context) => {
|
|
9315
|
-
if (!
|
|
9317
|
+
if (!outDirectoryUrl) {
|
|
9316
9318
|
await _cook(urlInfo, context);
|
|
9317
9319
|
return;
|
|
9318
9320
|
}
|
|
@@ -10275,17 +10277,6 @@ const parseAndTransformWebmanifestUrls = async (urlInfo, context) => {
|
|
|
10275
10277
|
const content = urlInfo.content;
|
|
10276
10278
|
const manifest = JSON.parse(content);
|
|
10277
10279
|
const actions = [];
|
|
10278
|
-
const {
|
|
10279
|
-
start_url
|
|
10280
|
-
} = manifest;
|
|
10281
|
-
if (start_url) {
|
|
10282
|
-
if (context.build) {
|
|
10283
|
-
manifest.start_url = "/";
|
|
10284
|
-
} else {
|
|
10285
|
-
const parentUrl = context.reference.parentUrl;
|
|
10286
|
-
manifest.start_url = `${parentUrl.slice(context.rootDirectoryUrl.length)}`;
|
|
10287
|
-
}
|
|
10288
|
-
}
|
|
10289
10280
|
const {
|
|
10290
10281
|
icons = []
|
|
10291
10282
|
} = manifest;
|
|
@@ -15227,7 +15218,7 @@ const jsenvPluginAsJsClassicLibrary = ({
|
|
|
15227
15218
|
jsModuleUrlInfos: [jsModuleUrlInfo],
|
|
15228
15219
|
context: {
|
|
15229
15220
|
...context,
|
|
15230
|
-
buildDirectoryUrl:
|
|
15221
|
+
buildDirectoryUrl: new URL("./", import.meta.url)
|
|
15231
15222
|
},
|
|
15232
15223
|
preserveDynamicImport: true
|
|
15233
15224
|
});
|
|
@@ -16956,67 +16947,73 @@ const applyFileSystemMagicResolution = (fileUrl, {
|
|
|
16956
16947
|
magicDirectoryIndex,
|
|
16957
16948
|
magicExtensions
|
|
16958
16949
|
}) => {
|
|
16959
|
-
|
|
16960
|
-
|
|
16950
|
+
const result = {
|
|
16951
|
+
stat: null,
|
|
16952
|
+
url: fileUrl,
|
|
16953
|
+
magicExtension: "",
|
|
16954
|
+
magicDirectoryIndex: false,
|
|
16955
|
+
lastENOENTError: null
|
|
16956
|
+
};
|
|
16957
|
+
if (fileStat === undefined) {
|
|
16961
16958
|
try {
|
|
16962
|
-
|
|
16959
|
+
fileStat = statSync(new URL(fileUrl));
|
|
16963
16960
|
} catch (e) {
|
|
16964
16961
|
if (e.code === "ENOENT") {
|
|
16965
|
-
lastENOENTError = e;
|
|
16966
|
-
|
|
16962
|
+
result.lastENOENTError = e;
|
|
16963
|
+
fileStat = null;
|
|
16964
|
+
} else {
|
|
16965
|
+
throw e;
|
|
16967
16966
|
}
|
|
16968
|
-
throw e;
|
|
16969
16967
|
}
|
|
16970
|
-
}
|
|
16971
|
-
fileStat = fileStat === undefined ? fileStatOrNull(fileUrl) : fileStat;
|
|
16968
|
+
}
|
|
16972
16969
|
if (fileStat && fileStat.isFile()) {
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
};
|
|
16970
|
+
result.stat = fileStat;
|
|
16971
|
+
result.url = fileUrl;
|
|
16972
|
+
return result;
|
|
16977
16973
|
}
|
|
16978
16974
|
if (fileStat && fileStat.isDirectory()) {
|
|
16979
16975
|
if (magicDirectoryIndex) {
|
|
16980
16976
|
const indexFileSuffix = fileUrl.endsWith("/") ? "index" : "/index";
|
|
16981
16977
|
const indexFileUrl = `${fileUrl}${indexFileSuffix}`;
|
|
16982
|
-
const
|
|
16978
|
+
const subResult = applyFileSystemMagicResolution(indexFileUrl, {
|
|
16983
16979
|
magicDirectoryIndex: false,
|
|
16984
16980
|
magicExtensions
|
|
16985
16981
|
});
|
|
16986
16982
|
return {
|
|
16987
16983
|
...result,
|
|
16984
|
+
...subResult,
|
|
16988
16985
|
magicDirectoryIndex: true
|
|
16989
16986
|
};
|
|
16990
16987
|
}
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
isDirectory: true
|
|
16995
|
-
};
|
|
16988
|
+
result.stat = fileStat;
|
|
16989
|
+
result.url = fileUrl;
|
|
16990
|
+
return result;
|
|
16996
16991
|
}
|
|
16997
16992
|
if (magicExtensions && magicExtensions.length) {
|
|
16998
16993
|
const parentUrl = new URL("./", fileUrl).href;
|
|
16999
16994
|
const urlFilename = urlToFilename(fileUrl);
|
|
17000
|
-
const
|
|
16995
|
+
for (const extensionToTry of magicExtensions) {
|
|
17001
16996
|
const urlCandidate = `${parentUrl}${urlFilename}${extensionToTry}`;
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
}
|
|
16997
|
+
let stat;
|
|
16998
|
+
try {
|
|
16999
|
+
stat = statSync(new URL(urlCandidate));
|
|
17000
|
+
} catch (e) {
|
|
17001
|
+
if (e.code === "ENOENT") {
|
|
17002
|
+
stat = null;
|
|
17003
|
+
} else {
|
|
17004
|
+
throw e;
|
|
17005
|
+
}
|
|
17006
|
+
}
|
|
17007
|
+
if (stat) {
|
|
17008
|
+
result.stat = stat;
|
|
17009
|
+
result.url = `${fileUrl}${extensionToTry}`;
|
|
17010
|
+
result.magicExtension = extensionToTry;
|
|
17011
|
+
return result;
|
|
17012
|
+
}
|
|
17012
17013
|
}
|
|
17013
17014
|
}
|
|
17014
17015
|
// magic extension not found
|
|
17015
|
-
return
|
|
17016
|
-
found: false,
|
|
17017
|
-
url: fileUrl,
|
|
17018
|
-
lastENOENTError
|
|
17019
|
-
};
|
|
17016
|
+
return result;
|
|
17020
17017
|
};
|
|
17021
17018
|
const getExtensionsToTry = (magicExtensions, importer) => {
|
|
17022
17019
|
if (!magicExtensions) {
|
|
@@ -17329,46 +17326,52 @@ const jsenvPluginFileUrls = ({
|
|
|
17329
17326
|
const pathnameUsesTrailingSlash = pathname.endsWith("/");
|
|
17330
17327
|
urlObject.search = "";
|
|
17331
17328
|
urlObject.hash = "";
|
|
17332
|
-
const foundADirectory = stat && stat.isDirectory();
|
|
17333
|
-
const foundSomething = stat && !foundADirectory;
|
|
17334
17329
|
// force trailing slash on directories
|
|
17335
|
-
if (
|
|
17330
|
+
if (stat && stat.isDirectory() && !pathnameUsesTrailingSlash) {
|
|
17336
17331
|
urlObject.pathname = `${pathname}/`;
|
|
17337
17332
|
}
|
|
17338
17333
|
// otherwise remove trailing slash if any
|
|
17339
|
-
if (
|
|
17334
|
+
if (stat && !stat.isDirectory() && pathnameUsesTrailingSlash) {
|
|
17340
17335
|
// a warning here? (because it's strange to reference a file with a trailing slash)
|
|
17341
17336
|
urlObject.pathname = pathname.slice(0, -1);
|
|
17342
17337
|
}
|
|
17343
|
-
|
|
17344
|
-
|
|
17345
|
-
|
|
17346
|
-
|
|
17347
|
-
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
17351
|
-
|
|
17352
|
-
const
|
|
17353
|
-
|
|
17354
|
-
|
|
17355
|
-
|
|
17356
|
-
|
|
17357
|
-
|
|
17358
|
-
|
|
17359
|
-
|
|
17360
|
-
|
|
17361
|
-
|
|
17362
|
-
|
|
17363
|
-
|
|
17364
|
-
|
|
17365
|
-
|
|
17338
|
+
let url = urlObject.href;
|
|
17339
|
+
const shouldPreserve = stat && stat.isDirectory() && (
|
|
17340
|
+
// ignore new URL second arg
|
|
17341
|
+
reference.subtype === "new_url_second_arg" ||
|
|
17342
|
+
// ignore root file url
|
|
17343
|
+
reference.url === "file:///" || reference.subtype === "new_url_first_arg" && reference.specifier === "./");
|
|
17344
|
+
if (shouldPreserve) {
|
|
17345
|
+
reference.shouldHandle = false;
|
|
17346
|
+
} else {
|
|
17347
|
+
const shouldApplyDilesystemMagicResolution = reference.type === "js_import";
|
|
17348
|
+
if (shouldApplyDilesystemMagicResolution) {
|
|
17349
|
+
const filesystemResolution = applyFileSystemMagicResolution(url, {
|
|
17350
|
+
fileStat: stat,
|
|
17351
|
+
magicDirectoryIndex,
|
|
17352
|
+
magicExtensions: getExtensionsToTry(magicExtensions, reference.parentUrl)
|
|
17353
|
+
});
|
|
17354
|
+
if (filesystemResolution.stat) {
|
|
17355
|
+
stat = filesystemResolution.stat;
|
|
17356
|
+
url = filesystemResolution.url;
|
|
17357
|
+
}
|
|
17358
|
+
}
|
|
17359
|
+
if (stat && stat.isDirectory()) {
|
|
17360
|
+
const directoryAllowed = reference.type === "filesystem" || typeof directoryReferenceAllowed === "function" && directoryReferenceAllowed(reference) || directoryReferenceAllowed;
|
|
17361
|
+
if (!directoryAllowed) {
|
|
17362
|
+
const error = new Error("Reference leads to a directory");
|
|
17363
|
+
error.code = "DIRECTORY_REFERENCE_NOT_ALLOWED";
|
|
17364
|
+
throw error;
|
|
17365
|
+
}
|
|
17366
|
+
}
|
|
17367
|
+
}
|
|
17368
|
+
reference.leadsToADirectory = stat && stat.isDirectory();
|
|
17369
|
+
if (stat) {
|
|
17370
|
+
const urlRaw = preserveSymlinks ? url : resolveSymlink(url);
|
|
17371
|
+
const resolvedUrl = `${urlRaw}${search}${hash}`;
|
|
17372
|
+
return resolvedUrl;
|
|
17366
17373
|
}
|
|
17367
|
-
|
|
17368
|
-
const fileFacadeUrl = filesystemResolution.url;
|
|
17369
|
-
const fileUrlRaw = preserveSymlinks ? fileFacadeUrl : resolveSymlink(fileFacadeUrl);
|
|
17370
|
-
const fileUrl = `${fileUrlRaw}${search}${hash}`;
|
|
17371
|
-
return fileUrl;
|
|
17374
|
+
return null;
|
|
17372
17375
|
}
|
|
17373
17376
|
}, {
|
|
17374
17377
|
name: "jsenv:filesystem_resolution",
|
|
@@ -17413,26 +17416,21 @@ const jsenvPluginFileUrls = ({
|
|
|
17413
17416
|
return null;
|
|
17414
17417
|
}
|
|
17415
17418
|
const urlObject = new URL(urlInfo.url);
|
|
17416
|
-
if (context.reference.
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
filename = `${urlToFilename$1(urlInfo.url)}/`;
|
|
17425
|
-
}
|
|
17426
|
-
return {
|
|
17427
|
-
type: "directory",
|
|
17428
|
-
contentType: "application/json",
|
|
17429
|
-
content: JSON.stringify(directoryEntries, null, " "),
|
|
17430
|
-
filename
|
|
17431
|
-
};
|
|
17419
|
+
if (context.reference.leadsToADirectory) {
|
|
17420
|
+
const directoryEntries = readdirSync(urlObject);
|
|
17421
|
+
let filename;
|
|
17422
|
+
if (context.reference.type === "filesystem") {
|
|
17423
|
+
const parentUrlInfo = context.urlGraph.getUrlInfo(context.reference.parentUrl);
|
|
17424
|
+
filename = `${parentUrlInfo.filename}${context.reference.specifier}/`;
|
|
17425
|
+
} else {
|
|
17426
|
+
filename = `${urlToFilename$1(urlInfo.url)}/`;
|
|
17432
17427
|
}
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17428
|
+
return {
|
|
17429
|
+
type: "directory",
|
|
17430
|
+
contentType: "application/json",
|
|
17431
|
+
content: JSON.stringify(directoryEntries, null, " "),
|
|
17432
|
+
filename
|
|
17433
|
+
};
|
|
17436
17434
|
}
|
|
17437
17435
|
const fileBuffer = readFileSync$1(urlObject);
|
|
17438
17436
|
const contentType = CONTENT_TYPE.fromUrlExtension(urlInfo.url);
|
|
@@ -20883,7 +20881,7 @@ const build = async ({
|
|
|
20883
20881
|
watch = false,
|
|
20884
20882
|
directoryToClean,
|
|
20885
20883
|
writeOnFileSystem = true,
|
|
20886
|
-
|
|
20884
|
+
outDirectoryUrl,
|
|
20887
20885
|
assetManifest = versioningMethod === "filename",
|
|
20888
20886
|
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
20889
20887
|
...rest
|
|
@@ -20895,6 +20893,15 @@ const build = async ({
|
|
|
20895
20893
|
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
20896
20894
|
}
|
|
20897
20895
|
sourceDirectoryUrl = assertAndNormalizeDirectoryUrl(sourceDirectoryUrl, "sourceDirectoryUrl");
|
|
20896
|
+
buildDirectoryUrl = assertAndNormalizeDirectoryUrl(buildDirectoryUrl, "buildDirectoryUrl");
|
|
20897
|
+
if (outDirectoryUrl === undefined && !process.env.CI) {
|
|
20898
|
+
const packageDirectoryUrl = lookupPackageDirectory(sourceDirectoryUrl);
|
|
20899
|
+
if (packageDirectoryUrl) {
|
|
20900
|
+
outDirectoryUrl = `${packageDirectoryUrl}.jsenv/`;
|
|
20901
|
+
}
|
|
20902
|
+
} else {
|
|
20903
|
+
outDirectoryUrl = assertAndNormalizeDirectoryUrl(outDirectoryUrl, "outDirectoryUrl");
|
|
20904
|
+
}
|
|
20898
20905
|
if (typeof entryPoints !== "object" || entryPoints === null) {
|
|
20899
20906
|
throw new TypeError(`entryPoints must be an object, got ${entryPoints}`);
|
|
20900
20907
|
}
|
|
@@ -20911,7 +20918,6 @@ const build = async ({
|
|
|
20911
20918
|
throw new TypeError(`entryPoints values must be plain strings (no "/"), found "${value}" on key "${key}"`);
|
|
20912
20919
|
}
|
|
20913
20920
|
});
|
|
20914
|
-
buildDirectoryUrl = assertAndNormalizeDirectoryUrl(buildDirectoryUrl, "buildDirectoryUrl");
|
|
20915
20921
|
if (!["filename", "search_param"].includes(versioningMethod)) {
|
|
20916
20922
|
throw new TypeError(`versioningMethod must be "filename" or "search_param", got ${versioning}`);
|
|
20917
20923
|
}
|
|
@@ -20935,7 +20941,6 @@ const build = async ({
|
|
|
20935
20941
|
directoryToClean = new URL(assetsDirectory, buildDirectoryUrl).href;
|
|
20936
20942
|
}
|
|
20937
20943
|
}
|
|
20938
|
-
const jsenvInternalDirectoryUrl = determineJsenvInternalDirectoryUrl(sourceDirectoryUrl);
|
|
20939
20944
|
const asFormattedBuildUrl = (generatedUrl, reference) => {
|
|
20940
20945
|
if (base === "./") {
|
|
20941
20946
|
const urlRelativeToParent = urlToRelativeUrl(generatedUrl, reference.parentUrl === sourceDirectoryUrl ? buildDirectoryUrl : reference.parentUrl);
|
|
@@ -20989,7 +20994,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
20989
20994
|
signal,
|
|
20990
20995
|
logLevel,
|
|
20991
20996
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
20992
|
-
jsenvInternalDirectoryUrl,
|
|
20993
20997
|
urlGraph: rawGraph,
|
|
20994
20998
|
build: true,
|
|
20995
20999
|
runtimeCompat,
|
|
@@ -21024,8 +21028,7 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21024
21028
|
})],
|
|
21025
21029
|
sourcemaps,
|
|
21026
21030
|
sourcemapsSourcesContent,
|
|
21027
|
-
|
|
21028
|
-
outDirectoryUrl: new URL("build/", jsenvInternalDirectoryUrl)
|
|
21031
|
+
outDirectoryUrl: outDirectoryUrl ? new URL("build/", outDirectoryUrl) : undefined
|
|
21029
21032
|
});
|
|
21030
21033
|
const buildUrlsGenerator = createBuildUrlsGenerator({
|
|
21031
21034
|
buildDirectoryUrl,
|
|
@@ -21053,7 +21056,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21053
21056
|
const finalGraphKitchen = createKitchen({
|
|
21054
21057
|
logLevel,
|
|
21055
21058
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
21056
|
-
jsenvInternalDirectoryUrl,
|
|
21057
21059
|
urlGraph: finalGraph,
|
|
21058
21060
|
build: true,
|
|
21059
21061
|
runtimeCompat,
|
|
@@ -21299,8 +21301,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21299
21301
|
sourcemaps,
|
|
21300
21302
|
sourcemapsSourcesContent,
|
|
21301
21303
|
sourcemapsSourcesRelative: !versioning,
|
|
21302
|
-
|
|
21303
|
-
outDirectoryUrl: new URL("postbuild/", jsenvInternalDirectoryUrl)
|
|
21304
|
+
outDirectoryUrl: outDirectoryUrl ? new URL("postbuild/", outDirectoryUrl) : undefined
|
|
21304
21305
|
});
|
|
21305
21306
|
const finalEntryUrls = [];
|
|
21306
21307
|
{
|
|
@@ -21308,8 +21309,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21308
21309
|
disabled: logger.levels.debug || !logger.levels.info
|
|
21309
21310
|
});
|
|
21310
21311
|
try {
|
|
21311
|
-
if (
|
|
21312
|
-
await ensureEmptyDirectory(new URL(`build/`,
|
|
21312
|
+
if (outDirectoryUrl) {
|
|
21313
|
+
await ensureEmptyDirectory(new URL(`build/`, outDirectoryUrl));
|
|
21313
21314
|
}
|
|
21314
21315
|
const rawUrlGraphLoader = createUrlGraphLoader(rawGraphKitchen.kitchenContext);
|
|
21315
21316
|
Object.keys(entryPoints).forEach(key => {
|
|
@@ -21522,8 +21523,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21522
21523
|
disabled: logger.levels.debug || !logger.levels.info
|
|
21523
21524
|
});
|
|
21524
21525
|
try {
|
|
21525
|
-
if (
|
|
21526
|
-
await ensureEmptyDirectory(new URL(`postbuild/`,
|
|
21526
|
+
if (outDirectoryUrl) {
|
|
21527
|
+
await ensureEmptyDirectory(new URL(`postbuild/`, outDirectoryUrl));
|
|
21527
21528
|
}
|
|
21528
21529
|
const finalUrlGraphLoader = createUrlGraphLoader(finalGraphKitchen.kitchenContext);
|
|
21529
21530
|
entryUrls.forEach(entryUrl => {
|
|
@@ -21723,7 +21724,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21723
21724
|
const versioningKitchen = createKitchen({
|
|
21724
21725
|
logLevel: logger.level,
|
|
21725
21726
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
21726
|
-
jsenvInternalDirectoryUrl,
|
|
21727
21727
|
urlGraph: finalGraph,
|
|
21728
21728
|
build: true,
|
|
21729
21729
|
runtimeCompat,
|
|
@@ -21815,8 +21815,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21815
21815
|
sourcemaps,
|
|
21816
21816
|
sourcemapsSourcesContent,
|
|
21817
21817
|
sourcemapsSourcesRelative: true,
|
|
21818
|
-
|
|
21819
|
-
outDirectoryUrl: new URL("postbuild/", jsenvInternalDirectoryUrl)
|
|
21818
|
+
outDirectoryUrl: outDirectoryUrl ? new URL("postbuild/", outDirectoryUrl) : undefined
|
|
21820
21819
|
});
|
|
21821
21820
|
const versioningUrlGraphLoader = createUrlGraphLoader(versioningKitchen.kitchenContext);
|
|
21822
21821
|
finalEntryUrls.forEach(finalEntryUrl => {
|
|
@@ -22344,7 +22343,7 @@ const createFileService = ({
|
|
|
22344
22343
|
sourcemaps,
|
|
22345
22344
|
sourcemapsSourcesProtocol,
|
|
22346
22345
|
sourcemapsSourcesContent,
|
|
22347
|
-
|
|
22346
|
+
outDirectoryUrl
|
|
22348
22347
|
}) => {
|
|
22349
22348
|
const clientFileChangeCallbackList = [];
|
|
22350
22349
|
const clientFilesPruneCallbackList = [];
|
|
@@ -22393,7 +22392,6 @@ const createFileService = ({
|
|
|
22393
22392
|
const clientRuntimeCompat = {
|
|
22394
22393
|
[runtimeName]: runtimeVersion
|
|
22395
22394
|
};
|
|
22396
|
-
const jsenvInternalDirectoryUrl = determineJsenvInternalDirectoryUrl(sourceDirectoryUrl);
|
|
22397
22395
|
let mainFileUrl;
|
|
22398
22396
|
if (sourceMainFilePath === undefined) {
|
|
22399
22397
|
mainFileUrl = explorer ? String(explorerHtmlFileUrl) : String(new URL("./index.html", sourceDirectoryUrl));
|
|
@@ -22404,7 +22402,6 @@ const createFileService = ({
|
|
|
22404
22402
|
signal,
|
|
22405
22403
|
logLevel,
|
|
22406
22404
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
22407
|
-
jsenvInternalDirectoryUrl,
|
|
22408
22405
|
urlGraph,
|
|
22409
22406
|
dev: true,
|
|
22410
22407
|
runtimeCompat,
|
|
@@ -22431,8 +22428,7 @@ const createFileService = ({
|
|
|
22431
22428
|
sourcemaps,
|
|
22432
22429
|
sourcemapsSourcesProtocol,
|
|
22433
22430
|
sourcemapsSourcesContent,
|
|
22434
|
-
|
|
22435
|
-
outDirectoryUrl: new URL(`${runtimeName}@${runtimeVersion}/`, jsenvInternalDirectoryUrl)
|
|
22431
|
+
outDirectoryUrl: outDirectoryUrl ? new URL(`${runtimeName}@${runtimeVersion}/`, outDirectoryUrl) : undefined
|
|
22436
22432
|
});
|
|
22437
22433
|
urlGraph.createUrlInfoCallbackRef.current = urlInfo => {
|
|
22438
22434
|
const {
|
|
@@ -22778,9 +22774,7 @@ const startDevServer = async ({
|
|
|
22778
22774
|
sourcemaps = "inline",
|
|
22779
22775
|
sourcemapsSourcesProtocol,
|
|
22780
22776
|
sourcemapsSourcesContent,
|
|
22781
|
-
|
|
22782
|
-
// and mitigates https://github.com/actions/runner-images/issues/3885
|
|
22783
|
-
writeGeneratedFiles = !process.env.CI,
|
|
22777
|
+
outDirectoryUrl,
|
|
22784
22778
|
...rest
|
|
22785
22779
|
}) => {
|
|
22786
22780
|
// params type checking
|
|
@@ -22790,6 +22784,14 @@ const startDevServer = async ({
|
|
|
22790
22784
|
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
22791
22785
|
}
|
|
22792
22786
|
sourceDirectoryUrl = assertAndNormalizeDirectoryUrl(sourceDirectoryUrl, "sourceDirectoryUrl");
|
|
22787
|
+
if (outDirectoryUrl === undefined && !process.env.CI) {
|
|
22788
|
+
const packageDirectoryUrl = lookupPackageDirectory(sourceDirectoryUrl);
|
|
22789
|
+
if (packageDirectoryUrl) {
|
|
22790
|
+
outDirectoryUrl = `${packageDirectoryUrl}.jsenv/`;
|
|
22791
|
+
}
|
|
22792
|
+
} else {
|
|
22793
|
+
outDirectoryUrl = assertAndNormalizeDirectoryUrl(outDirectoryUrl, "outDirectoryUrl");
|
|
22794
|
+
}
|
|
22793
22795
|
}
|
|
22794
22796
|
const logger = createLogger({
|
|
22795
22797
|
logLevel
|
|
@@ -22882,7 +22884,7 @@ const startDevServer = async ({
|
|
|
22882
22884
|
sourcemaps,
|
|
22883
22885
|
sourcemapsSourcesProtocol,
|
|
22884
22886
|
sourcemapsSourcesContent,
|
|
22885
|
-
|
|
22887
|
+
outDirectoryUrl
|
|
22886
22888
|
}),
|
|
22887
22889
|
handleWebsocket: (websocket, {
|
|
22888
22890
|
request
|
|
@@ -24670,7 +24672,7 @@ const executeTestPlan = async ({
|
|
|
24670
24672
|
await import(devServerModuleUrl);
|
|
24671
24673
|
delete process.env.IMPORTED_BY_TEST_PLAN;
|
|
24672
24674
|
} catch (e) {
|
|
24673
|
-
if (e.code === "
|
|
24675
|
+
if (e.code === "ERR_MODULE_NOT_FOUND") {
|
|
24674
24676
|
throw new Error(`Cannot find file responsible to start dev server at "${devServerModuleUrl}"`);
|
|
24675
24677
|
}
|
|
24676
24678
|
throw e;
|