@nasti-toolchain/nasti 2.5.0 → 2.5.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/cli.cjs +1504 -183
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1495 -174
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1455 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1452 -131
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -10,16 +10,25 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
10
10
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
11
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
12
|
});
|
|
13
|
-
var __glob = (map) => (
|
|
14
|
-
var fn = map[
|
|
13
|
+
var __glob = (map) => (path23) => {
|
|
14
|
+
var fn = map[path23];
|
|
15
15
|
if (fn) return fn();
|
|
16
|
-
throw new Error("Module not found in bundle: " +
|
|
16
|
+
throw new Error("Module not found in bundle: " + path23);
|
|
17
17
|
};
|
|
18
|
-
var __esm = (fn, res) => function __init() {
|
|
19
|
-
|
|
18
|
+
var __esm = (fn, res, err) => function __init() {
|
|
19
|
+
if (err) throw err[0];
|
|
20
|
+
try {
|
|
21
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
throw err = [e], e;
|
|
24
|
+
}
|
|
20
25
|
};
|
|
21
26
|
var __commonJS = (cb, mod) => function __require3() {
|
|
22
|
-
|
|
27
|
+
try {
|
|
28
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
throw mod = 0, e;
|
|
31
|
+
}
|
|
23
32
|
};
|
|
24
33
|
var __export = (target, all) => {
|
|
25
34
|
for (var name in all)
|
|
@@ -144,7 +153,7 @@ function createLogger(level = "info", options = {}) {
|
|
|
144
153
|
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
145
154
|
const clear = canClearScreen ? clearScreen : () => {
|
|
146
155
|
};
|
|
147
|
-
function
|
|
156
|
+
function format2(type, msg, options2 = {}) {
|
|
148
157
|
if (options2.timestamp) {
|
|
149
158
|
const tag = type === "info" ? pc.cyan(pc.bold(prefix)) : type === "warn" ? pc.yellow(pc.bold(prefix)) : pc.red(pc.bold(prefix));
|
|
150
159
|
return `${pc.dim(timeFormatter.format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
|
|
@@ -161,16 +170,16 @@ function createLogger(level = "info", options = {}) {
|
|
|
161
170
|
if (type === lastType && msg === lastMsg) {
|
|
162
171
|
sameCount++;
|
|
163
172
|
clear();
|
|
164
|
-
console_[method](
|
|
173
|
+
console_[method](format2(type, msg, options2), pc.yellow(`(x${sameCount + 1})`));
|
|
165
174
|
} else {
|
|
166
175
|
sameCount = 0;
|
|
167
176
|
lastMsg = msg;
|
|
168
177
|
lastType = type;
|
|
169
178
|
if (options2.clear) clear();
|
|
170
|
-
console_[method](
|
|
179
|
+
console_[method](format2(type, msg, options2));
|
|
171
180
|
}
|
|
172
181
|
} else {
|
|
173
|
-
console_[method](
|
|
182
|
+
console_[method](format2(type, msg, options2));
|
|
174
183
|
}
|
|
175
184
|
}
|
|
176
185
|
const warnedMessages = /* @__PURE__ */ new Set();
|
|
@@ -891,27 +900,27 @@ var require_process = __commonJS({
|
|
|
891
900
|
var require_filesystem = __commonJS({
|
|
892
901
|
"node_modules/detect-libc/lib/filesystem.js"(exports, module) {
|
|
893
902
|
"use strict";
|
|
894
|
-
var
|
|
903
|
+
var fs17 = __require("fs");
|
|
895
904
|
var LDD_PATH = "/usr/bin/ldd";
|
|
896
905
|
var SELF_PATH = "/proc/self/exe";
|
|
897
906
|
var MAX_LENGTH = 2048;
|
|
898
|
-
var readFileSync = (
|
|
899
|
-
const fd =
|
|
907
|
+
var readFileSync = (path23) => {
|
|
908
|
+
const fd = fs17.openSync(path23, "r");
|
|
900
909
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
901
|
-
const bytesRead =
|
|
902
|
-
|
|
910
|
+
const bytesRead = fs17.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
911
|
+
fs17.close(fd, () => {
|
|
903
912
|
});
|
|
904
913
|
return buffer.subarray(0, bytesRead);
|
|
905
914
|
};
|
|
906
|
-
var readFile = (
|
|
907
|
-
|
|
915
|
+
var readFile = (path23) => new Promise((resolve, reject) => {
|
|
916
|
+
fs17.open(path23, "r", (err, fd) => {
|
|
908
917
|
if (err) {
|
|
909
918
|
reject(err);
|
|
910
919
|
} else {
|
|
911
920
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
912
|
-
|
|
921
|
+
fs17.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
913
922
|
resolve(buffer.subarray(0, bytesRead));
|
|
914
|
-
|
|
923
|
+
fs17.close(fd, () => {
|
|
915
924
|
});
|
|
916
925
|
});
|
|
917
926
|
}
|
|
@@ -1023,11 +1032,11 @@ var require_detect_libc = __commonJS({
|
|
|
1023
1032
|
}
|
|
1024
1033
|
return null;
|
|
1025
1034
|
};
|
|
1026
|
-
var familyFromInterpreterPath = (
|
|
1027
|
-
if (
|
|
1028
|
-
if (
|
|
1035
|
+
var familyFromInterpreterPath = (path23) => {
|
|
1036
|
+
if (path23) {
|
|
1037
|
+
if (path23.includes("/ld-musl-")) {
|
|
1029
1038
|
return MUSL;
|
|
1030
|
-
} else if (
|
|
1039
|
+
} else if (path23.includes("/ld-linux-")) {
|
|
1031
1040
|
return GLIBC;
|
|
1032
1041
|
}
|
|
1033
1042
|
}
|
|
@@ -1074,8 +1083,8 @@ var require_detect_libc = __commonJS({
|
|
|
1074
1083
|
cachedFamilyInterpreter = null;
|
|
1075
1084
|
try {
|
|
1076
1085
|
const selfContent = await readFile(SELF_PATH);
|
|
1077
|
-
const
|
|
1078
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
1086
|
+
const path23 = interpreterPath(selfContent);
|
|
1087
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path23);
|
|
1079
1088
|
} catch (e) {
|
|
1080
1089
|
}
|
|
1081
1090
|
return cachedFamilyInterpreter;
|
|
@@ -1087,8 +1096,8 @@ var require_detect_libc = __commonJS({
|
|
|
1087
1096
|
cachedFamilyInterpreter = null;
|
|
1088
1097
|
try {
|
|
1089
1098
|
const selfContent = readFileSync(SELF_PATH);
|
|
1090
|
-
const
|
|
1091
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
1099
|
+
const path23 = interpreterPath(selfContent);
|
|
1100
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path23);
|
|
1092
1101
|
} catch (e) {
|
|
1093
1102
|
}
|
|
1094
1103
|
return cachedFamilyInterpreter;
|
|
@@ -2316,8 +2325,8 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2316
2325
|
let cached2 = descriptorCache.get(filePath);
|
|
2317
2326
|
if (!cached2) {
|
|
2318
2327
|
try {
|
|
2319
|
-
const
|
|
2320
|
-
const rawSource =
|
|
2328
|
+
const fs17 = await import("fs");
|
|
2329
|
+
const rawSource = fs17.readFileSync(filePath, "utf-8");
|
|
2321
2330
|
const transformedSfc = await applySourceTransform(
|
|
2322
2331
|
vueOptions.transformSfc,
|
|
2323
2332
|
rawSource,
|
|
@@ -4013,7 +4022,7 @@ async function build(inlineConfig = {}) {
|
|
|
4013
4022
|
const startTime = performance.now();
|
|
4014
4023
|
logger.info(
|
|
4015
4024
|
pc4.cyan(`
|
|
4016
|
-
nasti v${"2.5.
|
|
4025
|
+
nasti v${"2.5.1"} `) + pc4.green(`building for ${config.mode}...`)
|
|
4017
4026
|
);
|
|
4018
4027
|
debug5?.(`root: ${config.root}`);
|
|
4019
4028
|
const buildableNames = Object.keys(config.environments).filter((name) => {
|
|
@@ -4987,8 +4996,8 @@ function rewriteExternalRequires(code, baseDir, root) {
|
|
|
4987
4996
|
}
|
|
4988
4997
|
async function injectCjsNamedExports(code, entryFile) {
|
|
4989
4998
|
try {
|
|
4990
|
-
const { createRequire:
|
|
4991
|
-
const req =
|
|
4999
|
+
const { createRequire: createRequire7 } = await import("module");
|
|
5000
|
+
const req = createRequire7(entryFile);
|
|
4992
5001
|
const cjsExports = req(entryFile);
|
|
4993
5002
|
if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
|
|
4994
5003
|
const namedKeys = Object.keys(cjsExports).filter(
|
|
@@ -5839,16 +5848,1320 @@ var init_hmr = __esm({
|
|
|
5839
5848
|
}
|
|
5840
5849
|
});
|
|
5841
5850
|
|
|
5851
|
+
// node_modules/import-meta-resolve/lib/errors.js
|
|
5852
|
+
import v8 from "v8";
|
|
5853
|
+
import assert from "assert";
|
|
5854
|
+
import { format, inspect } from "util";
|
|
5855
|
+
function formatList(array, type = "and") {
|
|
5856
|
+
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
|
|
5857
|
+
}
|
|
5858
|
+
function createError(sym, value, constructor) {
|
|
5859
|
+
messages.set(sym, value);
|
|
5860
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
5861
|
+
}
|
|
5862
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
5863
|
+
return NodeError;
|
|
5864
|
+
function NodeError(...parameters) {
|
|
5865
|
+
const limit = Error.stackTraceLimit;
|
|
5866
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
5867
|
+
const error = new Base();
|
|
5868
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
5869
|
+
const message = getMessage(key, parameters, error);
|
|
5870
|
+
Object.defineProperties(error, {
|
|
5871
|
+
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
5872
|
+
// probably.
|
|
5873
|
+
message: {
|
|
5874
|
+
value: message,
|
|
5875
|
+
enumerable: false,
|
|
5876
|
+
writable: true,
|
|
5877
|
+
configurable: true
|
|
5878
|
+
},
|
|
5879
|
+
toString: {
|
|
5880
|
+
/** @this {Error} */
|
|
5881
|
+
value() {
|
|
5882
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
5883
|
+
},
|
|
5884
|
+
enumerable: false,
|
|
5885
|
+
writable: true,
|
|
5886
|
+
configurable: true
|
|
5887
|
+
}
|
|
5888
|
+
});
|
|
5889
|
+
captureLargerStackTrace(error);
|
|
5890
|
+
error.code = key;
|
|
5891
|
+
return error;
|
|
5892
|
+
}
|
|
5893
|
+
}
|
|
5894
|
+
function isErrorStackTraceLimitWritable() {
|
|
5895
|
+
try {
|
|
5896
|
+
if (v8.startupSnapshot.isBuildingSnapshot()) {
|
|
5897
|
+
return false;
|
|
5898
|
+
}
|
|
5899
|
+
} catch {
|
|
5900
|
+
}
|
|
5901
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
5902
|
+
if (desc === void 0) {
|
|
5903
|
+
return Object.isExtensible(Error);
|
|
5904
|
+
}
|
|
5905
|
+
return own.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
5906
|
+
}
|
|
5907
|
+
function hideStackFrames(wrappedFunction) {
|
|
5908
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
5909
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
5910
|
+
return wrappedFunction;
|
|
5911
|
+
}
|
|
5912
|
+
function getMessage(key, parameters, self) {
|
|
5913
|
+
const message = messages.get(key);
|
|
5914
|
+
assert.ok(message !== void 0, "expected `message` to be found");
|
|
5915
|
+
if (typeof message === "function") {
|
|
5916
|
+
assert.ok(
|
|
5917
|
+
message.length <= parameters.length,
|
|
5918
|
+
// Default options do not count.
|
|
5919
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
|
|
5920
|
+
);
|
|
5921
|
+
return Reflect.apply(message, self, parameters);
|
|
5922
|
+
}
|
|
5923
|
+
const regex = /%[dfijoOs]/g;
|
|
5924
|
+
let expectedLength = 0;
|
|
5925
|
+
while (regex.exec(message) !== null) expectedLength++;
|
|
5926
|
+
assert.ok(
|
|
5927
|
+
expectedLength === parameters.length,
|
|
5928
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
|
|
5929
|
+
);
|
|
5930
|
+
if (parameters.length === 0) return message;
|
|
5931
|
+
parameters.unshift(message);
|
|
5932
|
+
return Reflect.apply(format, null, parameters);
|
|
5933
|
+
}
|
|
5934
|
+
function determineSpecificType(value) {
|
|
5935
|
+
if (value === null || value === void 0) {
|
|
5936
|
+
return String(value);
|
|
5937
|
+
}
|
|
5938
|
+
if (typeof value === "function" && value.name) {
|
|
5939
|
+
return `function ${value.name}`;
|
|
5940
|
+
}
|
|
5941
|
+
if (typeof value === "object") {
|
|
5942
|
+
if (value.constructor && value.constructor.name) {
|
|
5943
|
+
return `an instance of ${value.constructor.name}`;
|
|
5944
|
+
}
|
|
5945
|
+
return `${inspect(value, { depth: -1 })}`;
|
|
5946
|
+
}
|
|
5947
|
+
let inspected = inspect(value, { colors: false });
|
|
5948
|
+
if (inspected.length > 28) {
|
|
5949
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
5950
|
+
}
|
|
5951
|
+
return `type ${typeof value} (${inspected})`;
|
|
5952
|
+
}
|
|
5953
|
+
var own, classRegExp, kTypes, codes, messages, nodeInternalPrefix, userStackTraceLimit, captureLargerStackTrace;
|
|
5954
|
+
var init_errors = __esm({
|
|
5955
|
+
"node_modules/import-meta-resolve/lib/errors.js"() {
|
|
5956
|
+
"use strict";
|
|
5957
|
+
own = {}.hasOwnProperty;
|
|
5958
|
+
classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
5959
|
+
kTypes = /* @__PURE__ */ new Set([
|
|
5960
|
+
"string",
|
|
5961
|
+
"function",
|
|
5962
|
+
"number",
|
|
5963
|
+
"object",
|
|
5964
|
+
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
5965
|
+
"Function",
|
|
5966
|
+
"Object",
|
|
5967
|
+
"boolean",
|
|
5968
|
+
"bigint",
|
|
5969
|
+
"symbol"
|
|
5970
|
+
]);
|
|
5971
|
+
codes = {};
|
|
5972
|
+
messages = /* @__PURE__ */ new Map();
|
|
5973
|
+
nodeInternalPrefix = "__node_internal_";
|
|
5974
|
+
codes.ERR_INVALID_ARG_TYPE = createError(
|
|
5975
|
+
"ERR_INVALID_ARG_TYPE",
|
|
5976
|
+
/**
|
|
5977
|
+
* @param {string} name
|
|
5978
|
+
* @param {Array<string> | string} expected
|
|
5979
|
+
* @param {unknown} actual
|
|
5980
|
+
*/
|
|
5981
|
+
(name, expected, actual) => {
|
|
5982
|
+
assert.ok(typeof name === "string", "'name' must be a string");
|
|
5983
|
+
if (!Array.isArray(expected)) {
|
|
5984
|
+
expected = [expected];
|
|
5985
|
+
}
|
|
5986
|
+
let message = "The ";
|
|
5987
|
+
if (name.endsWith(" argument")) {
|
|
5988
|
+
message += `${name} `;
|
|
5989
|
+
} else {
|
|
5990
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
5991
|
+
message += `"${name}" ${type} `;
|
|
5992
|
+
}
|
|
5993
|
+
message += "must be ";
|
|
5994
|
+
const types = [];
|
|
5995
|
+
const instances = [];
|
|
5996
|
+
const other = [];
|
|
5997
|
+
for (const value of expected) {
|
|
5998
|
+
assert.ok(
|
|
5999
|
+
typeof value === "string",
|
|
6000
|
+
"All expected entries have to be of type string"
|
|
6001
|
+
);
|
|
6002
|
+
if (kTypes.has(value)) {
|
|
6003
|
+
types.push(value.toLowerCase());
|
|
6004
|
+
} else if (classRegExp.exec(value) === null) {
|
|
6005
|
+
assert.ok(
|
|
6006
|
+
value !== "object",
|
|
6007
|
+
'The value "object" should be written as "Object"'
|
|
6008
|
+
);
|
|
6009
|
+
other.push(value);
|
|
6010
|
+
} else {
|
|
6011
|
+
instances.push(value);
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
if (instances.length > 0) {
|
|
6015
|
+
const pos = types.indexOf("object");
|
|
6016
|
+
if (pos !== -1) {
|
|
6017
|
+
types.slice(pos, 1);
|
|
6018
|
+
instances.push("Object");
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
if (types.length > 0) {
|
|
6022
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
|
|
6023
|
+
types,
|
|
6024
|
+
"or"
|
|
6025
|
+
)}`;
|
|
6026
|
+
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
6027
|
+
}
|
|
6028
|
+
if (instances.length > 0) {
|
|
6029
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
6030
|
+
if (other.length > 0) message += " or ";
|
|
6031
|
+
}
|
|
6032
|
+
if (other.length > 0) {
|
|
6033
|
+
if (other.length > 1) {
|
|
6034
|
+
message += `one of ${formatList(other, "or")}`;
|
|
6035
|
+
} else {
|
|
6036
|
+
if (other[0].toLowerCase() !== other[0]) message += "an ";
|
|
6037
|
+
message += `${other[0]}`;
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
6041
|
+
return message;
|
|
6042
|
+
},
|
|
6043
|
+
TypeError
|
|
6044
|
+
);
|
|
6045
|
+
codes.ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
6046
|
+
"ERR_INVALID_MODULE_SPECIFIER",
|
|
6047
|
+
/**
|
|
6048
|
+
* @param {string} request
|
|
6049
|
+
* @param {string} reason
|
|
6050
|
+
* @param {string} [base]
|
|
6051
|
+
*/
|
|
6052
|
+
(request, reason, base = void 0) => {
|
|
6053
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
6054
|
+
},
|
|
6055
|
+
TypeError
|
|
6056
|
+
);
|
|
6057
|
+
codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
6058
|
+
"ERR_INVALID_PACKAGE_CONFIG",
|
|
6059
|
+
/**
|
|
6060
|
+
* @param {string} path
|
|
6061
|
+
* @param {string} [base]
|
|
6062
|
+
* @param {string} [message]
|
|
6063
|
+
*/
|
|
6064
|
+
(path23, base, message) => {
|
|
6065
|
+
return `Invalid package config ${path23}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
6066
|
+
},
|
|
6067
|
+
Error
|
|
6068
|
+
);
|
|
6069
|
+
codes.ERR_INVALID_PACKAGE_TARGET = createError(
|
|
6070
|
+
"ERR_INVALID_PACKAGE_TARGET",
|
|
6071
|
+
/**
|
|
6072
|
+
* @param {string} packagePath
|
|
6073
|
+
* @param {string} key
|
|
6074
|
+
* @param {unknown} target
|
|
6075
|
+
* @param {boolean} [isImport=false]
|
|
6076
|
+
* @param {string} [base]
|
|
6077
|
+
*/
|
|
6078
|
+
(packagePath, key, target, isImport = false, base = void 0) => {
|
|
6079
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
6080
|
+
if (key === ".") {
|
|
6081
|
+
assert.ok(isImport === false);
|
|
6082
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
6083
|
+
}
|
|
6084
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
6085
|
+
target
|
|
6086
|
+
)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
6087
|
+
},
|
|
6088
|
+
Error
|
|
6089
|
+
);
|
|
6090
|
+
codes.ERR_MODULE_NOT_FOUND = createError(
|
|
6091
|
+
"ERR_MODULE_NOT_FOUND",
|
|
6092
|
+
/**
|
|
6093
|
+
* @param {string} path
|
|
6094
|
+
* @param {string} base
|
|
6095
|
+
* @param {boolean} [exactUrl]
|
|
6096
|
+
*/
|
|
6097
|
+
(path23, base, exactUrl = false) => {
|
|
6098
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path23}' imported from ${base}`;
|
|
6099
|
+
},
|
|
6100
|
+
Error
|
|
6101
|
+
);
|
|
6102
|
+
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError(
|
|
6103
|
+
"ERR_NETWORK_IMPORT_DISALLOWED",
|
|
6104
|
+
"import of '%s' by %s is not supported: %s",
|
|
6105
|
+
Error
|
|
6106
|
+
);
|
|
6107
|
+
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
6108
|
+
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
6109
|
+
/**
|
|
6110
|
+
* @param {string} specifier
|
|
6111
|
+
* @param {string} packagePath
|
|
6112
|
+
* @param {string} base
|
|
6113
|
+
*/
|
|
6114
|
+
(specifier, packagePath, base) => {
|
|
6115
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
6116
|
+
},
|
|
6117
|
+
TypeError
|
|
6118
|
+
);
|
|
6119
|
+
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
6120
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
6121
|
+
/**
|
|
6122
|
+
* @param {string} packagePath
|
|
6123
|
+
* @param {string} subpath
|
|
6124
|
+
* @param {string} [base]
|
|
6125
|
+
*/
|
|
6126
|
+
(packagePath, subpath, base = void 0) => {
|
|
6127
|
+
if (subpath === ".")
|
|
6128
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
6129
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
6130
|
+
},
|
|
6131
|
+
Error
|
|
6132
|
+
);
|
|
6133
|
+
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
|
|
6134
|
+
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
6135
|
+
"Directory import '%s' is not supported resolving ES modules imported from %s",
|
|
6136
|
+
Error
|
|
6137
|
+
);
|
|
6138
|
+
codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
|
|
6139
|
+
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
|
|
6140
|
+
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
|
|
6141
|
+
TypeError
|
|
6142
|
+
);
|
|
6143
|
+
codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
6144
|
+
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
6145
|
+
/**
|
|
6146
|
+
* @param {string} extension
|
|
6147
|
+
* @param {string} path
|
|
6148
|
+
*/
|
|
6149
|
+
(extension, path23) => {
|
|
6150
|
+
return `Unknown file extension "${extension}" for ${path23}`;
|
|
6151
|
+
},
|
|
6152
|
+
TypeError
|
|
6153
|
+
);
|
|
6154
|
+
codes.ERR_INVALID_ARG_VALUE = createError(
|
|
6155
|
+
"ERR_INVALID_ARG_VALUE",
|
|
6156
|
+
/**
|
|
6157
|
+
* @param {string} name
|
|
6158
|
+
* @param {unknown} value
|
|
6159
|
+
* @param {string} [reason='is invalid']
|
|
6160
|
+
*/
|
|
6161
|
+
(name, value, reason = "is invalid") => {
|
|
6162
|
+
let inspected = inspect(value);
|
|
6163
|
+
if (inspected.length > 128) {
|
|
6164
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
6165
|
+
}
|
|
6166
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
6167
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
6168
|
+
},
|
|
6169
|
+
TypeError
|
|
6170
|
+
// Note: extra classes have been shaken out.
|
|
6171
|
+
// , RangeError
|
|
6172
|
+
);
|
|
6173
|
+
captureLargerStackTrace = hideStackFrames(
|
|
6174
|
+
/**
|
|
6175
|
+
* @param {Error} error
|
|
6176
|
+
* @returns {Error}
|
|
6177
|
+
*/
|
|
6178
|
+
// @ts-expect-error: fine
|
|
6179
|
+
function(error) {
|
|
6180
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
6181
|
+
if (stackTraceLimitIsWritable) {
|
|
6182
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
6183
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
6184
|
+
}
|
|
6185
|
+
Error.captureStackTrace(error);
|
|
6186
|
+
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
6187
|
+
return error;
|
|
6188
|
+
}
|
|
6189
|
+
);
|
|
6190
|
+
}
|
|
6191
|
+
});
|
|
6192
|
+
|
|
6193
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
6194
|
+
import fs12 from "fs";
|
|
6195
|
+
import path15 from "path";
|
|
6196
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6197
|
+
function read(jsonPath, { base, specifier }) {
|
|
6198
|
+
const existing = cache.get(jsonPath);
|
|
6199
|
+
if (existing) {
|
|
6200
|
+
return existing;
|
|
6201
|
+
}
|
|
6202
|
+
let string;
|
|
6203
|
+
try {
|
|
6204
|
+
string = fs12.readFileSync(path15.toNamespacedPath(jsonPath), "utf8");
|
|
6205
|
+
} catch (error) {
|
|
6206
|
+
const exception = (
|
|
6207
|
+
/** @type {ErrnoException} */
|
|
6208
|
+
error
|
|
6209
|
+
);
|
|
6210
|
+
if (exception.code !== "ENOENT") {
|
|
6211
|
+
throw exception;
|
|
6212
|
+
}
|
|
6213
|
+
}
|
|
6214
|
+
const result = {
|
|
6215
|
+
exists: false,
|
|
6216
|
+
pjsonPath: jsonPath,
|
|
6217
|
+
main: void 0,
|
|
6218
|
+
name: void 0,
|
|
6219
|
+
type: "none",
|
|
6220
|
+
// Ignore unknown types for forwards compatibility
|
|
6221
|
+
exports: void 0,
|
|
6222
|
+
imports: void 0
|
|
6223
|
+
};
|
|
6224
|
+
if (string !== void 0) {
|
|
6225
|
+
let parsed;
|
|
6226
|
+
try {
|
|
6227
|
+
parsed = JSON.parse(string);
|
|
6228
|
+
} catch (error_) {
|
|
6229
|
+
const cause = (
|
|
6230
|
+
/** @type {ErrnoException} */
|
|
6231
|
+
error_
|
|
6232
|
+
);
|
|
6233
|
+
const error = new ERR_INVALID_PACKAGE_CONFIG(
|
|
6234
|
+
jsonPath,
|
|
6235
|
+
(base ? `"${specifier}" from ` : "") + fileURLToPath2(base || specifier),
|
|
6236
|
+
cause.message
|
|
6237
|
+
);
|
|
6238
|
+
error.cause = cause;
|
|
6239
|
+
throw error;
|
|
6240
|
+
}
|
|
6241
|
+
result.exists = true;
|
|
6242
|
+
if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
|
|
6243
|
+
result.name = parsed.name;
|
|
6244
|
+
}
|
|
6245
|
+
if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
|
|
6246
|
+
result.main = parsed.main;
|
|
6247
|
+
}
|
|
6248
|
+
if (hasOwnProperty.call(parsed, "exports")) {
|
|
6249
|
+
result.exports = parsed.exports;
|
|
6250
|
+
}
|
|
6251
|
+
if (hasOwnProperty.call(parsed, "imports")) {
|
|
6252
|
+
result.imports = parsed.imports;
|
|
6253
|
+
}
|
|
6254
|
+
if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
|
|
6255
|
+
result.type = parsed.type;
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
cache.set(jsonPath, result);
|
|
6259
|
+
return result;
|
|
6260
|
+
}
|
|
6261
|
+
function getPackageScopeConfig(resolved) {
|
|
6262
|
+
let packageJSONUrl = new URL("package.json", resolved);
|
|
6263
|
+
while (true) {
|
|
6264
|
+
const packageJSONPath2 = packageJSONUrl.pathname;
|
|
6265
|
+
if (packageJSONPath2.endsWith("node_modules/package.json")) {
|
|
6266
|
+
break;
|
|
6267
|
+
}
|
|
6268
|
+
const packageConfig = read(fileURLToPath2(packageJSONUrl), {
|
|
6269
|
+
specifier: resolved
|
|
6270
|
+
});
|
|
6271
|
+
if (packageConfig.exists) {
|
|
6272
|
+
return packageConfig;
|
|
6273
|
+
}
|
|
6274
|
+
const lastPackageJSONUrl = packageJSONUrl;
|
|
6275
|
+
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
6276
|
+
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
|
|
6277
|
+
break;
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
const packageJSONPath = fileURLToPath2(packageJSONUrl);
|
|
6281
|
+
return {
|
|
6282
|
+
pjsonPath: packageJSONPath,
|
|
6283
|
+
exists: false,
|
|
6284
|
+
type: "none"
|
|
6285
|
+
};
|
|
6286
|
+
}
|
|
6287
|
+
function getPackageType(url) {
|
|
6288
|
+
return getPackageScopeConfig(url).type;
|
|
6289
|
+
}
|
|
6290
|
+
var hasOwnProperty, ERR_INVALID_PACKAGE_CONFIG, cache;
|
|
6291
|
+
var init_package_json_reader = __esm({
|
|
6292
|
+
"node_modules/import-meta-resolve/lib/package-json-reader.js"() {
|
|
6293
|
+
"use strict";
|
|
6294
|
+
init_errors();
|
|
6295
|
+
hasOwnProperty = {}.hasOwnProperty;
|
|
6296
|
+
({ ERR_INVALID_PACKAGE_CONFIG } = codes);
|
|
6297
|
+
cache = /* @__PURE__ */ new Map();
|
|
6298
|
+
}
|
|
6299
|
+
});
|
|
6300
|
+
|
|
6301
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
6302
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
6303
|
+
function mimeToFormat(mime) {
|
|
6304
|
+
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
|
|
6305
|
+
return "module";
|
|
6306
|
+
if (mime === "application/json") return "json";
|
|
6307
|
+
return null;
|
|
6308
|
+
}
|
|
6309
|
+
function getDataProtocolModuleFormat(parsed) {
|
|
6310
|
+
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
|
|
6311
|
+
parsed.pathname
|
|
6312
|
+
) || [null, null, null];
|
|
6313
|
+
return mimeToFormat(mime);
|
|
6314
|
+
}
|
|
6315
|
+
function extname(url) {
|
|
6316
|
+
const pathname = url.pathname;
|
|
6317
|
+
let index2 = pathname.length;
|
|
6318
|
+
while (index2--) {
|
|
6319
|
+
const code = pathname.codePointAt(index2);
|
|
6320
|
+
if (code === 47) {
|
|
6321
|
+
return "";
|
|
6322
|
+
}
|
|
6323
|
+
if (code === 46) {
|
|
6324
|
+
return pathname.codePointAt(index2 - 1) === 47 ? "" : pathname.slice(index2);
|
|
6325
|
+
}
|
|
6326
|
+
}
|
|
6327
|
+
return "";
|
|
6328
|
+
}
|
|
6329
|
+
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
6330
|
+
const value = extname(url);
|
|
6331
|
+
if (value === ".js") {
|
|
6332
|
+
const packageType = getPackageType(url);
|
|
6333
|
+
if (packageType !== "none") {
|
|
6334
|
+
return packageType;
|
|
6335
|
+
}
|
|
6336
|
+
return "commonjs";
|
|
6337
|
+
}
|
|
6338
|
+
if (value === "") {
|
|
6339
|
+
const packageType = getPackageType(url);
|
|
6340
|
+
if (packageType === "none" || packageType === "commonjs") {
|
|
6341
|
+
return "commonjs";
|
|
6342
|
+
}
|
|
6343
|
+
return "module";
|
|
6344
|
+
}
|
|
6345
|
+
const format2 = extensionFormatMap[value];
|
|
6346
|
+
if (format2) return format2;
|
|
6347
|
+
if (ignoreErrors) {
|
|
6348
|
+
return void 0;
|
|
6349
|
+
}
|
|
6350
|
+
const filepath = fileURLToPath3(url);
|
|
6351
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
|
|
6352
|
+
}
|
|
6353
|
+
function getHttpProtocolModuleFormat() {
|
|
6354
|
+
}
|
|
6355
|
+
function defaultGetFormatWithoutErrors(url, context) {
|
|
6356
|
+
const protocol = url.protocol;
|
|
6357
|
+
if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
|
|
6358
|
+
return null;
|
|
6359
|
+
}
|
|
6360
|
+
return protocolHandlers[protocol](url, context, true) || null;
|
|
6361
|
+
}
|
|
6362
|
+
var ERR_UNKNOWN_FILE_EXTENSION, hasOwnProperty2, extensionFormatMap, protocolHandlers;
|
|
6363
|
+
var init_get_format = __esm({
|
|
6364
|
+
"node_modules/import-meta-resolve/lib/get-format.js"() {
|
|
6365
|
+
"use strict";
|
|
6366
|
+
init_package_json_reader();
|
|
6367
|
+
init_errors();
|
|
6368
|
+
({ ERR_UNKNOWN_FILE_EXTENSION } = codes);
|
|
6369
|
+
hasOwnProperty2 = {}.hasOwnProperty;
|
|
6370
|
+
extensionFormatMap = {
|
|
6371
|
+
// @ts-expect-error: hush.
|
|
6372
|
+
__proto__: null,
|
|
6373
|
+
".cjs": "commonjs",
|
|
6374
|
+
".js": "module",
|
|
6375
|
+
".json": "json",
|
|
6376
|
+
".mjs": "module"
|
|
6377
|
+
};
|
|
6378
|
+
protocolHandlers = {
|
|
6379
|
+
// @ts-expect-error: hush.
|
|
6380
|
+
__proto__: null,
|
|
6381
|
+
"data:": getDataProtocolModuleFormat,
|
|
6382
|
+
"file:": getFileProtocolModuleFormat,
|
|
6383
|
+
"http:": getHttpProtocolModuleFormat,
|
|
6384
|
+
"https:": getHttpProtocolModuleFormat,
|
|
6385
|
+
"node:"() {
|
|
6386
|
+
return "builtin";
|
|
6387
|
+
}
|
|
6388
|
+
};
|
|
6389
|
+
}
|
|
6390
|
+
});
|
|
6391
|
+
|
|
6392
|
+
// node_modules/import-meta-resolve/lib/utils.js
|
|
6393
|
+
function getDefaultConditions() {
|
|
6394
|
+
return DEFAULT_CONDITIONS;
|
|
6395
|
+
}
|
|
6396
|
+
function getDefaultConditionsSet() {
|
|
6397
|
+
return DEFAULT_CONDITIONS_SET;
|
|
6398
|
+
}
|
|
6399
|
+
function getConditionsSet(conditions) {
|
|
6400
|
+
if (conditions !== void 0 && conditions !== getDefaultConditions()) {
|
|
6401
|
+
if (!Array.isArray(conditions)) {
|
|
6402
|
+
throw new ERR_INVALID_ARG_VALUE(
|
|
6403
|
+
"conditions",
|
|
6404
|
+
conditions,
|
|
6405
|
+
"expected an array"
|
|
6406
|
+
);
|
|
6407
|
+
}
|
|
6408
|
+
return new Set(conditions);
|
|
6409
|
+
}
|
|
6410
|
+
return getDefaultConditionsSet();
|
|
6411
|
+
}
|
|
6412
|
+
var ERR_INVALID_ARG_VALUE, DEFAULT_CONDITIONS, DEFAULT_CONDITIONS_SET;
|
|
6413
|
+
var init_utils = __esm({
|
|
6414
|
+
"node_modules/import-meta-resolve/lib/utils.js"() {
|
|
6415
|
+
"use strict";
|
|
6416
|
+
init_errors();
|
|
6417
|
+
({ ERR_INVALID_ARG_VALUE } = codes);
|
|
6418
|
+
DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
|
|
6419
|
+
DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
|
|
6420
|
+
}
|
|
6421
|
+
});
|
|
6422
|
+
|
|
6423
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
6424
|
+
import assert2 from "assert";
|
|
6425
|
+
import { statSync, realpathSync } from "fs";
|
|
6426
|
+
import process2 from "process";
|
|
6427
|
+
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL4 } from "url";
|
|
6428
|
+
import path16 from "path";
|
|
6429
|
+
import { builtinModules as builtinModules3 } from "module";
|
|
6430
|
+
function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
|
|
6431
|
+
if (process2.noDeprecation) {
|
|
6432
|
+
return;
|
|
6433
|
+
}
|
|
6434
|
+
const pjsonPath = fileURLToPath4(packageJsonUrl);
|
|
6435
|
+
const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
|
|
6436
|
+
process2.emitWarning(
|
|
6437
|
+
`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath4(base)}` : ""}.`,
|
|
6438
|
+
"DeprecationWarning",
|
|
6439
|
+
"DEP0166"
|
|
6440
|
+
);
|
|
6441
|
+
}
|
|
6442
|
+
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
6443
|
+
if (process2.noDeprecation) {
|
|
6444
|
+
return;
|
|
6445
|
+
}
|
|
6446
|
+
const format2 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
|
|
6447
|
+
if (format2 !== "module") return;
|
|
6448
|
+
const urlPath = fileURLToPath4(url.href);
|
|
6449
|
+
const packagePath = fileURLToPath4(new URL(".", packageJsonUrl));
|
|
6450
|
+
const basePath = fileURLToPath4(base);
|
|
6451
|
+
if (!main) {
|
|
6452
|
+
process2.emitWarning(
|
|
6453
|
+
`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
|
|
6454
|
+
packagePath.length
|
|
6455
|
+
)}", imported from ${basePath}.
|
|
6456
|
+
Default "index" lookups for the main are deprecated for ES modules.`,
|
|
6457
|
+
"DeprecationWarning",
|
|
6458
|
+
"DEP0151"
|
|
6459
|
+
);
|
|
6460
|
+
} else if (path16.resolve(packagePath, main) !== urlPath) {
|
|
6461
|
+
process2.emitWarning(
|
|
6462
|
+
`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
|
|
6463
|
+
packagePath.length
|
|
6464
|
+
)}", imported from ${basePath}.
|
|
6465
|
+
Automatic extension resolution of the "main" field is deprecated for ES modules.`,
|
|
6466
|
+
"DeprecationWarning",
|
|
6467
|
+
"DEP0151"
|
|
6468
|
+
);
|
|
6469
|
+
}
|
|
6470
|
+
}
|
|
6471
|
+
function tryStatSync(path23) {
|
|
6472
|
+
try {
|
|
6473
|
+
return statSync(path23);
|
|
6474
|
+
} catch {
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
function fileExists(url) {
|
|
6478
|
+
const stats = statSync(url, { throwIfNoEntry: false });
|
|
6479
|
+
const isFile = stats ? stats.isFile() : void 0;
|
|
6480
|
+
return isFile === null || isFile === void 0 ? false : isFile;
|
|
6481
|
+
}
|
|
6482
|
+
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
6483
|
+
let guess;
|
|
6484
|
+
if (packageConfig.main !== void 0) {
|
|
6485
|
+
guess = new URL(packageConfig.main, packageJsonUrl);
|
|
6486
|
+
if (fileExists(guess)) return guess;
|
|
6487
|
+
const tries2 = [
|
|
6488
|
+
`./${packageConfig.main}.js`,
|
|
6489
|
+
`./${packageConfig.main}.json`,
|
|
6490
|
+
`./${packageConfig.main}.node`,
|
|
6491
|
+
`./${packageConfig.main}/index.js`,
|
|
6492
|
+
`./${packageConfig.main}/index.json`,
|
|
6493
|
+
`./${packageConfig.main}/index.node`
|
|
6494
|
+
];
|
|
6495
|
+
let i2 = -1;
|
|
6496
|
+
while (++i2 < tries2.length) {
|
|
6497
|
+
guess = new URL(tries2[i2], packageJsonUrl);
|
|
6498
|
+
if (fileExists(guess)) break;
|
|
6499
|
+
guess = void 0;
|
|
6500
|
+
}
|
|
6501
|
+
if (guess) {
|
|
6502
|
+
emitLegacyIndexDeprecation(
|
|
6503
|
+
guess,
|
|
6504
|
+
packageJsonUrl,
|
|
6505
|
+
base,
|
|
6506
|
+
packageConfig.main
|
|
6507
|
+
);
|
|
6508
|
+
return guess;
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
const tries = ["./index.js", "./index.json", "./index.node"];
|
|
6512
|
+
let i = -1;
|
|
6513
|
+
while (++i < tries.length) {
|
|
6514
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
6515
|
+
if (fileExists(guess)) break;
|
|
6516
|
+
guess = void 0;
|
|
6517
|
+
}
|
|
6518
|
+
if (guess) {
|
|
6519
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
6520
|
+
return guess;
|
|
6521
|
+
}
|
|
6522
|
+
throw new ERR_MODULE_NOT_FOUND(
|
|
6523
|
+
fileURLToPath4(new URL(".", packageJsonUrl)),
|
|
6524
|
+
fileURLToPath4(base)
|
|
6525
|
+
);
|
|
6526
|
+
}
|
|
6527
|
+
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
6528
|
+
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
|
|
6529
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
6530
|
+
resolved.pathname,
|
|
6531
|
+
'must not include encoded "/" or "\\" characters',
|
|
6532
|
+
fileURLToPath4(base)
|
|
6533
|
+
);
|
|
6534
|
+
}
|
|
6535
|
+
let filePath;
|
|
6536
|
+
try {
|
|
6537
|
+
filePath = fileURLToPath4(resolved);
|
|
6538
|
+
} catch (error) {
|
|
6539
|
+
const cause = (
|
|
6540
|
+
/** @type {ErrnoException} */
|
|
6541
|
+
error
|
|
6542
|
+
);
|
|
6543
|
+
Object.defineProperty(cause, "input", { value: String(resolved) });
|
|
6544
|
+
Object.defineProperty(cause, "module", { value: String(base) });
|
|
6545
|
+
throw cause;
|
|
6546
|
+
}
|
|
6547
|
+
const stats = tryStatSync(
|
|
6548
|
+
filePath.endsWith("/") ? filePath.slice(-1) : filePath
|
|
6549
|
+
);
|
|
6550
|
+
if (stats && stats.isDirectory()) {
|
|
6551
|
+
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath4(base));
|
|
6552
|
+
error.url = String(resolved);
|
|
6553
|
+
throw error;
|
|
6554
|
+
}
|
|
6555
|
+
if (!stats || !stats.isFile()) {
|
|
6556
|
+
const error = new ERR_MODULE_NOT_FOUND(
|
|
6557
|
+
filePath || resolved.pathname,
|
|
6558
|
+
base && fileURLToPath4(base),
|
|
6559
|
+
true
|
|
6560
|
+
);
|
|
6561
|
+
error.url = String(resolved);
|
|
6562
|
+
throw error;
|
|
6563
|
+
}
|
|
6564
|
+
if (!preserveSymlinks) {
|
|
6565
|
+
const real = realpathSync(filePath);
|
|
6566
|
+
const { search, hash } = resolved;
|
|
6567
|
+
resolved = pathToFileURL4(real + (filePath.endsWith(path16.sep) ? "/" : ""));
|
|
6568
|
+
resolved.search = search;
|
|
6569
|
+
resolved.hash = hash;
|
|
6570
|
+
}
|
|
6571
|
+
return resolved;
|
|
6572
|
+
}
|
|
6573
|
+
function importNotDefined(specifier, packageJsonUrl, base) {
|
|
6574
|
+
return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
|
|
6575
|
+
specifier,
|
|
6576
|
+
packageJsonUrl && fileURLToPath4(new URL(".", packageJsonUrl)),
|
|
6577
|
+
fileURLToPath4(base)
|
|
6578
|
+
);
|
|
6579
|
+
}
|
|
6580
|
+
function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
6581
|
+
return new ERR_PACKAGE_PATH_NOT_EXPORTED(
|
|
6582
|
+
fileURLToPath4(new URL(".", packageJsonUrl)),
|
|
6583
|
+
subpath,
|
|
6584
|
+
base && fileURLToPath4(base)
|
|
6585
|
+
);
|
|
6586
|
+
}
|
|
6587
|
+
function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
|
|
6588
|
+
const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath4(packageJsonUrl)}`;
|
|
6589
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
6590
|
+
request,
|
|
6591
|
+
reason,
|
|
6592
|
+
base && fileURLToPath4(base)
|
|
6593
|
+
);
|
|
6594
|
+
}
|
|
6595
|
+
function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
|
|
6596
|
+
target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
|
|
6597
|
+
return new ERR_INVALID_PACKAGE_TARGET(
|
|
6598
|
+
fileURLToPath4(new URL(".", packageJsonUrl)),
|
|
6599
|
+
subpath,
|
|
6600
|
+
target,
|
|
6601
|
+
internal,
|
|
6602
|
+
base && fileURLToPath4(base)
|
|
6603
|
+
);
|
|
6604
|
+
}
|
|
6605
|
+
function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
|
|
6606
|
+
if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
|
|
6607
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6608
|
+
if (!target.startsWith("./")) {
|
|
6609
|
+
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
6610
|
+
let isURL = false;
|
|
6611
|
+
try {
|
|
6612
|
+
new URL(target);
|
|
6613
|
+
isURL = true;
|
|
6614
|
+
} catch {
|
|
6615
|
+
}
|
|
6616
|
+
if (!isURL) {
|
|
6617
|
+
const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
6618
|
+
patternRegEx,
|
|
6619
|
+
target,
|
|
6620
|
+
() => subpath
|
|
6621
|
+
) : target + subpath;
|
|
6622
|
+
return packageResolve(exportTarget, packageJsonUrl, conditions);
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6626
|
+
}
|
|
6627
|
+
if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
|
|
6628
|
+
if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
|
|
6629
|
+
if (!isPathMap) {
|
|
6630
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
6631
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
6632
|
+
patternRegEx,
|
|
6633
|
+
target,
|
|
6634
|
+
() => subpath
|
|
6635
|
+
) : target;
|
|
6636
|
+
emitInvalidSegmentDeprecation(
|
|
6637
|
+
resolvedTarget,
|
|
6638
|
+
request,
|
|
6639
|
+
match,
|
|
6640
|
+
packageJsonUrl,
|
|
6641
|
+
internal,
|
|
6642
|
+
base,
|
|
6643
|
+
true
|
|
6644
|
+
);
|
|
6645
|
+
}
|
|
6646
|
+
} else {
|
|
6647
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6648
|
+
}
|
|
6649
|
+
}
|
|
6650
|
+
const resolved = new URL(target, packageJsonUrl);
|
|
6651
|
+
const resolvedPath = resolved.pathname;
|
|
6652
|
+
const packagePath = new URL(".", packageJsonUrl).pathname;
|
|
6653
|
+
if (!resolvedPath.startsWith(packagePath))
|
|
6654
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6655
|
+
if (subpath === "") return resolved;
|
|
6656
|
+
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
6657
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
6658
|
+
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
6659
|
+
if (!isPathMap) {
|
|
6660
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
6661
|
+
patternRegEx,
|
|
6662
|
+
target,
|
|
6663
|
+
() => subpath
|
|
6664
|
+
) : target;
|
|
6665
|
+
emitInvalidSegmentDeprecation(
|
|
6666
|
+
resolvedTarget,
|
|
6667
|
+
request,
|
|
6668
|
+
match,
|
|
6669
|
+
packageJsonUrl,
|
|
6670
|
+
internal,
|
|
6671
|
+
base,
|
|
6672
|
+
false
|
|
6673
|
+
);
|
|
6674
|
+
}
|
|
6675
|
+
} else {
|
|
6676
|
+
throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
if (pattern) {
|
|
6680
|
+
return new URL(
|
|
6681
|
+
RegExpPrototypeSymbolReplace.call(
|
|
6682
|
+
patternRegEx,
|
|
6683
|
+
resolved.href,
|
|
6684
|
+
() => subpath
|
|
6685
|
+
)
|
|
6686
|
+
);
|
|
6687
|
+
}
|
|
6688
|
+
return new URL(subpath, resolved);
|
|
6689
|
+
}
|
|
6690
|
+
function isArrayIndex(key) {
|
|
6691
|
+
const keyNumber = Number(key);
|
|
6692
|
+
if (`${keyNumber}` !== key) return false;
|
|
6693
|
+
return keyNumber >= 0 && keyNumber < 4294967295;
|
|
6694
|
+
}
|
|
6695
|
+
function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
|
|
6696
|
+
if (typeof target === "string") {
|
|
6697
|
+
return resolvePackageTargetString(
|
|
6698
|
+
target,
|
|
6699
|
+
subpath,
|
|
6700
|
+
packageSubpath,
|
|
6701
|
+
packageJsonUrl,
|
|
6702
|
+
base,
|
|
6703
|
+
pattern,
|
|
6704
|
+
internal,
|
|
6705
|
+
isPathMap,
|
|
6706
|
+
conditions
|
|
6707
|
+
);
|
|
6708
|
+
}
|
|
6709
|
+
if (Array.isArray(target)) {
|
|
6710
|
+
const targetList = target;
|
|
6711
|
+
if (targetList.length === 0) return null;
|
|
6712
|
+
let lastException;
|
|
6713
|
+
let i = -1;
|
|
6714
|
+
while (++i < targetList.length) {
|
|
6715
|
+
const targetItem = targetList[i];
|
|
6716
|
+
let resolveResult;
|
|
6717
|
+
try {
|
|
6718
|
+
resolveResult = resolvePackageTarget(
|
|
6719
|
+
packageJsonUrl,
|
|
6720
|
+
targetItem,
|
|
6721
|
+
subpath,
|
|
6722
|
+
packageSubpath,
|
|
6723
|
+
base,
|
|
6724
|
+
pattern,
|
|
6725
|
+
internal,
|
|
6726
|
+
isPathMap,
|
|
6727
|
+
conditions
|
|
6728
|
+
);
|
|
6729
|
+
} catch (error) {
|
|
6730
|
+
const exception = (
|
|
6731
|
+
/** @type {ErrnoException} */
|
|
6732
|
+
error
|
|
6733
|
+
);
|
|
6734
|
+
lastException = exception;
|
|
6735
|
+
if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
|
|
6736
|
+
throw error;
|
|
6737
|
+
}
|
|
6738
|
+
if (resolveResult === void 0) continue;
|
|
6739
|
+
if (resolveResult === null) {
|
|
6740
|
+
lastException = null;
|
|
6741
|
+
continue;
|
|
6742
|
+
}
|
|
6743
|
+
return resolveResult;
|
|
6744
|
+
}
|
|
6745
|
+
if (lastException === void 0 || lastException === null) {
|
|
6746
|
+
return null;
|
|
6747
|
+
}
|
|
6748
|
+
throw lastException;
|
|
6749
|
+
}
|
|
6750
|
+
if (typeof target === "object" && target !== null) {
|
|
6751
|
+
const keys = Object.getOwnPropertyNames(target);
|
|
6752
|
+
let i = -1;
|
|
6753
|
+
while (++i < keys.length) {
|
|
6754
|
+
const key = keys[i];
|
|
6755
|
+
if (isArrayIndex(key)) {
|
|
6756
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(
|
|
6757
|
+
fileURLToPath4(packageJsonUrl),
|
|
6758
|
+
base,
|
|
6759
|
+
'"exports" cannot contain numeric property keys.'
|
|
6760
|
+
);
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
i = -1;
|
|
6764
|
+
while (++i < keys.length) {
|
|
6765
|
+
const key = keys[i];
|
|
6766
|
+
if (key === "default" || conditions && conditions.has(key)) {
|
|
6767
|
+
const conditionalTarget = (
|
|
6768
|
+
/** @type {unknown} */
|
|
6769
|
+
target[key]
|
|
6770
|
+
);
|
|
6771
|
+
const resolveResult = resolvePackageTarget(
|
|
6772
|
+
packageJsonUrl,
|
|
6773
|
+
conditionalTarget,
|
|
6774
|
+
subpath,
|
|
6775
|
+
packageSubpath,
|
|
6776
|
+
base,
|
|
6777
|
+
pattern,
|
|
6778
|
+
internal,
|
|
6779
|
+
isPathMap,
|
|
6780
|
+
conditions
|
|
6781
|
+
);
|
|
6782
|
+
if (resolveResult === void 0) continue;
|
|
6783
|
+
return resolveResult;
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
return null;
|
|
6787
|
+
}
|
|
6788
|
+
if (target === null) {
|
|
6789
|
+
return null;
|
|
6790
|
+
}
|
|
6791
|
+
throw invalidPackageTarget(
|
|
6792
|
+
packageSubpath,
|
|
6793
|
+
target,
|
|
6794
|
+
packageJsonUrl,
|
|
6795
|
+
internal,
|
|
6796
|
+
base
|
|
6797
|
+
);
|
|
6798
|
+
}
|
|
6799
|
+
function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
|
|
6800
|
+
if (typeof exports === "string" || Array.isArray(exports)) return true;
|
|
6801
|
+
if (typeof exports !== "object" || exports === null) return false;
|
|
6802
|
+
const keys = Object.getOwnPropertyNames(exports);
|
|
6803
|
+
let isConditionalSugar = false;
|
|
6804
|
+
let i = 0;
|
|
6805
|
+
let keyIndex = -1;
|
|
6806
|
+
while (++keyIndex < keys.length) {
|
|
6807
|
+
const key = keys[keyIndex];
|
|
6808
|
+
const currentIsConditionalSugar = key === "" || key[0] !== ".";
|
|
6809
|
+
if (i++ === 0) {
|
|
6810
|
+
isConditionalSugar = currentIsConditionalSugar;
|
|
6811
|
+
} else if (isConditionalSugar !== currentIsConditionalSugar) {
|
|
6812
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(
|
|
6813
|
+
fileURLToPath4(packageJsonUrl),
|
|
6814
|
+
base,
|
|
6815
|
+
`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
|
|
6816
|
+
);
|
|
6817
|
+
}
|
|
6818
|
+
}
|
|
6819
|
+
return isConditionalSugar;
|
|
6820
|
+
}
|
|
6821
|
+
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
6822
|
+
if (process2.noDeprecation) {
|
|
6823
|
+
return;
|
|
6824
|
+
}
|
|
6825
|
+
const pjsonPath = fileURLToPath4(pjsonUrl);
|
|
6826
|
+
if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
|
|
6827
|
+
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
6828
|
+
process2.emitWarning(
|
|
6829
|
+
`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath4(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
|
|
6830
|
+
"DeprecationWarning",
|
|
6831
|
+
"DEP0155"
|
|
6832
|
+
);
|
|
6833
|
+
}
|
|
6834
|
+
function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
|
|
6835
|
+
let exports = packageConfig.exports;
|
|
6836
|
+
if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
|
|
6837
|
+
exports = { ".": exports };
|
|
6838
|
+
}
|
|
6839
|
+
if (own2.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
|
|
6840
|
+
const target = exports[packageSubpath];
|
|
6841
|
+
const resolveResult = resolvePackageTarget(
|
|
6842
|
+
packageJsonUrl,
|
|
6843
|
+
target,
|
|
6844
|
+
"",
|
|
6845
|
+
packageSubpath,
|
|
6846
|
+
base,
|
|
6847
|
+
false,
|
|
6848
|
+
false,
|
|
6849
|
+
false,
|
|
6850
|
+
conditions
|
|
6851
|
+
);
|
|
6852
|
+
if (resolveResult === null || resolveResult === void 0) {
|
|
6853
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6854
|
+
}
|
|
6855
|
+
return resolveResult;
|
|
6856
|
+
}
|
|
6857
|
+
let bestMatch = "";
|
|
6858
|
+
let bestMatchSubpath = "";
|
|
6859
|
+
const keys = Object.getOwnPropertyNames(exports);
|
|
6860
|
+
let i = -1;
|
|
6861
|
+
while (++i < keys.length) {
|
|
6862
|
+
const key = keys[i];
|
|
6863
|
+
const patternIndex = key.indexOf("*");
|
|
6864
|
+
if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
|
|
6865
|
+
if (packageSubpath.endsWith("/")) {
|
|
6866
|
+
emitTrailingSlashPatternDeprecation(
|
|
6867
|
+
packageSubpath,
|
|
6868
|
+
packageJsonUrl,
|
|
6869
|
+
base
|
|
6870
|
+
);
|
|
6871
|
+
}
|
|
6872
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
6873
|
+
if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
6874
|
+
bestMatch = key;
|
|
6875
|
+
bestMatchSubpath = packageSubpath.slice(
|
|
6876
|
+
patternIndex,
|
|
6877
|
+
packageSubpath.length - patternTrailer.length
|
|
6878
|
+
);
|
|
6879
|
+
}
|
|
6880
|
+
}
|
|
6881
|
+
}
|
|
6882
|
+
if (bestMatch) {
|
|
6883
|
+
const target = (
|
|
6884
|
+
/** @type {unknown} */
|
|
6885
|
+
exports[bestMatch]
|
|
6886
|
+
);
|
|
6887
|
+
const resolveResult = resolvePackageTarget(
|
|
6888
|
+
packageJsonUrl,
|
|
6889
|
+
target,
|
|
6890
|
+
bestMatchSubpath,
|
|
6891
|
+
bestMatch,
|
|
6892
|
+
base,
|
|
6893
|
+
true,
|
|
6894
|
+
false,
|
|
6895
|
+
packageSubpath.endsWith("/"),
|
|
6896
|
+
conditions
|
|
6897
|
+
);
|
|
6898
|
+
if (resolveResult === null || resolveResult === void 0) {
|
|
6899
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6900
|
+
}
|
|
6901
|
+
return resolveResult;
|
|
6902
|
+
}
|
|
6903
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6904
|
+
}
|
|
6905
|
+
function patternKeyCompare(a, b) {
|
|
6906
|
+
const aPatternIndex = a.indexOf("*");
|
|
6907
|
+
const bPatternIndex = b.indexOf("*");
|
|
6908
|
+
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
6909
|
+
const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
6910
|
+
if (baseLengthA > baseLengthB) return -1;
|
|
6911
|
+
if (baseLengthB > baseLengthA) return 1;
|
|
6912
|
+
if (aPatternIndex === -1) return 1;
|
|
6913
|
+
if (bPatternIndex === -1) return -1;
|
|
6914
|
+
if (a.length > b.length) return -1;
|
|
6915
|
+
if (b.length > a.length) return 1;
|
|
6916
|
+
return 0;
|
|
6917
|
+
}
|
|
6918
|
+
function packageImportsResolve(name, base, conditions) {
|
|
6919
|
+
if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
|
|
6920
|
+
const reason = "is not a valid internal imports specifier name";
|
|
6921
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath4(base));
|
|
6922
|
+
}
|
|
6923
|
+
let packageJsonUrl;
|
|
6924
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
6925
|
+
if (packageConfig.exists) {
|
|
6926
|
+
packageJsonUrl = pathToFileURL4(packageConfig.pjsonPath);
|
|
6927
|
+
const imports = packageConfig.imports;
|
|
6928
|
+
if (imports) {
|
|
6929
|
+
if (own2.call(imports, name) && !name.includes("*")) {
|
|
6930
|
+
const resolveResult = resolvePackageTarget(
|
|
6931
|
+
packageJsonUrl,
|
|
6932
|
+
imports[name],
|
|
6933
|
+
"",
|
|
6934
|
+
name,
|
|
6935
|
+
base,
|
|
6936
|
+
false,
|
|
6937
|
+
true,
|
|
6938
|
+
false,
|
|
6939
|
+
conditions
|
|
6940
|
+
);
|
|
6941
|
+
if (resolveResult !== null && resolveResult !== void 0) {
|
|
6942
|
+
return resolveResult;
|
|
6943
|
+
}
|
|
6944
|
+
} else {
|
|
6945
|
+
let bestMatch = "";
|
|
6946
|
+
let bestMatchSubpath = "";
|
|
6947
|
+
const keys = Object.getOwnPropertyNames(imports);
|
|
6948
|
+
let i = -1;
|
|
6949
|
+
while (++i < keys.length) {
|
|
6950
|
+
const key = keys[i];
|
|
6951
|
+
const patternIndex = key.indexOf("*");
|
|
6952
|
+
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
6953
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
6954
|
+
if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
6955
|
+
bestMatch = key;
|
|
6956
|
+
bestMatchSubpath = name.slice(
|
|
6957
|
+
patternIndex,
|
|
6958
|
+
name.length - patternTrailer.length
|
|
6959
|
+
);
|
|
6960
|
+
}
|
|
6961
|
+
}
|
|
6962
|
+
}
|
|
6963
|
+
if (bestMatch) {
|
|
6964
|
+
const target = imports[bestMatch];
|
|
6965
|
+
const resolveResult = resolvePackageTarget(
|
|
6966
|
+
packageJsonUrl,
|
|
6967
|
+
target,
|
|
6968
|
+
bestMatchSubpath,
|
|
6969
|
+
bestMatch,
|
|
6970
|
+
base,
|
|
6971
|
+
true,
|
|
6972
|
+
true,
|
|
6973
|
+
false,
|
|
6974
|
+
conditions
|
|
6975
|
+
);
|
|
6976
|
+
if (resolveResult !== null && resolveResult !== void 0) {
|
|
6977
|
+
return resolveResult;
|
|
6978
|
+
}
|
|
6979
|
+
}
|
|
6980
|
+
}
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
throw importNotDefined(name, packageJsonUrl, base);
|
|
6984
|
+
}
|
|
6985
|
+
function parsePackageName(specifier, base) {
|
|
6986
|
+
let separatorIndex = specifier.indexOf("/");
|
|
6987
|
+
let validPackageName = true;
|
|
6988
|
+
let isScoped = false;
|
|
6989
|
+
if (specifier[0] === "@") {
|
|
6990
|
+
isScoped = true;
|
|
6991
|
+
if (separatorIndex === -1 || specifier.length === 0) {
|
|
6992
|
+
validPackageName = false;
|
|
6993
|
+
} else {
|
|
6994
|
+
separatorIndex = specifier.indexOf("/", separatorIndex + 1);
|
|
6995
|
+
}
|
|
6996
|
+
}
|
|
6997
|
+
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
6998
|
+
if (invalidPackageNameRegEx.exec(packageName) !== null) {
|
|
6999
|
+
validPackageName = false;
|
|
7000
|
+
}
|
|
7001
|
+
if (!validPackageName) {
|
|
7002
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
7003
|
+
specifier,
|
|
7004
|
+
"is not a valid package name",
|
|
7005
|
+
fileURLToPath4(base)
|
|
7006
|
+
);
|
|
7007
|
+
}
|
|
7008
|
+
const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
|
|
7009
|
+
return { packageName, packageSubpath, isScoped };
|
|
7010
|
+
}
|
|
7011
|
+
function packageResolve(specifier, base, conditions) {
|
|
7012
|
+
if (builtinModules3.includes(specifier)) {
|
|
7013
|
+
return new URL("node:" + specifier);
|
|
7014
|
+
}
|
|
7015
|
+
const { packageName, packageSubpath, isScoped } = parsePackageName(
|
|
7016
|
+
specifier,
|
|
7017
|
+
base
|
|
7018
|
+
);
|
|
7019
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
7020
|
+
if (packageConfig.exists) {
|
|
7021
|
+
const packageJsonUrl2 = pathToFileURL4(packageConfig.pjsonPath);
|
|
7022
|
+
if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
|
|
7023
|
+
return packageExportsResolve(
|
|
7024
|
+
packageJsonUrl2,
|
|
7025
|
+
packageSubpath,
|
|
7026
|
+
packageConfig,
|
|
7027
|
+
base,
|
|
7028
|
+
conditions
|
|
7029
|
+
);
|
|
7030
|
+
}
|
|
7031
|
+
}
|
|
7032
|
+
let packageJsonUrl = new URL(
|
|
7033
|
+
"./node_modules/" + packageName + "/package.json",
|
|
7034
|
+
base
|
|
7035
|
+
);
|
|
7036
|
+
let packageJsonPath = fileURLToPath4(packageJsonUrl);
|
|
7037
|
+
let lastPath;
|
|
7038
|
+
do {
|
|
7039
|
+
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
7040
|
+
if (!stat || !stat.isDirectory()) {
|
|
7041
|
+
lastPath = packageJsonPath;
|
|
7042
|
+
packageJsonUrl = new URL(
|
|
7043
|
+
(isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
|
|
7044
|
+
packageJsonUrl
|
|
7045
|
+
);
|
|
7046
|
+
packageJsonPath = fileURLToPath4(packageJsonUrl);
|
|
7047
|
+
continue;
|
|
7048
|
+
}
|
|
7049
|
+
const packageConfig2 = read(packageJsonPath, { base, specifier });
|
|
7050
|
+
if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
|
|
7051
|
+
return packageExportsResolve(
|
|
7052
|
+
packageJsonUrl,
|
|
7053
|
+
packageSubpath,
|
|
7054
|
+
packageConfig2,
|
|
7055
|
+
base,
|
|
7056
|
+
conditions
|
|
7057
|
+
);
|
|
7058
|
+
}
|
|
7059
|
+
if (packageSubpath === ".") {
|
|
7060
|
+
return legacyMainResolve(packageJsonUrl, packageConfig2, base);
|
|
7061
|
+
}
|
|
7062
|
+
return new URL(packageSubpath, packageJsonUrl);
|
|
7063
|
+
} while (packageJsonPath.length !== lastPath.length);
|
|
7064
|
+
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath4(base), false);
|
|
7065
|
+
}
|
|
7066
|
+
function isRelativeSpecifier(specifier) {
|
|
7067
|
+
if (specifier[0] === ".") {
|
|
7068
|
+
if (specifier.length === 1 || specifier[1] === "/") return true;
|
|
7069
|
+
if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
|
|
7070
|
+
return true;
|
|
7071
|
+
}
|
|
7072
|
+
}
|
|
7073
|
+
return false;
|
|
7074
|
+
}
|
|
7075
|
+
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
7076
|
+
if (specifier === "") return false;
|
|
7077
|
+
if (specifier[0] === "/") return true;
|
|
7078
|
+
return isRelativeSpecifier(specifier);
|
|
7079
|
+
}
|
|
7080
|
+
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
7081
|
+
if (conditions === void 0) {
|
|
7082
|
+
conditions = getConditionsSet();
|
|
7083
|
+
}
|
|
7084
|
+
const protocol = base.protocol;
|
|
7085
|
+
const isData = protocol === "data:";
|
|
7086
|
+
const isRemote = isData || protocol === "http:" || protocol === "https:";
|
|
7087
|
+
let resolved;
|
|
7088
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
7089
|
+
try {
|
|
7090
|
+
resolved = new URL(specifier, base);
|
|
7091
|
+
} catch (error_) {
|
|
7092
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
7093
|
+
error.cause = error_;
|
|
7094
|
+
throw error;
|
|
7095
|
+
}
|
|
7096
|
+
} else if (protocol === "file:" && specifier[0] === "#") {
|
|
7097
|
+
resolved = packageImportsResolve(specifier, base, conditions);
|
|
7098
|
+
} else {
|
|
7099
|
+
try {
|
|
7100
|
+
resolved = new URL(specifier);
|
|
7101
|
+
} catch (error_) {
|
|
7102
|
+
if (isRemote && !builtinModules3.includes(specifier)) {
|
|
7103
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
7104
|
+
error.cause = error_;
|
|
7105
|
+
throw error;
|
|
7106
|
+
}
|
|
7107
|
+
resolved = packageResolve(specifier, base, conditions);
|
|
7108
|
+
}
|
|
7109
|
+
}
|
|
7110
|
+
assert2.ok(resolved !== void 0, "expected to be defined");
|
|
7111
|
+
if (resolved.protocol !== "file:") {
|
|
7112
|
+
return resolved;
|
|
7113
|
+
}
|
|
7114
|
+
return finalizeResolution(resolved, base, preserveSymlinks);
|
|
7115
|
+
}
|
|
7116
|
+
var RegExpPrototypeSymbolReplace, ERR_NETWORK_IMPORT_DISALLOWED, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG2, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST, own2, invalidSegmentRegEx, deprecatedInvalidSegmentRegEx, invalidPackageNameRegEx, patternRegEx, encodedSeparatorRegEx, emittedPackageWarnings, doubleSlashRegEx;
|
|
7117
|
+
var init_resolve2 = __esm({
|
|
7118
|
+
"node_modules/import-meta-resolve/lib/resolve.js"() {
|
|
7119
|
+
"use strict";
|
|
7120
|
+
init_get_format();
|
|
7121
|
+
init_errors();
|
|
7122
|
+
init_package_json_reader();
|
|
7123
|
+
init_utils();
|
|
7124
|
+
RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
7125
|
+
({
|
|
7126
|
+
ERR_NETWORK_IMPORT_DISALLOWED,
|
|
7127
|
+
ERR_INVALID_MODULE_SPECIFIER,
|
|
7128
|
+
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
|
|
7129
|
+
ERR_INVALID_PACKAGE_TARGET,
|
|
7130
|
+
ERR_MODULE_NOT_FOUND,
|
|
7131
|
+
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
|
7132
|
+
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
7133
|
+
ERR_UNSUPPORTED_DIR_IMPORT,
|
|
7134
|
+
ERR_UNSUPPORTED_RESOLVE_REQUEST
|
|
7135
|
+
} = codes);
|
|
7136
|
+
own2 = {}.hasOwnProperty;
|
|
7137
|
+
invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
|
|
7138
|
+
deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
|
|
7139
|
+
invalidPackageNameRegEx = /^\.|%|\\/;
|
|
7140
|
+
patternRegEx = /\*/g;
|
|
7141
|
+
encodedSeparatorRegEx = /%2f|%5c/i;
|
|
7142
|
+
emittedPackageWarnings = /* @__PURE__ */ new Set();
|
|
7143
|
+
doubleSlashRegEx = /[/\\]{2}/;
|
|
7144
|
+
}
|
|
7145
|
+
});
|
|
7146
|
+
|
|
7147
|
+
// node_modules/import-meta-resolve/index.js
|
|
7148
|
+
var init_import_meta_resolve = __esm({
|
|
7149
|
+
"node_modules/import-meta-resolve/index.js"() {
|
|
7150
|
+
"use strict";
|
|
7151
|
+
init_resolve2();
|
|
7152
|
+
}
|
|
7153
|
+
});
|
|
7154
|
+
|
|
5842
7155
|
// src/server/runnable-environment.ts
|
|
5843
7156
|
var runnable_environment_exports = {};
|
|
5844
7157
|
__export(runnable_environment_exports, {
|
|
5845
7158
|
NastiModuleRunner: () => NastiModuleRunner,
|
|
5846
7159
|
createModuleRunner: () => createModuleRunner
|
|
5847
7160
|
});
|
|
5848
|
-
import
|
|
5849
|
-
import
|
|
5850
|
-
import { builtinModules as
|
|
5851
|
-
import { pathToFileURL as
|
|
7161
|
+
import path17 from "path";
|
|
7162
|
+
import fs13 from "fs";
|
|
7163
|
+
import { builtinModules as builtinModules4 } from "module";
|
|
7164
|
+
import { pathToFileURL as pathToFileURL5 } from "url";
|
|
5852
7165
|
function createModuleRunner(environment) {
|
|
5853
7166
|
if (environment.consumer !== "server") {
|
|
5854
7167
|
throw new Error(
|
|
@@ -5861,17 +7174,19 @@ var debug6, NODE_BUILTINS3, NastiModuleRunner, AsyncFunction;
|
|
|
5861
7174
|
var init_runnable_environment = __esm({
|
|
5862
7175
|
"src/server/runnable-environment.ts"() {
|
|
5863
7176
|
"use strict";
|
|
7177
|
+
init_import_meta_resolve();
|
|
5864
7178
|
init_transformer();
|
|
5865
7179
|
init_env();
|
|
5866
7180
|
init_debug();
|
|
5867
7181
|
debug6 = createDebugger("nasti:ssr");
|
|
5868
|
-
NODE_BUILTINS3 = /* @__PURE__ */ new Set([...
|
|
7182
|
+
NODE_BUILTINS3 = /* @__PURE__ */ new Set([...builtinModules4, ...builtinModules4.map((m) => `node:${m}`)]);
|
|
5869
7183
|
NastiModuleRunner = class {
|
|
5870
7184
|
environment;
|
|
5871
7185
|
config;
|
|
5872
7186
|
cache = /* @__PURE__ */ new Map();
|
|
5873
7187
|
envDefine;
|
|
5874
|
-
|
|
7188
|
+
externalImportParent;
|
|
7189
|
+
externalImportConditions;
|
|
5875
7190
|
constructor(environment) {
|
|
5876
7191
|
this.environment = environment;
|
|
5877
7192
|
this.config = environment.config;
|
|
@@ -5880,10 +7195,15 @@ var init_runnable_environment = __esm({
|
|
|
5880
7195
|
this.config.mode,
|
|
5881
7196
|
ssrDefineOverrides(environment.consumer)
|
|
5882
7197
|
);
|
|
5883
|
-
this.
|
|
7198
|
+
this.externalImportParent = pathToFileURL5(path17.join(this.config.root, "package.json"));
|
|
7199
|
+
this.externalImportConditions = /* @__PURE__ */ new Set([
|
|
7200
|
+
...environment.options.resolve.conditions.filter((condition) => condition !== "require"),
|
|
7201
|
+
"node",
|
|
7202
|
+
"import"
|
|
7203
|
+
]);
|
|
5884
7204
|
const handlers = {
|
|
5885
7205
|
fetchModule: async (id, importer) => this.fetchModule(id, importer),
|
|
5886
|
-
getBuiltins: () => [/^node:/, ...
|
|
7206
|
+
getBuiltins: () => [/^node:/, ...builtinModules4]
|
|
5887
7207
|
};
|
|
5888
7208
|
environment.hot.setInvokeHandler?.(handlers);
|
|
5889
7209
|
}
|
|
@@ -5904,9 +7224,9 @@ var init_runnable_environment = __esm({
|
|
|
5904
7224
|
this.cache.clear();
|
|
5905
7225
|
}
|
|
5906
7226
|
resolveToId(rawUrl) {
|
|
5907
|
-
if (
|
|
7227
|
+
if (path17.isAbsolute(rawUrl) && fs13.existsSync(rawUrl.split("?")[0])) return rawUrl;
|
|
5908
7228
|
const clean = rawUrl.replace(/^\//, "");
|
|
5909
|
-
return
|
|
7229
|
+
return path17.resolve(this.config.root, clean);
|
|
5910
7230
|
}
|
|
5911
7231
|
/**
|
|
5912
7232
|
* fetchModule(invoke 契约方法):环境管线产出 runner 可执行代码。
|
|
@@ -5915,14 +7235,14 @@ var init_runnable_environment = __esm({
|
|
|
5915
7235
|
*/
|
|
5916
7236
|
async fetchModule(id, importer) {
|
|
5917
7237
|
if (NODE_BUILTINS3.has(id)) return { externalize: id };
|
|
5918
|
-
if (!id.startsWith(".") && !
|
|
7238
|
+
if (!id.startsWith(".") && !path17.isAbsolute(id) && !id.startsWith("\0")) {
|
|
5919
7239
|
return { externalize: id };
|
|
5920
7240
|
}
|
|
5921
7241
|
const container = this.environment.pluginContainer;
|
|
5922
7242
|
let resolvedId = id;
|
|
5923
7243
|
if (id.startsWith(".") && importer) {
|
|
5924
7244
|
const resolved = await container.resolveId(id, importer);
|
|
5925
|
-
resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id :
|
|
7245
|
+
resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : path17.resolve(path17.dirname(importer.split("?")[0]), id);
|
|
5926
7246
|
}
|
|
5927
7247
|
resolvedId = this.completeExtension(resolvedId);
|
|
5928
7248
|
const cleanId = resolvedId.split("?")[0];
|
|
@@ -5930,8 +7250,8 @@ var init_runnable_environment = __esm({
|
|
|
5930
7250
|
const loaded = await container.load(resolvedId);
|
|
5931
7251
|
if (loaded != null) {
|
|
5932
7252
|
code = typeof loaded === "string" ? loaded : loaded.code;
|
|
5933
|
-
} else if (
|
|
5934
|
-
code =
|
|
7253
|
+
} else if (fs13.existsSync(cleanId)) {
|
|
7254
|
+
code = fs13.readFileSync(cleanId, "utf-8");
|
|
5935
7255
|
} else {
|
|
5936
7256
|
throw new Error(`[nasti:ssr] cannot load module: ${resolvedId}`);
|
|
5937
7257
|
}
|
|
@@ -5985,19 +7305,19 @@ var init_runnable_environment = __esm({
|
|
|
5985
7305
|
completeExtension(id) {
|
|
5986
7306
|
const clean = id.split("?")[0];
|
|
5987
7307
|
const query = id.includes("?") ? id.slice(id.indexOf("?")) : "";
|
|
5988
|
-
if (
|
|
7308
|
+
if (fs13.existsSync(clean) && fs13.statSync(clean).isFile()) return id;
|
|
5989
7309
|
const jsMatch = clean.match(/^(.*)\.([mc]?)jsx?$/);
|
|
5990
7310
|
if (jsMatch) {
|
|
5991
7311
|
for (const tsExt of [`.${jsMatch[2]}ts`, `.${jsMatch[2]}tsx`]) {
|
|
5992
|
-
if (
|
|
7312
|
+
if (fs13.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
|
|
5993
7313
|
}
|
|
5994
7314
|
}
|
|
5995
7315
|
for (const ext of this.config.resolve.extensions) {
|
|
5996
|
-
if (
|
|
7316
|
+
if (fs13.existsSync(clean + ext)) return clean + ext + query;
|
|
5997
7317
|
}
|
|
5998
7318
|
for (const ext of this.config.resolve.extensions) {
|
|
5999
|
-
const indexPath =
|
|
6000
|
-
if (
|
|
7319
|
+
const indexPath = path17.join(clean, `index${ext}`);
|
|
7320
|
+
if (fs13.existsSync(indexPath)) return indexPath;
|
|
6001
7321
|
}
|
|
6002
7322
|
return id;
|
|
6003
7323
|
}
|
|
@@ -6024,10 +7344,10 @@ var init_runnable_environment = __esm({
|
|
|
6024
7344
|
return;
|
|
6025
7345
|
}
|
|
6026
7346
|
const ssrImport = async (dep) => {
|
|
6027
|
-
if (NODE_BUILTINS3.has(dep) || !dep.startsWith(".") && !
|
|
7347
|
+
if (NODE_BUILTINS3.has(dep) || !dep.startsWith(".") && !path17.isAbsolute(dep) && !dep.startsWith("\0")) {
|
|
6028
7348
|
return this.importExternal(dep);
|
|
6029
7349
|
}
|
|
6030
|
-
const depId = dep.startsWith(".") ? this.completeExtension(
|
|
7350
|
+
const depId = dep.startsWith(".") ? this.completeExtension(path17.resolve(path17.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
|
|
6031
7351
|
return this.instantiate(depId);
|
|
6032
7352
|
};
|
|
6033
7353
|
const ssrExportAll = (sourceModule) => {
|
|
@@ -6042,7 +7362,7 @@ var init_runnable_environment = __esm({
|
|
|
6042
7362
|
}
|
|
6043
7363
|
};
|
|
6044
7364
|
const importMeta = {
|
|
6045
|
-
url:
|
|
7365
|
+
url: pathToFileURL5(fetched.id.split("?")[0]).href,
|
|
6046
7366
|
env: { SSR: true, MODE: this.config.mode, DEV: this.config.mode !== "production", PROD: this.config.mode === "production" },
|
|
6047
7367
|
hot: void 0
|
|
6048
7368
|
};
|
|
@@ -6059,20 +7379,21 @@ var init_runnable_environment = __esm({
|
|
|
6059
7379
|
}
|
|
6060
7380
|
async importExternal(spec) {
|
|
6061
7381
|
try {
|
|
6062
|
-
return await (spec.startsWith("node:") || !
|
|
7382
|
+
return await (spec.startsWith("node:") || !path17.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import(pathToFileURL5(spec).href));
|
|
6063
7383
|
} catch (err) {
|
|
6064
7384
|
throw new Error(`[nasti:ssr] failed to import external "${spec}": ${err.message}`);
|
|
6065
7385
|
}
|
|
6066
7386
|
}
|
|
6067
|
-
/** bare specifier → 项目 node_modules
|
|
7387
|
+
/** bare specifier → 项目 node_modules 的 ESM URL(避免相对 Nasti 自身解析) */
|
|
6068
7388
|
resolveExternalSpecifier(spec) {
|
|
6069
7389
|
if (spec.startsWith("node:")) return spec;
|
|
6070
7390
|
if (NODE_BUILTINS3.has(spec)) return `node:${spec}`;
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
7391
|
+
return moduleResolve(
|
|
7392
|
+
spec,
|
|
7393
|
+
this.externalImportParent,
|
|
7394
|
+
this.externalImportConditions,
|
|
7395
|
+
false
|
|
7396
|
+
).href;
|
|
6076
7397
|
}
|
|
6077
7398
|
};
|
|
6078
7399
|
AsyncFunction = Object.getPrototypeOf(async function() {
|
|
@@ -6085,7 +7406,7 @@ var dev_engine_exports = {};
|
|
|
6085
7406
|
__export(dev_engine_exports, {
|
|
6086
7407
|
createBundledDevServer: () => createBundledDevServer
|
|
6087
7408
|
});
|
|
6088
|
-
import
|
|
7409
|
+
import path18 from "path";
|
|
6089
7410
|
import crypto3 from "crypto";
|
|
6090
7411
|
import { WebSocketServer as WsServer2 } from "ws";
|
|
6091
7412
|
import pc8 from "picocolors";
|
|
@@ -6170,7 +7491,7 @@ async function createBundledDevServer(opts) {
|
|
|
6170
7491
|
}
|
|
6171
7492
|
const url = `/${patchPath}`;
|
|
6172
7493
|
logger.info(
|
|
6173
|
-
pc8.green("hmr update ") + pc8.dim(changedFiles.map((f) =>
|
|
7494
|
+
pc8.green("hmr update ") + pc8.dim(changedFiles.map((f) => path18.relative(config.root, f)).join(", ")),
|
|
6174
7495
|
{ timestamp: true }
|
|
6175
7496
|
);
|
|
6176
7497
|
sendTo(clientId, { type: "hmr:update", path: url, url });
|
|
@@ -6325,7 +7646,7 @@ async function createBundledDevServer(opts) {
|
|
|
6325
7646
|
return;
|
|
6326
7647
|
}
|
|
6327
7648
|
res.setHeader("ETag", hit.etag);
|
|
6328
|
-
res.setHeader("Content-Type", MIME_TYPES[
|
|
7649
|
+
res.setHeader("Content-Type", MIME_TYPES[path18.extname(fileName)] ?? "application/octet-stream");
|
|
6329
7650
|
res.setHeader("Cache-Control", "no-cache");
|
|
6330
7651
|
res.once("finish", () => {
|
|
6331
7652
|
void engine.notifyPayloadDelivered(fileName).catch(
|
|
@@ -6366,7 +7687,7 @@ function stripCatchAllLoad(plugins) {
|
|
|
6366
7687
|
);
|
|
6367
7688
|
}
|
|
6368
7689
|
function createReactRefreshRuntimePlugin(entryPoints) {
|
|
6369
|
-
const entryIds = new Set(entryPoints.map((p) =>
|
|
7690
|
+
const entryIds = new Set(entryPoints.map((p) => path18.resolve(p)));
|
|
6370
7691
|
return {
|
|
6371
7692
|
name: "nasti:bundled-react-refresh",
|
|
6372
7693
|
resolveId(source) {
|
|
@@ -6384,7 +7705,7 @@ function createReactRefreshRuntimePlugin(entryPoints) {
|
|
|
6384
7705
|
return null;
|
|
6385
7706
|
},
|
|
6386
7707
|
transform(code, id) {
|
|
6387
|
-
if (!entryIds.has(
|
|
7708
|
+
if (!entryIds.has(path18.resolve(id.split("?")[0]))) return null;
|
|
6388
7709
|
return { code: `import ${JSON.stringify(PREAMBLE_SPEC)};
|
|
6389
7710
|
${code}`, map: null };
|
|
6390
7711
|
}
|
|
@@ -6558,7 +7879,7 @@ __export(server_exports, {
|
|
|
6558
7879
|
createServer: () => createServer
|
|
6559
7880
|
});
|
|
6560
7881
|
import http from "http";
|
|
6561
|
-
import
|
|
7882
|
+
import path19 from "path";
|
|
6562
7883
|
import os from "os";
|
|
6563
7884
|
import connect from "connect";
|
|
6564
7885
|
import sirv from "sirv";
|
|
@@ -6651,19 +7972,19 @@ async function createServer(inlineConfig = {}) {
|
|
|
6651
7972
|
app.use(bundledServer.middleware);
|
|
6652
7973
|
}
|
|
6653
7974
|
const ignoredSegments = /* @__PURE__ */ new Set(["node_modules", ".git", ".nasti"]);
|
|
6654
|
-
const outDirAbs =
|
|
7975
|
+
const outDirAbs = path19.resolve(config.root, config.build.outDir);
|
|
6655
7976
|
const linkedPackageRoots = getLinkedPackageRoots(config.root).filter(
|
|
6656
7977
|
(r) => r !== config.root && !isUnderRoot(config.root, r)
|
|
6657
7978
|
);
|
|
6658
7979
|
const watchTargets = [config.root, ...linkedPackageRoots];
|
|
6659
7980
|
const watcher = watch(watchTargets, {
|
|
6660
7981
|
ignored: (filePath) => {
|
|
6661
|
-
if (filePath === outDirAbs || filePath.startsWith(outDirAbs +
|
|
7982
|
+
if (filePath === outDirAbs || filePath.startsWith(outDirAbs + path19.sep)) return true;
|
|
6662
7983
|
for (const watchRoot of watchTargets) {
|
|
6663
7984
|
if (filePath === watchRoot) return false;
|
|
6664
|
-
const rel =
|
|
6665
|
-
if (!rel || rel.startsWith("..") ||
|
|
6666
|
-
for (const seg of rel.split(
|
|
7985
|
+
const rel = path19.relative(watchRoot, filePath);
|
|
7986
|
+
if (!rel || rel.startsWith("..") || path19.isAbsolute(rel)) continue;
|
|
7987
|
+
for (const seg of rel.split(path19.sep)) {
|
|
6667
7988
|
if (ignoredSegments.has(seg)) return true;
|
|
6668
7989
|
}
|
|
6669
7990
|
return false;
|
|
@@ -6795,7 +8116,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6795
8116
|
});
|
|
6796
8117
|
};
|
|
6797
8118
|
watcher.on("change", (file) => {
|
|
6798
|
-
if (file.includes(`${
|
|
8119
|
+
if (file.includes(`${path19.sep}node_modules${path19.sep}`) || file.endsWith(`${path19.sep}node_modules`)) {
|
|
6799
8120
|
clearLinkedPackageRootsCache();
|
|
6800
8121
|
}
|
|
6801
8122
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6803,7 +8124,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6803
8124
|
notifyEnvironmentDrivers(file, "change");
|
|
6804
8125
|
});
|
|
6805
8126
|
watcher.on("add", (file) => {
|
|
6806
|
-
if (file.includes(`${
|
|
8127
|
+
if (file.includes(`${path19.sep}node_modules${path19.sep}`) || file.endsWith(`${path19.sep}node_modules`)) {
|
|
6807
8128
|
clearLinkedPackageRootsCache();
|
|
6808
8129
|
}
|
|
6809
8130
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6811,7 +8132,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6811
8132
|
notifyEnvironmentDrivers(file, "add");
|
|
6812
8133
|
});
|
|
6813
8134
|
watcher.on("unlink", (file) => {
|
|
6814
|
-
if (file.includes(`${
|
|
8135
|
+
if (file.includes(`${path19.sep}node_modules${path19.sep}`) || file.endsWith(`${path19.sep}node_modules`)) {
|
|
6815
8136
|
clearLinkedPackageRootsCache();
|
|
6816
8137
|
}
|
|
6817
8138
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6843,7 +8164,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6843
8164
|
const readyIn = Math.ceil(performance.now() - startTime);
|
|
6844
8165
|
logger.info(
|
|
6845
8166
|
`
|
|
6846
|
-
${pc9.cyan(pc9.bold("NASTI"))} ${pc9.cyan(`v${"2.5.
|
|
8167
|
+
${pc9.cyan(pc9.bold("NASTI"))} ${pc9.cyan(`v${"2.5.1"}`)} ${pc9.dim("ready in")} ${pc9.bold(readyIn)} ${pc9.dim("ms")}
|
|
6847
8168
|
`
|
|
6848
8169
|
);
|
|
6849
8170
|
printServerUrls(
|
|
@@ -6940,7 +8261,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6940
8261
|
throw error;
|
|
6941
8262
|
}
|
|
6942
8263
|
app.use(transformMiddleware(transformContexts.get("client")));
|
|
6943
|
-
const publicDir =
|
|
8264
|
+
const publicDir = path19.resolve(config.root, "public");
|
|
6944
8265
|
app.use(sirv(publicDir, { dev: true, etag: true }));
|
|
6945
8266
|
app.use(sirv(config.root, { dev: true, etag: true }));
|
|
6946
8267
|
const postMiddlewares = [];
|
|
@@ -7036,7 +8357,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
7036
8357
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
7037
8358
|
const startTime = performance.now();
|
|
7038
8359
|
assertElectronVersion(config);
|
|
7039
|
-
console.log(pc5.cyan("\n\u26A1 nasti build (electron)") + pc5.dim(` v${"2.5.
|
|
8360
|
+
console.log(pc5.cyan("\n\u26A1 nasti build (electron)") + pc5.dim(` v${"2.5.1"}`));
|
|
7040
8361
|
console.log(pc5.dim(` root: ${config.root}`));
|
|
7041
8362
|
console.log(pc5.dim(` mode: ${config.mode}`));
|
|
7042
8363
|
console.log(pc5.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -7166,8 +8487,8 @@ function createElectronRendererConfig(config, inlineConfig = {}, overrides = {})
|
|
|
7166
8487
|
}
|
|
7167
8488
|
};
|
|
7168
8489
|
}
|
|
7169
|
-
function outFileName(outDir, base,
|
|
7170
|
-
const ext =
|
|
8490
|
+
function outFileName(outDir, base, format2) {
|
|
8491
|
+
const ext = format2 === "cjs" ? ".cjs" : ".mjs";
|
|
7171
8492
|
return path11.join(outDir, base + ext);
|
|
7172
8493
|
}
|
|
7173
8494
|
function normalizePreload(preload, root) {
|
|
@@ -7210,9 +8531,9 @@ init_server();
|
|
|
7210
8531
|
|
|
7211
8532
|
// src/server/electron-dev.ts
|
|
7212
8533
|
init_config();
|
|
7213
|
-
import
|
|
7214
|
-
import
|
|
7215
|
-
import { createRequire as
|
|
8534
|
+
import path20 from "path";
|
|
8535
|
+
import fs14 from "fs";
|
|
8536
|
+
import { createRequire as createRequire5 } from "module";
|
|
7216
8537
|
import { spawn } from "child_process";
|
|
7217
8538
|
import chokidar from "chokidar";
|
|
7218
8539
|
import pc10 from "picocolors";
|
|
@@ -7224,7 +8545,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7224
8545
|
const { noSpawn, ...rest } = inlineConfig;
|
|
7225
8546
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
7226
8547
|
warnElectronVersion(config);
|
|
7227
|
-
console.log(pc10.cyan("\n\u26A1 nasti electron dev") + pc10.dim(` v${"2.5.
|
|
8548
|
+
console.log(pc10.cyan("\n\u26A1 nasti electron dev") + pc10.dim(` v${"2.5.1"}`));
|
|
7228
8549
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
7229
8550
|
const server = await createServer2({
|
|
7230
8551
|
...rest,
|
|
@@ -7234,11 +8555,11 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7234
8555
|
await server.listen();
|
|
7235
8556
|
const devUrl = `http://localhost:${server.config.server.port}` + electronRendererDevPath(config.electron.renderer);
|
|
7236
8557
|
console.log(pc10.dim(` renderer: ${devUrl}`));
|
|
7237
|
-
const stageDir =
|
|
7238
|
-
|
|
7239
|
-
const mainEntry =
|
|
8558
|
+
const stageDir = path20.resolve(config.root, ".nasti");
|
|
8559
|
+
fs14.mkdirSync(stageDir, { recursive: true });
|
|
8560
|
+
const mainEntry = path20.resolve(config.root, config.electron.main);
|
|
7240
8561
|
const preloadEntries = normalizePreload(config.electron.preload, config.root);
|
|
7241
|
-
const builtMainFile =
|
|
8562
|
+
const builtMainFile = path20.join(stageDir, "main" + extFor(config.electron.mainFormat));
|
|
7242
8563
|
const builtPreloadFiles = [];
|
|
7243
8564
|
const compileAll = async () => {
|
|
7244
8565
|
await compileNode(config, mainEntry, {
|
|
@@ -7248,9 +8569,9 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7248
8569
|
});
|
|
7249
8570
|
builtPreloadFiles.length = 0;
|
|
7250
8571
|
for (const entry of preloadEntries) {
|
|
7251
|
-
if (!
|
|
7252
|
-
const base =
|
|
7253
|
-
const out =
|
|
8572
|
+
if (!fs14.existsSync(entry)) continue;
|
|
8573
|
+
const base = path20.basename(entry).replace(/\.[^.]+$/, "");
|
|
8574
|
+
const out = path20.join(stageDir, base + extFor(config.electron.preloadFormat));
|
|
7254
8575
|
await compileNode(config, entry, {
|
|
7255
8576
|
outFile: out,
|
|
7256
8577
|
format: config.electron.preloadFormat,
|
|
@@ -7289,7 +8610,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7289
8610
|
};
|
|
7290
8611
|
spawnElectron();
|
|
7291
8612
|
if (config.electron.autoRestart) {
|
|
7292
|
-
const watchTargets = [mainEntry, ...preloadEntries].filter(
|
|
8613
|
+
const watchTargets = [mainEntry, ...preloadEntries].filter(fs14.existsSync);
|
|
7293
8614
|
const watcher = chokidar.watch(watchTargets, { ignoreInitial: true });
|
|
7294
8615
|
let restarting = null;
|
|
7295
8616
|
let pending = false;
|
|
@@ -7336,8 +8657,8 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7336
8657
|
});
|
|
7337
8658
|
}
|
|
7338
8659
|
}
|
|
7339
|
-
function extFor(
|
|
7340
|
-
return
|
|
8660
|
+
function extFor(format2) {
|
|
8661
|
+
return format2 === "cjs" ? ".cjs" : ".mjs";
|
|
7341
8662
|
}
|
|
7342
8663
|
async function compileNode(config, entry, opts) {
|
|
7343
8664
|
const env = loadEnv(config.mode, config.root, config.envPrefix);
|
|
@@ -7376,7 +8697,7 @@ async function compileNode(config, entry, opts) {
|
|
|
7376
8697
|
platform: "node",
|
|
7377
8698
|
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
7378
8699
|
});
|
|
7379
|
-
|
|
8700
|
+
fs14.mkdirSync(path20.dirname(opts.outFile), { recursive: true });
|
|
7380
8701
|
await bundle2.write({
|
|
7381
8702
|
file: opts.outFile,
|
|
7382
8703
|
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
@@ -7389,18 +8710,18 @@ async function compileNode(config, entry, opts) {
|
|
|
7389
8710
|
await bundle2.close();
|
|
7390
8711
|
}
|
|
7391
8712
|
function electronRendererDevPath(renderer) {
|
|
7392
|
-
const normalized = renderer.split(
|
|
8713
|
+
const normalized = renderer.split(path20.sep).join("/").replace(/^\.?\//, "");
|
|
7393
8714
|
return normalized === "index.html" ? "/" : `/${normalized}`;
|
|
7394
8715
|
}
|
|
7395
8716
|
function resolveElectronBinary(config) {
|
|
7396
|
-
if (config.electron.electronPath &&
|
|
8717
|
+
if (config.electron.electronPath && fs14.existsSync(config.electron.electronPath)) {
|
|
7397
8718
|
return config.electron.electronPath;
|
|
7398
8719
|
}
|
|
7399
8720
|
try {
|
|
7400
|
-
const require2 =
|
|
8721
|
+
const require2 = createRequire5(path20.resolve(config.root, "package.json"));
|
|
7401
8722
|
const pathFile = require2.resolve("electron");
|
|
7402
8723
|
const electronModule = require2(pathFile);
|
|
7403
|
-
if (typeof electronModule === "string" &&
|
|
8724
|
+
if (typeof electronModule === "string" && fs14.existsSync(electronModule)) {
|
|
7404
8725
|
return electronModule;
|
|
7405
8726
|
}
|
|
7406
8727
|
} catch {
|
|
@@ -7427,10 +8748,10 @@ function warnElectronVersion(config) {
|
|
|
7427
8748
|
}
|
|
7428
8749
|
|
|
7429
8750
|
// src/plugins/monaco-editor.ts
|
|
7430
|
-
import
|
|
7431
|
-
import
|
|
8751
|
+
import path21 from "path";
|
|
8752
|
+
import fs15 from "fs";
|
|
7432
8753
|
import crypto4 from "crypto";
|
|
7433
|
-
import { createRequire as
|
|
8754
|
+
import { createRequire as createRequire6 } from "module";
|
|
7434
8755
|
var DEFAULT_WORKERS = {
|
|
7435
8756
|
editorWorkerService: "monaco-editor/esm/vs/editor/editor.worker",
|
|
7436
8757
|
css: "monaco-editor/esm/vs/language/css/css.worker",
|
|
@@ -7449,9 +8770,9 @@ function normalizePublicPath(p) {
|
|
|
7449
8770
|
}
|
|
7450
8771
|
function readMonacoVersion(root) {
|
|
7451
8772
|
try {
|
|
7452
|
-
const require2 =
|
|
8773
|
+
const require2 = createRequire6(path21.resolve(root, "package.json"));
|
|
7453
8774
|
const pkgJsonPath = require2.resolve("monaco-editor/package.json", { paths: [root] });
|
|
7454
|
-
const pkg = JSON.parse(
|
|
8775
|
+
const pkg = JSON.parse(fs15.readFileSync(pkgJsonPath, "utf-8"));
|
|
7455
8776
|
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
7456
8777
|
} catch {
|
|
7457
8778
|
return "unknown";
|
|
@@ -7471,20 +8792,20 @@ function monacoEditorPlugin(options = {}) {
|
|
|
7471
8792
|
let cacheDir = "";
|
|
7472
8793
|
const building = /* @__PURE__ */ new Map();
|
|
7473
8794
|
async function buildWorker(worker) {
|
|
7474
|
-
const cacheFile =
|
|
7475
|
-
if (
|
|
8795
|
+
const cacheFile = path21.join(cacheDir, `${worker.label}.worker.js`);
|
|
8796
|
+
if (fs15.existsSync(cacheFile)) return cacheFile;
|
|
7476
8797
|
const existing = building.get(worker.label);
|
|
7477
8798
|
if (existing) return existing;
|
|
7478
8799
|
const task = (async () => {
|
|
7479
8800
|
const { rolldown: rolldown4 } = await import("rolldown");
|
|
7480
|
-
const require2 =
|
|
8801
|
+
const require2 = createRequire6(path21.resolve(resolvedConfig.root, "package.json"));
|
|
7481
8802
|
let entry;
|
|
7482
8803
|
try {
|
|
7483
8804
|
entry = require2.resolve(worker.entry, { paths: [resolvedConfig.root] });
|
|
7484
8805
|
} catch {
|
|
7485
8806
|
entry = require2.resolve(worker.entry + ".js", { paths: [resolvedConfig.root] });
|
|
7486
8807
|
}
|
|
7487
|
-
|
|
8808
|
+
fs15.mkdirSync(cacheDir, { recursive: true });
|
|
7488
8809
|
const bundle2 = await rolldown4({
|
|
7489
8810
|
input: entry,
|
|
7490
8811
|
platform: "browser"
|
|
@@ -7544,15 +8865,15 @@ function monacoEditorPlugin(options = {}) {
|
|
|
7544
8865
|
resolvedConfig = config;
|
|
7545
8866
|
const version = readMonacoVersion(config.root);
|
|
7546
8867
|
const key = crypto4.createHash("sha1").update(version + "|" + publicPath).digest("hex").slice(0, 8);
|
|
7547
|
-
cacheDir =
|
|
8868
|
+
cacheDir = path21.resolve(config.root, "node_modules/.nasti/monaco", key);
|
|
7548
8869
|
},
|
|
7549
8870
|
async configureServer(server) {
|
|
7550
8871
|
const shouldBuild = !isCDN(publicPath) || forceBuildCDN;
|
|
7551
8872
|
const watcher = server.watcher;
|
|
7552
|
-
const monacoLogical =
|
|
8873
|
+
const monacoLogical = path21.resolve(resolvedConfig.root, "node_modules/monaco-editor");
|
|
7553
8874
|
const monacoPaths = /* @__PURE__ */ new Set([monacoLogical]);
|
|
7554
8875
|
try {
|
|
7555
|
-
monacoPaths.add(
|
|
8876
|
+
monacoPaths.add(fs15.realpathSync(monacoLogical));
|
|
7556
8877
|
} catch {
|
|
7557
8878
|
}
|
|
7558
8879
|
for (const monacoDir of monacoPaths) {
|
|
@@ -7586,7 +8907,7 @@ function monacoEditorPlugin(options = {}) {
|
|
|
7586
8907
|
const file = await buildWorker(worker);
|
|
7587
8908
|
res.setHeader("Content-Type", "application/javascript; charset=utf-8");
|
|
7588
8909
|
res.setHeader("Cache-Control", "public, max-age=604800, immutable");
|
|
7589
|
-
|
|
8910
|
+
fs15.createReadStream(file).pipe(res);
|
|
7590
8911
|
} catch (e) {
|
|
7591
8912
|
res.statusCode = 500;
|
|
7592
8913
|
res.end(`Monaco worker build failed: ${e.message}`);
|
|
@@ -7621,16 +8942,16 @@ self.monaco = monaco;`,
|
|
|
7621
8942
|
resolvedConfig.root,
|
|
7622
8943
|
resolvedConfig.build.outDir,
|
|
7623
8944
|
resolvedConfig.base
|
|
7624
|
-
) : isCDN(publicPath) ?
|
|
8945
|
+
) : isCDN(publicPath) ? path21.resolve(resolvedConfig.root, resolvedConfig.build.outDir, "monaco") : path21.resolve(
|
|
7625
8946
|
resolvedConfig.root,
|
|
7626
8947
|
resolvedConfig.build.outDir,
|
|
7627
8948
|
publicPath.replace(/^\//, "")
|
|
7628
8949
|
);
|
|
7629
|
-
|
|
8950
|
+
fs15.mkdirSync(outDir, { recursive: true });
|
|
7630
8951
|
for (const worker of workers) {
|
|
7631
8952
|
try {
|
|
7632
8953
|
const cacheFile = await buildWorker(worker);
|
|
7633
|
-
|
|
8954
|
+
fs15.copyFileSync(cacheFile, path21.join(outDir, `${worker.label}.worker.js`));
|
|
7634
8955
|
} catch (e) {
|
|
7635
8956
|
throw new Error(
|
|
7636
8957
|
`[nasti:monaco-editor] worker build failed for "${worker.label}": ${e.message}
|
|
@@ -7644,8 +8965,8 @@ ${e.stack || ""}`
|
|
|
7644
8965
|
|
|
7645
8966
|
// src/plugins/rsc.ts
|
|
7646
8967
|
init_transformer();
|
|
7647
|
-
import
|
|
7648
|
-
import
|
|
8968
|
+
import fs16 from "fs";
|
|
8969
|
+
import path22 from "path";
|
|
7649
8970
|
import { parseSync } from "oxc-parser";
|
|
7650
8971
|
var SERVER_RUNTIME_ID = "virtual:nasti-rsc/server-runtime";
|
|
7651
8972
|
var CLIENT_RUNTIME_ID = "virtual:nasti-rsc/client-runtime";
|
|
@@ -7664,7 +8985,7 @@ function rsc(options = {}) {
|
|
|
7664
8985
|
name: "nasti:rsc",
|
|
7665
8986
|
enforce: "post",
|
|
7666
8987
|
config(config, env) {
|
|
7667
|
-
const root =
|
|
8988
|
+
const root = path22.resolve(config.root ?? ".");
|
|
7668
8989
|
const include = options.include ?? config.react?.include ?? /\.[tj]sx?$/;
|
|
7669
8990
|
const exclude = options.exclude ?? config.react?.exclude ?? /node_modules/;
|
|
7670
8991
|
const discoveredClients = env.command === "build" ? discoverDirectiveModules(root, options.scanDirectories, include, exclude) : [];
|
|
@@ -7916,21 +9237,21 @@ function manifestReferences(root, result, references) {
|
|
|
7916
9237
|
}
|
|
7917
9238
|
function discoverDirectiveModules(root, scanDirectories, include, exclude) {
|
|
7918
9239
|
const requested = scanDirectories ?? ["app", "src"];
|
|
7919
|
-
const roots = requested.map((directory) =>
|
|
9240
|
+
const roots = requested.map((directory) => path22.resolve(root, directory)).filter((directory) => fs16.existsSync(directory));
|
|
7920
9241
|
if (roots.length === 0) roots.push(root);
|
|
7921
9242
|
const output = [];
|
|
7922
9243
|
for (const directory of roots) walk(directory);
|
|
7923
9244
|
return output;
|
|
7924
9245
|
function walk(directory) {
|
|
7925
|
-
for (const entry of
|
|
9246
|
+
for (const entry of fs16.readdirSync(directory, { withFileTypes: true })) {
|
|
7926
9247
|
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".nasti") continue;
|
|
7927
|
-
const id =
|
|
9248
|
+
const id = path22.join(directory, entry.name);
|
|
7928
9249
|
if (entry.isDirectory()) {
|
|
7929
9250
|
walk(id);
|
|
7930
9251
|
continue;
|
|
7931
9252
|
}
|
|
7932
9253
|
if (!entry.isFile() || !matchesReactFilter(id, include, exclude)) continue;
|
|
7933
|
-
const module = scanModule(id,
|
|
9254
|
+
const module = scanModule(id, fs16.readFileSync(id, "utf-8"));
|
|
7934
9255
|
if (module) output.push({ id, module });
|
|
7935
9256
|
}
|
|
7936
9257
|
}
|
|
@@ -7941,15 +9262,15 @@ function collectClientSeeds(root, config, client, configured) {
|
|
|
7941
9262
|
...normalizeEntries(configured)
|
|
7942
9263
|
];
|
|
7943
9264
|
if (explicit.length > 0) return explicit;
|
|
7944
|
-
const htmlFile =
|
|
7945
|
-
if (
|
|
7946
|
-
const html =
|
|
7947
|
-
const htmlDir =
|
|
7948
|
-
const entries = [...html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi)].map((match) => match[1]?.split(/[?#]/, 1)[0]).filter((entry) => !!entry && !entry.startsWith("http")).map((entry) => entry.startsWith("/") ?
|
|
9265
|
+
const htmlFile = path22.resolve(root, client.html ?? "index.html");
|
|
9266
|
+
if (fs16.existsSync(htmlFile)) {
|
|
9267
|
+
const html = fs16.readFileSync(htmlFile, "utf-8");
|
|
9268
|
+
const htmlDir = path22.dirname(htmlFile);
|
|
9269
|
+
const entries = [...html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi)].map((match) => match[1]?.split(/[?#]/, 1)[0]).filter((entry) => !!entry && !entry.startsWith("http")).map((entry) => entry.startsWith("/") ? path22.resolve(root, entry.slice(1)) : path22.resolve(htmlDir, entry));
|
|
7949
9270
|
if (entries.length > 0) return entries;
|
|
7950
9271
|
}
|
|
7951
9272
|
for (const entry of ["src/main.ts", "src/main.tsx", "src/main.js", "src/index.ts", "src/index.tsx", "src/index.js"]) {
|
|
7952
|
-
if (
|
|
9273
|
+
if (fs16.existsSync(path22.resolve(root, entry))) return [entry];
|
|
7953
9274
|
}
|
|
7954
9275
|
return [];
|
|
7955
9276
|
}
|
|
@@ -7970,9 +9291,9 @@ function cleanModuleId(id) {
|
|
|
7970
9291
|
return id.split(/[?#]/, 1)[0];
|
|
7971
9292
|
}
|
|
7972
9293
|
function referenceModuleId(root, id) {
|
|
7973
|
-
if (!root || !
|
|
7974
|
-
const relative =
|
|
7975
|
-
return relative.startsWith("../") ? id.replaceAll(
|
|
9294
|
+
if (!root || !path22.isAbsolute(id)) return id.replaceAll(path22.sep, "/");
|
|
9295
|
+
const relative = path22.relative(root, id).replaceAll(path22.sep, "/");
|
|
9296
|
+
return relative.startsWith("../") ? id.replaceAll(path22.sep, "/") : `/${relative}`;
|
|
7976
9297
|
}
|
|
7977
9298
|
function displayId(root, id) {
|
|
7978
9299
|
return referenceModuleId(root, id);
|