@zntc/core 0.1.1 → 0.1.3
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/README.md +35 -25
- package/bin/cli-flags.mjs +16 -0
- package/bin/rn-dev-input.mjs +11 -0
- package/bin/zntc.mjs +816 -48
- package/dist/core/index.d.cts +300 -3
- package/dist/core/index.d.ts +300 -3
- package/dist/core/src/config-loader.d.ts +1 -1
- package/dist/core/src/schema-allowlists.d.ts +2 -2
- package/dist/index.cjs +283 -82
- package/dist/index.js +361 -83
- package/dist/shared/compat-engines.d.ts +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -15,7 +15,7 @@ function formatSupportedPlatforms() {
|
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region compat-engines.ts
|
|
18
|
-
const FEATURES = ["arrow", "class", "template_literal", "destructuring", "for_of", "spread", "object_extensions", "default_params", "block_scoping", "generator", "new_target", "exponentiation", "async_await", "object_spread", "optional_catch_binding", "nullish_coalescing", "optional_chaining", "logical_assignment", "class_static_block", "class_private_method", "class_private_field", "top_level_await", "hashbang", "using", "regex_sticky", "regex_dotall", "regex_named_groups", "unicode_brace_escape"],SUPPORT = { arrow: { chrome: [45, 0], firefox: [22, 0], safari: [10, 0], edge: [12, 0], node: [4, 0], deno: [1, 0], ios: [10, 0] }, class: { chrome: [49, 0], firefox: [45, 0], safari: [10, 1], edge: [13, 0], node: [6, 0], deno: [1, 0], ios: [10, 3] }, template_literal: { chrome: [41, 0], firefox: [34, 0], safari: [9, 0], edge: [12, 0], node: [4, 0], deno: [1, 0], ios: [9, 0] }, destructuring: { chrome: [49, 0], firefox: [41, 0], safari: [8, 0], edge: [14, 0], node: [6, 0], deno: [1, 0], ios: [8, 0] }, for_of: { chrome: [38, 0], firefox: [13, 0], safari: [7, 0], edge: [12, 0], node: [0, 12], deno: [1, 0], ios: [7, 0], hermes: [0, 7] }, spread: { chrome: [46, 0], firefox: [27, 0], safari: [10, 0], edge: [13, 0], node: [5, 0], deno: [1, 0], ios: [10, 0], hermes: [0, 7] }, object_extensions: { chrome: [43, 0], firefox: [34, 0], safari: [9, 0], edge: [12, 0], node: [4, 0], deno: [1, 0], ios: [9, 0], hermes: [0, 7] }, default_params: { chrome: [49, 0], firefox: [15, 0], safari: [10, 0], edge: [14, 0], node: [6, 0], deno: [1, 0], ios: [10, 0] }, block_scoping: { chrome: [49, 0], firefox: [51, 0], safari: [11, 0], edge: [14, 0], node: [6, 0], deno: [1, 0], ios: [11, 0] }, generator: { chrome: [50, 0], firefox: [53, 0], safari: [10, 0], edge: [13, 0], node: [6, 0], deno: [1, 0], ios: [10, 0] }, new_target: { chrome: [46, 0], firefox: [41, 0], safari: [10, 0], edge: [14, 0], node: [5, 0], deno: [1, 0], ios: [10, 0] }, exponentiation: { chrome: [52, 0], firefox: [52, 0], safari: [10, 1], edge: [14, 0], node: [7, 0], deno: [1, 0], ios: [10, 3], hermes: [0, 7] }, async_await: { chrome: [55, 0], firefox: [52, 0], safari: [11, 0], edge: [15, 0], node: [7, 6], deno: [1, 0], ios: [11, 0] }, object_spread: { chrome: [60, 0], firefox: [55, 0], safari: [11, 1], edge: [79, 0], node: [8, 3], deno: [1, 0], ios: [11, 3], hermes: [0, 7] }, optional_catch_binding: { chrome: [66, 0], firefox: [58, 0], safari: [11, 1], edge: [79, 0], node: [10, 0], deno: [1, 0], ios: [11, 3], hermes: [0, 12] }, nullish_coalescing: { chrome: [80, 0], firefox: [72, 0], safari: [13, 1], edge: [80, 0], node: [14, 0], deno: [1, 0], ios: [13, 4], hermes: [0, 7] }, optional_chaining: { chrome: [91, 0], firefox: [74, 0], safari: [13, 1], edge: [91, 0], node: [16, 9], deno: [1, 9], ios: [13, 4], hermes: [0, 12] }, logical_assignment: { chrome: [85, 0], firefox: [79, 0], safari: [14, 0], edge: [85, 0], node: [15, 0], deno: [1, 2], ios: [14, 0], hermes: [0, 7] }, class_static_block: { chrome: [94, 0], firefox: [93, 0], safari: [16, 4], edge: [94, 0], node: [16, 11], deno: [1, 14], ios: [16, 4] }, class_private_method: { chrome: [84, 0], firefox: [90, 0], safari: [15, 0], edge: [84, 0], node: [14, 6], deno: [1, 0], ios: [15, 0] }, class_private_field: { chrome: [74, 0], firefox: [90, 0], safari: [14, 1], edge: [79, 0], node: [12, 0], deno: [1, 0], ios: [14, 5] }, hashbang: { chrome: [74, 0], firefox: [67, 0], safari: [13, 1], edge: [79, 0], node: [12, 0], deno: [1, 0], ios: [13, 4], hermes: [0, 7] }, using: {} };
|
|
18
|
+
const FEATURES = ["arrow", "class", "template_literal", "destructuring", "for_of", "spread", "object_extensions", "default_params", "block_scoping", "generator", "new_target", "exponentiation", "async_await", "object_spread", "optional_catch_binding", "nullish_coalescing", "optional_chaining", "logical_assignment", "class_static_block", "class_private_method", "class_private_field", "top_level_await", "hashbang", "using", "regex_sticky", "regex_dotall", "regex_named_groups", "unicode_brace_escape", "regex_duplicate_named_groups", "regex_modifiers", "regex_lookbehind"],SUPPORT = { arrow: { chrome: [45, 0], firefox: [22, 0], safari: [10, 0], edge: [12, 0], node: [4, 0], deno: [1, 0], ios: [10, 0] }, class: { chrome: [49, 0], firefox: [45, 0], safari: [10, 1], edge: [13, 0], node: [6, 0], deno: [1, 0], ios: [10, 3] }, template_literal: { chrome: [41, 0], firefox: [34, 0], safari: [9, 0], edge: [12, 0], node: [4, 0], deno: [1, 0], ios: [9, 0] }, destructuring: { chrome: [49, 0], firefox: [41, 0], safari: [8, 0], edge: [14, 0], node: [6, 0], deno: [1, 0], ios: [8, 0] }, for_of: { chrome: [38, 0], firefox: [13, 0], safari: [7, 0], edge: [12, 0], node: [0, 12], deno: [1, 0], ios: [7, 0], hermes: [0, 7] }, spread: { chrome: [46, 0], firefox: [27, 0], safari: [10, 0], edge: [13, 0], node: [5, 0], deno: [1, 0], ios: [10, 0], hermes: [0, 7] }, object_extensions: { chrome: [43, 0], firefox: [34, 0], safari: [9, 0], edge: [12, 0], node: [4, 0], deno: [1, 0], ios: [9, 0], hermes: [0, 7] }, default_params: { chrome: [49, 0], firefox: [15, 0], safari: [10, 0], edge: [14, 0], node: [6, 0], deno: [1, 0], ios: [10, 0] }, block_scoping: { chrome: [49, 0], firefox: [51, 0], safari: [11, 0], edge: [14, 0], node: [6, 0], deno: [1, 0], ios: [11, 0] }, generator: { chrome: [50, 0], firefox: [53, 0], safari: [10, 0], edge: [13, 0], node: [6, 0], deno: [1, 0], ios: [10, 0] }, new_target: { chrome: [46, 0], firefox: [41, 0], safari: [10, 0], edge: [14, 0], node: [5, 0], deno: [1, 0], ios: [10, 0] }, exponentiation: { chrome: [52, 0], firefox: [52, 0], safari: [10, 1], edge: [14, 0], node: [7, 0], deno: [1, 0], ios: [10, 3], hermes: [0, 7] }, async_await: { chrome: [55, 0], firefox: [52, 0], safari: [11, 0], edge: [15, 0], node: [7, 6], deno: [1, 0], ios: [11, 0] }, object_spread: { chrome: [60, 0], firefox: [55, 0], safari: [11, 1], edge: [79, 0], node: [8, 3], deno: [1, 0], ios: [11, 3], hermes: [0, 7] }, optional_catch_binding: { chrome: [66, 0], firefox: [58, 0], safari: [11, 1], edge: [79, 0], node: [10, 0], deno: [1, 0], ios: [11, 3], hermes: [0, 12] }, nullish_coalescing: { chrome: [80, 0], firefox: [72, 0], safari: [13, 1], edge: [80, 0], node: [14, 0], deno: [1, 0], ios: [13, 4], hermes: [0, 7] }, optional_chaining: { chrome: [91, 0], firefox: [74, 0], safari: [13, 1], edge: [91, 0], node: [16, 9], deno: [1, 9], ios: [13, 4], hermes: [0, 12] }, logical_assignment: { chrome: [85, 0], firefox: [79, 0], safari: [14, 0], edge: [85, 0], node: [15, 0], deno: [1, 2], ios: [14, 0], hermes: [0, 7] }, class_static_block: { chrome: [94, 0], firefox: [93, 0], safari: [16, 4], edge: [94, 0], node: [16, 11], deno: [1, 14], ios: [16, 4] }, class_private_method: { chrome: [84, 0], firefox: [90, 0], safari: [15, 0], edge: [84, 0], node: [14, 6], deno: [1, 0], ios: [15, 0] }, class_private_field: { chrome: [74, 0], firefox: [90, 0], safari: [14, 1], edge: [79, 0], node: [12, 0], deno: [1, 0], ios: [14, 5] }, hashbang: { chrome: [74, 0], firefox: [67, 0], safari: [13, 1], edge: [79, 0], node: [12, 0], deno: [1, 0], ios: [13, 4], hermes: [0, 7] }, using: {}, regex_duplicate_named_groups: { chrome: [125, 0], edge: [125, 0], firefox: [129, 0], safari: [17, 4], ios: [17, 4], node: [23, 0], deno: [1, 44] }, regex_modifiers: { chrome: [125, 0], edge: [125, 0], firefox: [132, 0], safari: [26, 0], ios: [26, 0], node: [23, 0], deno: [1, 44] }, regex_lookbehind: { chrome: [62, 0], edge: [79, 0], firefox: [78, 0], safari: [16, 4], ios: [16, 4], node: [8, 10], deno: [1, 0] } };
|
|
19
19
|
function verGte(a,b) {
|
|
20
20
|
if (a[0] !== b[0])return a[0] > b[0];
|
|
21
21
|
return a[1] >= b[1];
|
|
@@ -42,7 +42,7 @@ function computeUnsupportedFromEngines(engines) {
|
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region index.ts
|
|
45
|
-
const ES_TARGET_BITS = { es5:
|
|
45
|
+
const ES_TARGET_BITS = { es5: 0x7fffffff, es2015: 0x76fff800, es2016: 0x76fff000, es2017: 0x76ffe000, es2018: 0x30ffc000, es2019: 0x30ff8000, es2020: 0x30fe0000, es2021: 0x30fc0000, es2022: 0x30c00000, es2023: 0x30800000, es2024: 0x30800000, es2025: 0x0, esnext: 0x0 };
|
|
46
46
|
function isPlainObject(value) {
|
|
47
47
|
return value !== null && typeof value == "object" && !Array.isArray(value);
|
|
48
48
|
}
|
|
@@ -102,7 +102,7 @@ function parseBrowserslistEntry(entry) {
|
|
|
102
102
|
if (!m)return null;
|
|
103
103
|
const name = m[1].toLowerCase();
|
|
104
104
|
;
|
|
105
|
-
const [majStr, minStr="0"] =
|
|
105
|
+
const [majStr, minStr="0"] = m[2].split("."),major = parseInt(majStr, 10),minor = parseInt(minStr, 10);
|
|
106
106
|
if (Number.isNaN(major))return null;
|
|
107
107
|
;
|
|
108
108
|
const engine = { chrome: "chrome", and_chr: "chrome", firefox: "firefox", and_ff: "firefox", safari: "safari", ios_saf: "ios", edge: "edge", node: "node", deno: "deno", opera: "opera", op_mob: "opera", hermes: "hermes" }[name];
|
|
@@ -343,7 +343,7 @@ async function resolveConfigValue(raw,env,absPath) {
|
|
|
343
343
|
async function loadModuleDefault(absPath,kind,options) {
|
|
344
344
|
const allowArray = options?.allowArray === true,ext = extname(absPath).toLowerCase();
|
|
345
345
|
if (ext === ".json") {
|
|
346
|
-
const raw = readFileOrThrowNotFound(absPath);
|
|
346
|
+
const raw = readFileOrThrowNotFound(absPath, kind);
|
|
347
347
|
try {
|
|
348
348
|
return JSON.parse(raw);
|
|
349
349
|
} catch (err) {
|
|
@@ -352,7 +352,7 @@ async function loadModuleDefault(absPath,kind,options) {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
if (TS_EXTS.has(ext)) {
|
|
355
|
-
return
|
|
355
|
+
return await loadTsModule(absPath, kind, allowArray);
|
|
356
356
|
}
|
|
357
357
|
if (JS_EXTS.has(ext)) {
|
|
358
358
|
try {
|
|
@@ -368,7 +368,7 @@ async function loadModuleDefault(absPath,kind,options) {
|
|
|
368
368
|
}
|
|
369
369
|
async function loadTsModule(absPath,kind,allowArray) {
|
|
370
370
|
init();
|
|
371
|
-
const source = readFileOrThrowNotFound(absPath),parseFilename = absPath.endsWith(".cts") ? absPath.slice(0, -4) + ".ts" : absPath,result = transpile(source, { filename: parseFilename, format: "esm" });
|
|
371
|
+
const source = readFileOrThrowNotFound(absPath, kind),parseFilename = absPath.endsWith(".cts") ? absPath.slice(0, -4) + ".ts" : absPath,result = transpile(source, { filename: parseFilename, format: "esm" });
|
|
372
372
|
if (result.errors) {
|
|
373
373
|
throw new Error(`@zntc/core: ${kind} compile failed in ${absPath}\n${result.errors}`);
|
|
374
374
|
}
|
|
@@ -402,16 +402,16 @@ async function importAndResolveDefault(absPath,options) {
|
|
|
402
402
|
;
|
|
403
403
|
if (valueType !== "function" && !(valueType === "object" && value !== null && (allowArray || !isArray))) {
|
|
404
404
|
;
|
|
405
|
-
throw new Error(`@zntc/core: module must be an object or function (got ${
|
|
405
|
+
throw new Error(`@zntc/core: module must be an object or function (got ${value === null ? "null" : isArray ? "array" : valueType}) from ${absPath}`);
|
|
406
406
|
}
|
|
407
407
|
return value;
|
|
408
408
|
}
|
|
409
|
-
function readFileOrThrowNotFound(absPath) {
|
|
409
|
+
function readFileOrThrowNotFound(absPath,kind) {
|
|
410
410
|
try {
|
|
411
411
|
return readFileSync$1(absPath, "utf8");
|
|
412
412
|
} catch (err) {
|
|
413
413
|
if (err.code === "ENOENT") {
|
|
414
|
-
throw new Error(`@zntc/core:
|
|
414
|
+
throw new Error(`@zntc/core: ${kind} file not found: ${absPath}`);
|
|
415
415
|
}
|
|
416
416
|
throw err;
|
|
417
417
|
}
|
|
@@ -460,6 +460,7 @@ function mergeUserConfigs(base,mode) {
|
|
|
460
460
|
}
|
|
461
461
|
//#endregion
|
|
462
462
|
//#region load-env.ts
|
|
463
|
+
var join$1 = require("node:path").join;
|
|
463
464
|
var pathResolve$1 = require("node:path").resolve;
|
|
464
465
|
function parseDotenvLine(line) {
|
|
465
466
|
const trimmed = line.trim();
|
|
@@ -469,7 +470,7 @@ function parseDotenvLine(line) {
|
|
|
469
470
|
const key = trimmed.slice(0, eqIdx).trim();
|
|
470
471
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))return null;
|
|
471
472
|
let value = trimmed.slice(eqIdx + 1).trim();
|
|
472
|
-
const quoted =
|
|
473
|
+
const quoted = value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'");
|
|
473
474
|
if (quoted) {
|
|
474
475
|
value = value.slice(1, -1);
|
|
475
476
|
} else {
|
|
@@ -490,7 +491,7 @@ function parseDotenvFile(filePath) {
|
|
|
490
491
|
function loadEnv(mode,envDir,prefixes=["VITE_", "ZNTC_"]) {
|
|
491
492
|
const prefixList = Array.isArray(prefixes) ? prefixes : [prefixes],dir = pathResolve$1(envDir),files = [`.env`, `.env.local`, `.env.${mode}`, `.env.${mode}.local`],merged = {};
|
|
492
493
|
for (const file of files) {
|
|
493
|
-
Object.assign(merged, parseDotenvFile(
|
|
494
|
+
Object.assign(merged, parseDotenvFile(join$1(dir, file)));
|
|
494
495
|
}
|
|
495
496
|
const filtered = {};
|
|
496
497
|
for (const [key, value] of Object.entries(merged)) {
|
|
@@ -534,7 +535,7 @@ function suggestKey(unknown,known,threshold=2) {
|
|
|
534
535
|
for (const candidate of known) {
|
|
535
536
|
const d = levenshtein(unknown, candidate);
|
|
536
537
|
if (d > adjusted)continue;
|
|
537
|
-
if (d < bestDist ||
|
|
538
|
+
if (d < bestDist || d === bestDist && best !== null && candidate < best) {
|
|
538
539
|
best = candidate;
|
|
539
540
|
bestDist = d;
|
|
540
541
|
}
|
|
@@ -554,14 +555,14 @@ function warnUnknownKeys(config,known,options={}) {
|
|
|
554
555
|
}
|
|
555
556
|
return result;
|
|
556
557
|
}
|
|
557
|
-
const KNOWN_CONFIG_KEYS = ["entryPoints", "outdir", "outfile", "outbase", "format", "platform", "target", "browserslist", "runtimePolyfills", "coreJs", "jsx", "jsxDev", "jsxFactory", "jsxFragment", "jsxImportSource", "jsxInJs", "jsxSideEffects", "minify", "minifyWhitespace", "minifyIdentifiers", "minifySyntax", "sourcemap", "sourcemapMode", "sourcemapDebugIds", "sourcesContent", "sourceRoot", "external", "alias", "define", "server", "loader", "conditions", "nodePaths", "moduleSpecifierMap", "resolveExtensions", "mainFields", "packagesExternal", "preserveSymlinks", "resolveSymlinkSiblings", "disableHierarchicalLookup", "splitting", "outputExports", "preserveModules", "preserveModulesRoot", "inlineDynamicImports", "manualChunks", "minChunkSize", "metafile", "treeShaking", "shimMissingExports", "keepNames", "drop", "dropConsole", "dropDebugger", "dropLabels", "banner", "footer", "intro", "outro", "inject", "pure", "legalComments", "entryNames", "chunkNames", "assetNames", "experimentalDecorators", "emitDecoratorMetadata", "useDefineForClassFields", "verbatimModuleSyntax", "tsconfigPath", "tsconfigRaw", "globalName", "globals", "publicPath", "charsetUtf8", "asciiOnly", "quotes", "compiler", "mf", "flow", "plugins", "logLevel", "logLimit", "lineLimit", "profile", "profileFormat", "profileLevel", "tokenizeFormat", "stopAfter", "ignoreAnnotations", "watchDelay", "jobs", "codegenTransform", "extends", "root", "projectRoot", "entry", "dev", "outDir", "bundler", "resolver", "transformer", "serializer", "symbolicator", "watchFolders"];
|
|
558
|
+
const KNOWN_CONFIG_KEYS = ["entryPoints", "output", "outdir", "outfile", "outbase", "format", "platform", "target", "rnVersion", "diskCache", "cacheDir", "browserslist", "runtimePolyfills", "coreJs", "jsx", "jsxDev", "jsxFactory", "jsxFragment", "jsxImportSource", "jsxInJs", "jsxSideEffects", "minify", "minifyWhitespace", "minifyIdentifiers", "minifySyntax", "sourcemap", "sourcemapMode", "sourcemapDebugIds", "sourcesContent", "sourceRoot", "external", "alias", "aliasExact", "define", "server", "loader", "conditions", "nodePaths", "moduleSpecifierMap", "resolveExtensions", "mainFields", "packagesExternal", "preserveSymlinks", "resolveSymlinkSiblings", "disableHierarchicalLookup", "splitting", "outputExports", "preserveModules", "preserveModulesRoot", "inlineDynamicImports", "manualChunks", "minChunkSize", "metafile", "treeShaking", "shimMissingExports", "keepNames", "drop", "dropConsole", "dropDebugger", "dropLabels", "banner", "footer", "intro", "outro", "inject", "pure", "legalComments", "entryNames", "chunkNames", "assetNames", "assetInlineLimit", "cssNames", "experimentalDecorators", "emitDecoratorMetadata", "useDefineForClassFields", "verbatimModuleSyntax", "tsconfigPath", "tsconfigRaw", "globalName", "globals", "publicPath", "charsetUtf8", "asciiOnly", "quotes", "compiler", "mf", "flow", "plugins", "logLevel", "logLimit", "lineLimit", "profile", "profileFormat", "profileLevel", "tokenizeFormat", "stopAfter", "ignoreAnnotations", "watchDelay", "jobs", "codegenTransform", "lazyCompilation", "lazyForceParse", "preserveSafePlugins", "extends", "root", "projectRoot", "entry", "dev", "outDir", "bundler", "resolver", "transformer", "serializer", "symbolicator", "watchFolders"];
|
|
558
559
|
//#endregion
|
|
559
560
|
//#region workspace.ts
|
|
560
561
|
var existsSync$1 = require("node:fs").existsSync;
|
|
561
562
|
var readdirSync = require("node:fs").readdirSync;
|
|
562
563
|
var readFileSync$2 = require("node:fs").readFileSync;
|
|
563
564
|
var basename = require("node:path").basename;
|
|
564
|
-
var join$
|
|
565
|
+
var join$2 = require("node:path").join;
|
|
565
566
|
var pathResolve$2 = require("node:path").resolve;
|
|
566
567
|
var CONFIG_EXT_PRIORITY_LOCAL = [".ts", ".mts", ".cts", ".mjs", ".js", ".cjs", ".json"];
|
|
567
568
|
function defineWorkspace(input) {
|
|
@@ -570,7 +571,7 @@ function defineWorkspace(input) {
|
|
|
570
571
|
var WORKSPACE_EXT_PRIORITY = CONFIG_EXT_PRIORITY_LOCAL;
|
|
571
572
|
function findWorkspacePath(cwd) {
|
|
572
573
|
for (const ext of WORKSPACE_EXT_PRIORITY) {
|
|
573
|
-
const p = join$
|
|
574
|
+
const p = join$2(cwd, `zntc.workspace${ext}`);
|
|
574
575
|
if (existsSync$1(p))return p;
|
|
575
576
|
}
|
|
576
577
|
return null;
|
|
@@ -579,7 +580,7 @@ async function loadWorkspace(filePath,env) {
|
|
|
579
580
|
const absPath = pathResolve$2(filePath),raw = await loadModuleDefault(absPath, "workspace", { allowArray: true }),entries = typeof raw == "function" ? await raw(env ?? defaultConfigEnv()) : raw;
|
|
580
581
|
if (!Array.isArray(entries)) {
|
|
581
582
|
;
|
|
582
|
-
throw new Error(`@zntc/core: workspace must export an array (got ${
|
|
583
|
+
throw new Error(`@zntc/core: workspace must export an array (got ${entries === null ? "null" : typeof entries}) from ${absPath}`);
|
|
583
584
|
}
|
|
584
585
|
for (let i = 0; i < entries.length; i += 1) {
|
|
585
586
|
const e = entries[i];
|
|
@@ -601,8 +602,9 @@ async function loadWorkspace(filePath,env) {
|
|
|
601
602
|
}
|
|
602
603
|
function identifyWorkspaceEntries(entries,rootDir) {
|
|
603
604
|
const seen = new Set(),out = [],push = (w) => {
|
|
604
|
-
|
|
605
|
-
seen.
|
|
605
|
+
const key = w.source === "inline" ? `inline:${w.name}` : w.cwd;
|
|
606
|
+
if (seen.has(key))return;
|
|
607
|
+
seen.add(key);
|
|
606
608
|
out.push(w);
|
|
607
609
|
};
|
|
608
610
|
for (const entry of entries) {
|
|
@@ -652,7 +654,7 @@ function enumerateDirs(baseDir,namePattern) {
|
|
|
652
654
|
if (!d.isDirectory())continue;
|
|
653
655
|
if (d.name.startsWith("."))continue;
|
|
654
656
|
if (d.name === "node_modules")continue;
|
|
655
|
-
if (matcher(d.name))out.push(join$
|
|
657
|
+
if (matcher(d.name))out.push(join$2(baseDir, d.name));
|
|
656
658
|
}
|
|
657
659
|
out.sort();
|
|
658
660
|
return out;
|
|
@@ -663,7 +665,7 @@ function makeStarMatcher(pattern) {
|
|
|
663
665
|
return (s) => re.test(s);
|
|
664
666
|
}
|
|
665
667
|
function detectPackageName(absDir) {
|
|
666
|
-
const pkgPath = join$
|
|
668
|
+
const pkgPath = join$2(absDir, "package.json");
|
|
667
669
|
if (existsSync$1(pkgPath)) {
|
|
668
670
|
try {
|
|
669
671
|
const pkg = JSON.parse(readFileSync$2(pkgPath, "utf8"));
|
|
@@ -688,7 +690,7 @@ var createRequire$1 = require("module").createRequire;
|
|
|
688
690
|
var existsSync$2 = require("fs").existsSync;
|
|
689
691
|
var mkdirSync = require("fs").mkdirSync;
|
|
690
692
|
var writeFileSync$1 = require("fs").writeFileSync;
|
|
691
|
-
var join$
|
|
693
|
+
var join$3 = require("path").join;
|
|
692
694
|
var dirname$2 = require("path").dirname;
|
|
693
695
|
var resolve$1 = require("path").resolve;
|
|
694
696
|
var fileURLToPath = require("url").fileURLToPath;
|
|
@@ -723,9 +725,9 @@ function getPlatformPackage() {
|
|
|
723
725
|
return match ? subPackageName(match) : null;
|
|
724
726
|
}
|
|
725
727
|
function findAddon() {
|
|
726
|
-
const __dirname = dirname$2(fileURLToPath(require("url").pathToFileURL(__filename).href)),platformPkg = getPlatformPackage(),zigOut = join$
|
|
728
|
+
const __dirname = dirname$2(fileURLToPath(require("url").pathToFileURL(__filename).href)),platformPkg = getPlatformPackage(),zigOut = join$3(__dirname, "../../zig-out/lib/zntc.node");
|
|
727
729
|
if (existsSync$2(zigOut))return zigOut;
|
|
728
|
-
const zigOut2 = join$
|
|
730
|
+
const zigOut2 = join$3(__dirname, "../../../zig-out/lib/zntc.node");
|
|
729
731
|
if (existsSync$2(zigOut2))return zigOut2;
|
|
730
732
|
if (platformPkg) {
|
|
731
733
|
try {
|
|
@@ -734,9 +736,9 @@ function findAddon() {
|
|
|
734
736
|
} catch {
|
|
735
737
|
}
|
|
736
738
|
}
|
|
737
|
-
const local = join$
|
|
739
|
+
const local = join$3(__dirname, "zntc.node");
|
|
738
740
|
if (existsSync$2(local))return local;
|
|
739
|
-
const parent = join$
|
|
741
|
+
const parent = join$3(__dirname, "../zntc.node");
|
|
740
742
|
if (existsSync$2(parent))return parent;
|
|
741
743
|
const expected = platformPkg ? ` (expected sub-package: ${platformPkg})` : "";
|
|
742
744
|
throw new Error(`@zntc/core: native binary not found for ${process.platform}-${process.arch}${expected}. ` + `Supported: ${formatSupportedPlatforms()}. ` + "For development run `zig build napi`. " + "If your platform should be supported, please open an issue.");
|
|
@@ -774,7 +776,7 @@ function resolveUnsupported(options) {
|
|
|
774
776
|
}
|
|
775
777
|
return browserslistToUnsupported(bl(options.browserslist));
|
|
776
778
|
}
|
|
777
|
-
return options.target ?
|
|
779
|
+
return options.target ? ES_TARGET_BITS[options.target] ?? 0 : 0;
|
|
778
780
|
}
|
|
779
781
|
var TsconfigCache = class {
|
|
780
782
|
_handle;
|
|
@@ -795,13 +797,13 @@ var TsconfigCache = class {
|
|
|
795
797
|
}
|
|
796
798
|
};
|
|
797
799
|
function transpile(source,options={}) {
|
|
798
|
-
if (
|
|
800
|
+
if (typeof source != "string")throw new Error("@zntc/core: source must be a string");
|
|
799
801
|
validateTsConfigRaw(options.tsconfigRaw);
|
|
800
802
|
const optionsJson = buildOptionsJson(options, resolveUnsupported(options));
|
|
801
803
|
return ensureNative().transpile(source, options.filename ?? "input.js", optionsJson, options.cache ? TsconfigCache._unwrap(options.cache) : undefined);
|
|
802
804
|
}
|
|
803
805
|
function tokenize(source,options={}) {
|
|
804
|
-
if (
|
|
806
|
+
if (typeof source != "string")throw new Error("@zntc/core: source must be a string");
|
|
805
807
|
return ensureNative().tokenize(source, options.filename ?? "input.js");
|
|
806
808
|
}
|
|
807
809
|
function configureProfile(profile,level) {
|
|
@@ -810,6 +812,18 @@ function configureProfile(profile,level) {
|
|
|
810
812
|
function profileReport(format="table") {
|
|
811
813
|
return ensureNative().profileReport(format);
|
|
812
814
|
}
|
|
815
|
+
function tlsSelfCheck(options) {
|
|
816
|
+
ensureNative().tlsSelfCheck(options);
|
|
817
|
+
}
|
|
818
|
+
function startDevServer(options) {
|
|
819
|
+
return ensureNative().startDevServer(options);
|
|
820
|
+
}
|
|
821
|
+
function stopDevServer(handle) {
|
|
822
|
+
ensureNative().stopDevServer(handle);
|
|
823
|
+
}
|
|
824
|
+
function getDevServerPort(handle) {
|
|
825
|
+
return ensureNative().getDevServerPort(handle);
|
|
826
|
+
}
|
|
813
827
|
function normalizePluginFailure(pluginName,hookName,thrown,fallbackFile) {
|
|
814
828
|
let message = "Plugin hook failed",file = fallbackFile ?? undefined,line,column;
|
|
815
829
|
if (typeof thrown == "string") {
|
|
@@ -827,14 +841,14 @@ function normalizePluginFailure(pluginName,hookName,thrown,fallbackFile) {
|
|
|
827
841
|
} else if (thrown != null) {
|
|
828
842
|
message = String(thrown);
|
|
829
843
|
}
|
|
830
|
-
return { __zntcPluginFailure: true, pluginName, hookName, message, ...
|
|
844
|
+
return { __zntcPluginFailure: true, pluginName, hookName, message, ...file ? { file } : {}, ...line !== undefined ? { line } : {}, ...column !== undefined ? { column } : {} };
|
|
831
845
|
}
|
|
832
846
|
function pluginFailureText(failure) {
|
|
833
847
|
const location = failure.file && failure.line !== undefined ? ` (${failure.file}:${failure.line}:${failure.column ?? 0})` : failure.file ? ` (${failure.file})` : "";
|
|
834
848
|
return `Plugin "${failure.pluginName}" failed in ${failure.hookName}: ${failure.message}${location}`;
|
|
835
849
|
}
|
|
836
850
|
function pluginFailureToDiagnostic(failure) {
|
|
837
|
-
return { code: "plugin_error", text: pluginFailureText(failure), ...
|
|
851
|
+
return { code: "plugin_error", text: pluginFailureText(failure), ...failure.file ? { location: { file: failure.file, line: failure.line, column: failure.column } } : {} };
|
|
838
852
|
}
|
|
839
853
|
function serializePluginSourceMap(map) {
|
|
840
854
|
if (map == null)return null;
|
|
@@ -856,7 +870,7 @@ function serializePluginSourceMap(map) {
|
|
|
856
870
|
}
|
|
857
871
|
}
|
|
858
872
|
function isPromiseLike(value) {
|
|
859
|
-
return
|
|
873
|
+
return value != null && (typeof value == "object" || typeof value == "function") && typeof value.then == "function";
|
|
860
874
|
}
|
|
861
875
|
function silenceUnsupportedSyncPromise(value) {
|
|
862
876
|
Promise.resolve(value).catch(() => {
|
|
@@ -868,6 +882,14 @@ function syncPluginPromiseFailure(pluginName,hookName,file) {
|
|
|
868
882
|
function isPluginFailureResult(value) {
|
|
869
883
|
return Boolean(value && typeof value == "object" && value.__zntcPluginFailure === true);
|
|
870
884
|
}
|
|
885
|
+
function deepMergeMeta(target,source) {
|
|
886
|
+
const out = { ...target };
|
|
887
|
+
for (const key of Object.keys(source)) {
|
|
888
|
+
const sv = source[key],tv = out[key],merged = sv != null && typeof sv == "object" && !Array.isArray(sv) && tv != null && typeof tv == "object" && !Array.isArray(tv) ? deepMergeMeta(tv, sv) : sv;
|
|
889
|
+
Object.defineProperty(out, key, { value: merged, writable: true, enumerable: true, configurable: true });
|
|
890
|
+
}
|
|
891
|
+
return out;
|
|
892
|
+
}
|
|
871
893
|
function safeSerializeSourceMap(map) {
|
|
872
894
|
try {
|
|
873
895
|
return { ok: true, map: serializePluginSourceMap(map) };
|
|
@@ -880,16 +902,16 @@ function mapMaybePromise(value,mapper) {
|
|
|
880
902
|
return mapper(value);
|
|
881
903
|
}
|
|
882
904
|
function collectPluginRegistry(plugins) {
|
|
883
|
-
const registry = { hooks: { resolveId: [], load: [], transform: [], renderChunk: [], resolveContext: [] }, generateBundleCallbacks: [], buildStartCallbacks: [], buildEndCallbacks: [], closeBundleCallbacks: [], astFunctionHooks: [], lifecycleFailures: [] };
|
|
905
|
+
const registry = { hooks: { resolveId: [], load: [], transform: [], renderChunk: [], resolveContext: [] }, generateBundleCallbacks: [], buildStartCallbacks: [], buildEndCallbacks: [], closeBundleCallbacks: [], astFunctionHooks: [], lifecycleFailures: [], pluginWarnings: [], contexts: new Map() };
|
|
884
906
|
for (const plugin of plugins) {
|
|
885
907
|
const build = { onResolve(opts,cb) {
|
|
886
|
-
registry.hooks.resolveId.push({ pluginName: plugin.name, filter: opts.filter, callback: cb });
|
|
908
|
+
registry.hooks.resolveId.push({ pluginName: plugin.name, filter: stripStatefulFilterFlags(opts.filter), callback: cb });
|
|
887
909
|
}, onLoad(opts,cb) {
|
|
888
|
-
registry.hooks.load.push({ pluginName: plugin.name, filter: opts.filter, callback: cb });
|
|
910
|
+
registry.hooks.load.push({ pluginName: plugin.name, filter: stripStatefulFilterFlags(opts.filter), callback: cb });
|
|
889
911
|
}, onTransform(opts,cb) {
|
|
890
|
-
registry.hooks.transform.push({ pluginName: plugin.name, filter: opts.filter, callback: cb });
|
|
912
|
+
registry.hooks.transform.push({ pluginName: plugin.name, filter: stripStatefulFilterFlags(opts.filter), callback: cb });
|
|
891
913
|
}, onRenderChunk(opts,cb) {
|
|
892
|
-
registry.hooks.renderChunk.push({ pluginName: plugin.name, filter: opts.filter, callback: cb });
|
|
914
|
+
registry.hooks.renderChunk.push({ pluginName: plugin.name, filter: stripStatefulFilterFlags(opts.filter), callback: cb });
|
|
893
915
|
}, onGenerateBundle(cb) {
|
|
894
916
|
registry.generateBundleCallbacks.push({ pluginName: plugin.name, callback: cb });
|
|
895
917
|
}, onBuildStart(cb) {
|
|
@@ -899,9 +921,9 @@ function collectPluginRegistry(plugins) {
|
|
|
899
921
|
}, onCloseBundle(cb) {
|
|
900
922
|
registry.closeBundleCallbacks.push({ pluginName: plugin.name, callback: cb });
|
|
901
923
|
}, onAstFunction(opts,cb) {
|
|
902
|
-
registry.astFunctionHooks.push({ pluginName: plugin.name, filter: opts.filter, callback: cb });
|
|
924
|
+
registry.astFunctionHooks.push({ pluginName: plugin.name, filter: stripStatefulFilterFlags(opts.filter), callback: cb });
|
|
903
925
|
}, onResolveContext(opts,cb) {
|
|
904
|
-
registry.hooks.resolveContext.push({ pluginName: plugin.name, filter: opts.filter, callback: cb });
|
|
926
|
+
registry.hooks.resolveContext.push({ pluginName: plugin.name, filter: stripStatefulFilterFlags(opts.filter), callback: cb });
|
|
905
927
|
} };
|
|
906
928
|
plugin.setup(build);
|
|
907
929
|
}
|
|
@@ -929,7 +951,24 @@ function lifecycleHookSpec(reg,hookName,arg1) {
|
|
|
929
951
|
return null;
|
|
930
952
|
}
|
|
931
953
|
}
|
|
932
|
-
function
|
|
954
|
+
function getPluginContext(reg,pluginName,getModuleInfo,resolve,emitFile,getFileName) {
|
|
955
|
+
let ctx = reg.contexts.get(pluginName);
|
|
956
|
+
if (!ctx) {
|
|
957
|
+
ctx = createRollupPluginContext(pluginName, (d) => reg.pluginWarnings.push(d));
|
|
958
|
+
reg.contexts.set(pluginName, ctx);
|
|
959
|
+
}
|
|
960
|
+
const slot = ctx;
|
|
961
|
+
slot.__getModuleInfo = getModuleInfo;
|
|
962
|
+
slot.__resolve = resolve;
|
|
963
|
+
slot.__emitFile = emitFile;
|
|
964
|
+
slot.__getFileName = getFileName;
|
|
965
|
+
return ctx;
|
|
966
|
+
}
|
|
967
|
+
function stripStatefulFilterFlags(re) {
|
|
968
|
+
if (!re.global && !re.sticky)return re;
|
|
969
|
+
return new RegExp(re.source, re.flags.replace(/[gy]/g, ""));
|
|
970
|
+
}
|
|
971
|
+
function* dispatchHook(reg,hookName,arg1,arg2,getModuleInfo,resolve,emitFile,getFileName) {
|
|
933
972
|
if (hookName === "astFunction") {
|
|
934
973
|
if (reg.astFunctionHooks.length === 0)return null;
|
|
935
974
|
let info;
|
|
@@ -940,7 +979,7 @@ function* dispatchHook(reg,hookName,arg1,arg2) {
|
|
|
940
979
|
}
|
|
941
980
|
for (const h of reg.astFunctionHooks) {
|
|
942
981
|
if (!h.filter.test(info.sourcePath))continue;
|
|
943
|
-
const result = yield { callback: () => h.callback(info), pluginName: h.pluginName, hookName: "astFunction", fallbackFile: info.sourcePath };
|
|
982
|
+
const result = yield { callback: () => h.callback.call(getPluginContext(reg, h.pluginName, getModuleInfo, resolve, emitFile, getFileName), info), pluginName: h.pluginName, hookName: "astFunction", fallbackFile: info.sourcePath };
|
|
944
983
|
if (isPluginFailureResult(result))return result;
|
|
945
984
|
if (result != null)return result;
|
|
946
985
|
}
|
|
@@ -956,7 +995,7 @@ function* dispatchHook(reg,hookName,arg1,arg2) {
|
|
|
956
995
|
}
|
|
957
996
|
for (const h of reg.hooks.resolveContext) {
|
|
958
997
|
if (!h.filter.test(args.dir))continue;
|
|
959
|
-
const result = yield { callback: () => h.callback(args), pluginName: h.pluginName, hookName: "resolveContext", fallbackFile: args.importer };
|
|
998
|
+
const result = yield { callback: () => h.callback.call(getPluginContext(reg, h.pluginName, getModuleInfo, resolve, emitFile, getFileName), args), pluginName: h.pluginName, hookName: "resolveContext", fallbackFile: args.importer };
|
|
960
999
|
if (isPluginFailureResult(result))return result;
|
|
961
1000
|
if (result != null)return result;
|
|
962
1001
|
}
|
|
@@ -967,7 +1006,7 @@ function* dispatchHook(reg,hookName,arg1,arg2) {
|
|
|
967
1006
|
if (spec) {
|
|
968
1007
|
let firstFailure = null;
|
|
969
1008
|
for (const { pluginName:pluginName, callback:callback } of spec.callbacks) {
|
|
970
|
-
const result = yield { callback: () => callback(spec.arg), pluginName, hookName };
|
|
1009
|
+
const result = yield { callback: () => callback.call(getPluginContext(reg, pluginName, getModuleInfo, resolve, emitFile, getFileName), spec.arg), pluginName, hookName };
|
|
971
1010
|
if (isPluginFailureResult(result) && firstFailure == null)firstFailure = result;
|
|
972
1011
|
}
|
|
973
1012
|
if (spec.surfaceFailures) {
|
|
@@ -982,9 +1021,10 @@ function* dispatchHook(reg,hookName,arg1,arg2) {
|
|
|
982
1021
|
if (!hookList)return null;
|
|
983
1022
|
let currentCode = arg1,changed = false;
|
|
984
1023
|
const sourceMaps = [];
|
|
1024
|
+
let mergedMeta;
|
|
985
1025
|
for (const h of hookList) {
|
|
986
1026
|
if (!h.filter.test(arg2 ?? ""))continue;
|
|
987
|
-
const cbArgs = hookName === "transform" ? { code: currentCode, path: arg2 } : { code: currentCode, chunk: arg2 },result = yield { callback: () => h.callback(cbArgs), pluginName: h.pluginName, hookName, fallbackFile: arg2 };
|
|
1027
|
+
const cbArgs = hookName === "transform" ? { code: currentCode, path: arg2 } : { code: currentCode, chunk: arg2 },result = yield { callback: () => h.callback.call(getPluginContext(reg, h.pluginName, getModuleInfo, resolve, emitFile, getFileName), cbArgs), pluginName: h.pluginName, hookName, fallbackFile: arg2 };
|
|
988
1028
|
if (isPluginFailureResult(result))return result;
|
|
989
1029
|
if (result != null) {
|
|
990
1030
|
const obj = result,newCode = typeof result == "string" ? result : obj.code;
|
|
@@ -997,9 +1037,23 @@ function* dispatchHook(reg,hookName,arg1,arg2) {
|
|
|
997
1037
|
if (!r.ok)return normalizePluginFailure(h.pluginName, hookName, r.err, arg2);
|
|
998
1038
|
if (r.map != null)sourceMaps.push(r.map);
|
|
999
1039
|
}
|
|
1040
|
+
if (hookName === "transform" && typeof result == "object" && obj.meta != null) {
|
|
1041
|
+
if (typeof obj.meta != "object") {
|
|
1042
|
+
} else {
|
|
1043
|
+
mergedMeta = mergedMeta === undefined ? { ...obj.meta } : deepMergeMeta(mergedMeta, obj.meta);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
let metaJson;
|
|
1049
|
+
if (mergedMeta !== undefined) {
|
|
1050
|
+
try {
|
|
1051
|
+
metaJson = JSON.stringify(mergedMeta);
|
|
1052
|
+
} catch (err) {
|
|
1053
|
+
return normalizePluginFailure("transform-chain", hookName, err, arg2);
|
|
1000
1054
|
}
|
|
1001
1055
|
}
|
|
1002
|
-
return changed ? { code: currentCode, ...
|
|
1056
|
+
return changed || metaJson !== undefined ? { ...changed ? { code: currentCode } : {}, ...sourceMaps.length > 0 ? { maps: sourceMaps } : {}, ...metaJson !== undefined ? { meta: metaJson } : {} } : null;
|
|
1003
1057
|
}
|
|
1004
1058
|
const hookList = reg.hooks[hookName];
|
|
1005
1059
|
if (!hookList)return null;
|
|
@@ -1008,15 +1062,26 @@ function* dispatchHook(reg,hookName,arg1,arg2) {
|
|
|
1008
1062
|
const [filterTarget, cbArgs] = buildArgs(arg1, arg2);
|
|
1009
1063
|
for (const h of hookList) {
|
|
1010
1064
|
if (!h.filter.test(filterTarget))continue;
|
|
1011
|
-
const fallbackFile = hookName === "resolveId" ? arg2 : filterTarget,result = yield { callback: () => h.callback(cbArgs), pluginName: h.pluginName, hookName, fallbackFile };
|
|
1065
|
+
const fallbackFile = hookName === "resolveId" ? arg2 : filterTarget,result = yield { callback: () => h.callback.call(getPluginContext(reg, h.pluginName, getModuleInfo, resolve, emitFile, getFileName), cbArgs), pluginName: h.pluginName, hookName, fallbackFile };
|
|
1012
1066
|
if (isPluginFailureResult(result))return result;
|
|
1013
1067
|
if (result != null) {
|
|
1014
|
-
|
|
1015
|
-
|
|
1068
|
+
let withMeta = result;
|
|
1069
|
+
const rawMeta = typeof result == "object" && result !== null ? result.meta : undefined;
|
|
1070
|
+
if (rawMeta != null && typeof rawMeta == "object") {
|
|
1071
|
+
let metaJson;
|
|
1072
|
+
try {
|
|
1073
|
+
metaJson = JSON.stringify(rawMeta);
|
|
1074
|
+
} catch (err) {
|
|
1075
|
+
return normalizePluginFailure(h.pluginName, hookName, err, fallbackFile);
|
|
1076
|
+
}
|
|
1077
|
+
withMeta = { ...result, meta: metaJson };
|
|
1078
|
+
}
|
|
1079
|
+
if (hookName === "load" && typeof withMeta == "object" && "map" in withMeta) {
|
|
1080
|
+
const r = safeSerializeSourceMap(withMeta.map);
|
|
1016
1081
|
if (!r.ok)return normalizePluginFailure(h.pluginName, hookName, r.err, fallbackFile);
|
|
1017
|
-
return { ...
|
|
1082
|
+
return { ...withMeta, ...r.map != null ? { map: r.map } : { map: undefined } };
|
|
1018
1083
|
}
|
|
1019
|
-
return
|
|
1084
|
+
return withMeta;
|
|
1020
1085
|
}
|
|
1021
1086
|
}
|
|
1022
1087
|
return null;
|
|
@@ -1056,10 +1121,11 @@ function driveDispatchSync(gen) {
|
|
|
1056
1121
|
return r.value;
|
|
1057
1122
|
}
|
|
1058
1123
|
function createPluginDispatcher(plugins) {
|
|
1059
|
-
const reg = collectPluginRegistry(plugins),dispatcher = function dispatcher(hookName,arg1,arg2) {
|
|
1060
|
-
return driveDispatchAsync(dispatchHook(reg, hookName, arg1, arg2));
|
|
1124
|
+
const reg = collectPluginRegistry(plugins),dispatcher = function dispatcher(hookName,arg1,arg2,getModuleInfo,resolve,emitFile,getFileName) {
|
|
1125
|
+
return driveDispatchAsync(dispatchHook(reg, hookName, arg1, arg2, getModuleInfo, resolve, emitFile, getFileName));
|
|
1061
1126
|
};
|
|
1062
1127
|
dispatcher.takeLifecycleFailures = () => reg.lifecycleFailures.splice(0);
|
|
1128
|
+
dispatcher.takePluginWarnings = () => reg.pluginWarnings.splice(0);
|
|
1063
1129
|
return dispatcher;
|
|
1064
1130
|
}
|
|
1065
1131
|
function createSyncPluginDispatcher(plugins) {
|
|
@@ -1067,6 +1133,7 @@ function createSyncPluginDispatcher(plugins) {
|
|
|
1067
1133
|
return driveDispatchSync(dispatchHook(reg, hookName, arg1, arg2));
|
|
1068
1134
|
};
|
|
1069
1135
|
dispatcher.takeLifecycleFailures = () => reg.lifecycleFailures.splice(0);
|
|
1136
|
+
dispatcher.takePluginWarnings = () => reg.pluginWarnings.splice(0);
|
|
1070
1137
|
return dispatcher;
|
|
1071
1138
|
}
|
|
1072
1139
|
function arrayAliasToPlugin(aliasArray) {
|
|
@@ -1103,6 +1170,11 @@ function withDefaultBuildDefines(options) {
|
|
|
1103
1170
|
}
|
|
1104
1171
|
return Object.keys(define).length > 0 ? define : undefined;
|
|
1105
1172
|
}
|
|
1173
|
+
function warnIfWatchOnlyOption(options,fnName) {
|
|
1174
|
+
if (options.skipInitialOutput) {
|
|
1175
|
+
console.warn(`@zntc/core: ${fnName}() does not honor skipInitialOutput (watch()-only option). It is silently ignored. If you meant to use this with a separate build, call watch() instead.`);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1106
1178
|
function withDefaultAppBuildDefines(options) {
|
|
1107
1179
|
const define = { ...options.define };
|
|
1108
1180
|
if (define["process.env.NODE_ENV"] === undefined) {
|
|
@@ -1111,7 +1183,17 @@ function withDefaultAppBuildDefines(options) {
|
|
|
1111
1183
|
return define;
|
|
1112
1184
|
}
|
|
1113
1185
|
function prepareNapiOptions(options) {
|
|
1114
|
-
const napiOptions = { ...options }
|
|
1186
|
+
const napiOptions = { ...options };
|
|
1187
|
+
if (typeof options.rnVersion == "string") {
|
|
1188
|
+
const m = /^[ \t]*(?:>=|<=|==|>|<)?[ \t]*(\d+)\.(\d+)(?:\.\d+)*[ \t]*$/.exec(options.rnVersion);
|
|
1189
|
+
if (!m || Number(m[1]) > 65535 || Number(m[2]) > 65535) {
|
|
1190
|
+
throw new Error(`Invalid rnVersion '${options.rnVersion}' (expected e.g. '0.74', '>=0.74', '<=0.84', '==0.76')`);
|
|
1191
|
+
}
|
|
1192
|
+
if (options.platform === "node" || options.platform === "neutral") {
|
|
1193
|
+
throw new Error(`rnVersion conflicts with platform: '${options.platform}' (rnVersion implies react-native)`);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
const define = withDefaultBuildDefines(options);
|
|
1115
1197
|
if (define)napiOptions.define = define;
|
|
1116
1198
|
delete napiOptions.write;
|
|
1117
1199
|
delete napiOptions.outdir;
|
|
@@ -1217,6 +1299,13 @@ function postProcessCssOutputs(result,options) {
|
|
|
1217
1299
|
}
|
|
1218
1300
|
}
|
|
1219
1301
|
}
|
|
1302
|
+
function resolveOutputPath(filePath,opts) {
|
|
1303
|
+
const { outfileResolved:outfileResolved, outdir:outdir } = opts;
|
|
1304
|
+
if (outfileResolved && filePath === "bundle.js")return outfileResolved;
|
|
1305
|
+
if (outfileResolved && filePath === "bundle.js.map")return `${outfileResolved}.map`;
|
|
1306
|
+
if (outdir)return join$3(resolve$1(outdir), filePath);
|
|
1307
|
+
return resolve$1(filePath);
|
|
1308
|
+
}
|
|
1220
1309
|
function writeOutputFiles(result,options) {
|
|
1221
1310
|
const shouldWrite = options.write ?? (options.outdir != null || options.outfile != null);
|
|
1222
1311
|
if (!shouldWrite)return;
|
|
@@ -1230,17 +1319,7 @@ function writeOutputFiles(result,options) {
|
|
|
1230
1319
|
}
|
|
1231
1320
|
const createdDirs = new Set(),outfileResolved = options.outfile ? resolve$1(options.outfile) : null;
|
|
1232
1321
|
for (const file of result.outputFiles) {
|
|
1233
|
-
|
|
1234
|
-
if (outfileResolved && file.path === "bundle.js") {
|
|
1235
|
-
outPath = outfileResolved;
|
|
1236
|
-
} else if (outfileResolved && file.path.endsWith(".map")) {
|
|
1237
|
-
outPath = outfileResolved + ".map";
|
|
1238
|
-
} else if (options.outdir) {
|
|
1239
|
-
outPath = join$2(resolve$1(options.outdir), file.path);
|
|
1240
|
-
} else {
|
|
1241
|
-
outPath = resolve$1(file.path);
|
|
1242
|
-
}
|
|
1243
|
-
const dir = dirname$2(outPath);
|
|
1322
|
+
const outPath = resolveOutputPath(file.path, { outfileResolved, outdir: options.outdir }),dir = dirname$2(outPath);
|
|
1244
1323
|
if (!createdDirs.has(dir)) {
|
|
1245
1324
|
mkdirSync(dir, { recursive: true });
|
|
1246
1325
|
createdDirs.add(dir);
|
|
@@ -1252,6 +1331,7 @@ async function build(options) {
|
|
|
1252
1331
|
const n = ensureNative();
|
|
1253
1332
|
if (!options.entryPoints?.length)throw new Error("@zntc/core: entryPoints is required");
|
|
1254
1333
|
validateTsConfigRaw(options.tsconfigRaw);
|
|
1334
|
+
warnIfWatchOnlyOption(options, "build");
|
|
1255
1335
|
if (options.output && options.output.length >= 2) {
|
|
1256
1336
|
return buildMultiFormat(options);
|
|
1257
1337
|
}
|
|
@@ -1263,6 +1343,9 @@ async function build(options) {
|
|
|
1263
1343
|
for (const failure of dispatcher.takeLifecycleFailures()) {
|
|
1264
1344
|
result.errors.push(pluginFailureToDiagnostic(failure));
|
|
1265
1345
|
}
|
|
1346
|
+
for (const warning of dispatcher.takePluginWarnings()) {
|
|
1347
|
+
result.warnings.push(warning);
|
|
1348
|
+
}
|
|
1266
1349
|
}
|
|
1267
1350
|
postProcessCssOutputs(result, options);
|
|
1268
1351
|
writeOutputFiles(result, options);
|
|
@@ -1271,6 +1354,9 @@ async function build(options) {
|
|
|
1271
1354
|
for (const failure of dispatcher.takeLifecycleFailures()) {
|
|
1272
1355
|
result.errors.push(pluginFailureToDiagnostic(failure));
|
|
1273
1356
|
}
|
|
1357
|
+
for (const warning of dispatcher.takePluginWarnings()) {
|
|
1358
|
+
result.warnings.push(warning);
|
|
1359
|
+
}
|
|
1274
1360
|
}
|
|
1275
1361
|
return result;
|
|
1276
1362
|
} finally {
|
|
@@ -1281,6 +1367,7 @@ function buildSync(options) {
|
|
|
1281
1367
|
const n = ensureNative();
|
|
1282
1368
|
if (!options.entryPoints?.length)throw new Error("@zntc/core: entryPoints is required");
|
|
1283
1369
|
validateTsConfigRaw(options.tsconfigRaw);
|
|
1370
|
+
warnIfWatchOnlyOption(options, "buildSync");
|
|
1284
1371
|
const { napiOptions:napiOptions, cleanup:cleanup } = prepareNapiOptions(options),dispatcher = resolveDispatcher(options, "sync");
|
|
1285
1372
|
if (dispatcher)napiOptions._pluginDispatcherSync = dispatcher;
|
|
1286
1373
|
try {
|
|
@@ -1289,6 +1376,9 @@ function buildSync(options) {
|
|
|
1289
1376
|
for (const failure of dispatcher.takeLifecycleFailures()) {
|
|
1290
1377
|
result.errors.push(pluginFailureToDiagnostic(failure));
|
|
1291
1378
|
}
|
|
1379
|
+
for (const warning of dispatcher.takePluginWarnings()) {
|
|
1380
|
+
result.warnings.push(warning);
|
|
1381
|
+
}
|
|
1292
1382
|
}
|
|
1293
1383
|
postProcessCssOutputs(result, options);
|
|
1294
1384
|
writeOutputFiles(result, options);
|
|
@@ -1297,6 +1387,9 @@ function buildSync(options) {
|
|
|
1297
1387
|
for (const failure of dispatcher.takeLifecycleFailures()) {
|
|
1298
1388
|
result.errors.push(pluginFailureToDiagnostic(failure));
|
|
1299
1389
|
}
|
|
1390
|
+
for (const warning of dispatcher.takePluginWarnings()) {
|
|
1391
|
+
result.warnings.push(warning);
|
|
1392
|
+
}
|
|
1300
1393
|
}
|
|
1301
1394
|
return result;
|
|
1302
1395
|
} finally {
|
|
@@ -1354,8 +1447,27 @@ async function buildMultiFormat(options) {
|
|
|
1354
1447
|
return aggregated;
|
|
1355
1448
|
}
|
|
1356
1449
|
function buildAppSync(options={}) {
|
|
1357
|
-
const n = ensureNative(),{ publicDir:publicDir, compiler:compiler, ...rest } = options;
|
|
1358
|
-
|
|
1450
|
+
const n = ensureNative(),{ publicDir:publicDir, compiler:compiler, plugins:_plugins, ...rest } = options;
|
|
1451
|
+
;
|
|
1452
|
+
const dispatcher = resolveDispatcher(options, "sync"),napiOptions = { ...rest, define: withDefaultAppBuildDefines(options), ...publicDir === false ? { disablePublicDir: true } : publicDir !== undefined ? { publicDir } : {}, ...buildCompilerNapiFields(compiler) };
|
|
1453
|
+
if (dispatcher)napiOptions._pluginDispatcherSync = dispatcher;
|
|
1454
|
+
const result = wrapOutputFiles(n.buildAppSync(napiOptions));
|
|
1455
|
+
if (dispatcher) {
|
|
1456
|
+
for (const failure of dispatcher.takeLifecycleFailures()) {
|
|
1457
|
+
result.errors.push(pluginFailureToDiagnostic(failure));
|
|
1458
|
+
}
|
|
1459
|
+
for (const warning of dispatcher.takePluginWarnings()) {
|
|
1460
|
+
result.warnings.push(warning);
|
|
1461
|
+
}
|
|
1462
|
+
dispatcher("closeBundle", undefined, null);
|
|
1463
|
+
for (const failure of dispatcher.takeLifecycleFailures()) {
|
|
1464
|
+
result.errors.push(pluginFailureToDiagnostic(failure));
|
|
1465
|
+
}
|
|
1466
|
+
for (const warning of dispatcher.takePluginWarnings()) {
|
|
1467
|
+
result.warnings.push(warning);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
return result;
|
|
1359
1471
|
}
|
|
1360
1472
|
function buildCompilerNapiFields(compiler) {
|
|
1361
1473
|
const out = {},sc = compiler?.styledComponents;
|
|
@@ -1392,7 +1504,7 @@ function buildCompilerNapiFields(compiler) {
|
|
|
1392
1504
|
}
|
|
1393
1505
|
function prepareAppDevSync(options={}) {
|
|
1394
1506
|
const n = ensureNative(),{ publicDir:publicDir, ...rest } = options;
|
|
1395
|
-
return n.prepareAppDevSync({ ...rest, ...
|
|
1507
|
+
return n.prepareAppDevSync({ ...rest, ...publicDir === false ? { disablePublicDir: true } : publicDir !== undefined ? { publicDir } : {} });
|
|
1396
1508
|
}
|
|
1397
1509
|
function close() {
|
|
1398
1510
|
native = null;
|
|
@@ -1438,17 +1550,74 @@ function normalizeVitePluginSourceMap(map,onDrop) {
|
|
|
1438
1550
|
return undefined;
|
|
1439
1551
|
}
|
|
1440
1552
|
}
|
|
1441
|
-
function createRollupPluginContext(pluginName) {
|
|
1442
|
-
|
|
1553
|
+
function createRollupPluginContext(pluginName,onWarn) {
|
|
1554
|
+
const ctx = { error(error) {
|
|
1443
1555
|
throw error;
|
|
1444
1556
|
}, warn(message) {
|
|
1445
|
-
|
|
1557
|
+
const text = `@zntc/core [${pluginName}]: ${typeof message == "string" ? message : String(message)}`;
|
|
1558
|
+
if (onWarn)onWarn({ text }); else console.warn(text);
|
|
1446
1559
|
}, addWatchFile(_id) {
|
|
1447
|
-
}, resolve(
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1560
|
+
}, resolve(source,importer,_options) {
|
|
1561
|
+
const fn = ctx.__resolve;
|
|
1562
|
+
if (typeof fn != "function") {
|
|
1563
|
+
throw new Error(`@zntc/core [${pluginName}]: this.resolve() 는 async build() 의 resolveId/load/transform hook 에서만 사용 가능합니다 (#1880 PR4).`);
|
|
1564
|
+
}
|
|
1565
|
+
return Promise.resolve(fn(source, importer));
|
|
1566
|
+
}, emitFile(file) {
|
|
1567
|
+
const fn = ctx.__emitFile;
|
|
1568
|
+
if (typeof fn != "function") {
|
|
1569
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile() 는 async build() 의 resolveId/load/transform hook 에서만 사용 가능합니다 (#1880 PR5).`);
|
|
1570
|
+
}
|
|
1571
|
+
if (typeof file != "object" || file === null) {
|
|
1572
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile() 는 객체 인자가 필요합니다.`);
|
|
1573
|
+
}
|
|
1574
|
+
const f = file;
|
|
1575
|
+
if (f.type === "chunk") {
|
|
1576
|
+
if (typeof f.id != "string" || f.id.length === 0) {
|
|
1577
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile({ type: 'chunk' }) 는 비어있지 않은 id(모듈 specifier)가 필요합니다 (#1880 PR7-2b).`);
|
|
1578
|
+
}
|
|
1579
|
+
if (f.implicitlyLoadedAfterOneOf !== undefined && (!Array.isArray(f.implicitlyLoadedAfterOneOf) || !f.implicitlyLoadedAfterOneOf.every((x) => typeof x == "string"))) {
|
|
1580
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile({ type: 'chunk' }) 의 implicitlyLoadedAfterOneOf 는 문자열 id 배열이어야 합니다 (#3664).`);
|
|
1581
|
+
}
|
|
1582
|
+
const chunkRef = fn({ chunkId: f.id, chunkName: typeof f.name == "string" && f.name.length > 0 ? f.name : undefined, chunkFileName: typeof f.fileName == "string" && f.fileName.length > 0 ? f.fileName : undefined, chunkImplicitlyLoadedAfterOneOf: Array.isArray(f.implicitlyLoadedAfterOneOf) && f.implicitlyLoadedAfterOneOf.length > 0 ? f.implicitlyLoadedAfterOneOf : undefined });
|
|
1583
|
+
if (typeof chunkRef != "string") {
|
|
1584
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile({ type: 'chunk', id: ${JSON.stringify(f.id)} }) 가 reference id 를 반환하지 못했습니다.`);
|
|
1585
|
+
}
|
|
1586
|
+
return chunkRef;
|
|
1587
|
+
}
|
|
1588
|
+
if (f.type !== "asset") {
|
|
1589
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile({ type: '${String(f.type)}' }) 는 아직 미지원입니다 — 현재 type:'asset'/'chunk' 만 지원 (#1880 PR7-2b).`);
|
|
1590
|
+
}
|
|
1591
|
+
const hasFileName = typeof f.fileName == "string" && f.fileName.length > 0,hasName = typeof f.name == "string" && f.name.length > 0;
|
|
1592
|
+
if (!hasFileName && !hasName) {
|
|
1593
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile() asset 은 비어있지 않은 fileName 또는 name 이 필요합니다 (#1880 PR6).`);
|
|
1594
|
+
}
|
|
1595
|
+
if (typeof f.source != "string" && !(f.source instanceof Uint8Array)) {
|
|
1596
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile() asset 은 source(string | Uint8Array) 가 필요합니다.`);
|
|
1597
|
+
}
|
|
1598
|
+
const referenceId = hasFileName ? fn({ fileName: f.fileName, source: f.source }) : fn({ name: f.name, source: f.source });
|
|
1599
|
+
if (typeof referenceId != "string") {
|
|
1600
|
+
throw new Error(`@zntc/core [${pluginName}]: this.emitFile(${JSON.stringify(hasFileName ? f.fileName : f.name)}) 가 reference id 를 반환하지 못했습니다 (asset emit 실패).`);
|
|
1601
|
+
}
|
|
1602
|
+
return referenceId;
|
|
1603
|
+
}, getFileName(referenceId) {
|
|
1604
|
+
const fn = ctx.__getFileName;
|
|
1605
|
+
if (typeof fn != "function") {
|
|
1606
|
+
throw new Error(`@zntc/core [${pluginName}]: this.getFileName() 는 resolveId/load/transform/generateBundle hook 에서만 사용 가능합니다 (#1880 PR6/2c).`);
|
|
1607
|
+
}
|
|
1608
|
+
const name = fn(referenceId);
|
|
1609
|
+
if (typeof name != "string") {
|
|
1610
|
+
throw new Error(`@zntc/core [${pluginName}]: this.getFileName(${JSON.stringify(referenceId)}) — 알 수 없는 reference id (미emit, 또는 chunk 를 청킹 전 hook 에서 조회 — chunk 파일명은 generateBundle 에서 확정).`);
|
|
1611
|
+
}
|
|
1612
|
+
return name;
|
|
1613
|
+
}, getModuleInfo(id) {
|
|
1614
|
+
const fn = ctx.__getModuleInfo;
|
|
1615
|
+
if (typeof fn != "function") {
|
|
1616
|
+
throw new Error(`@zntc/core [${pluginName}]: this.getModuleInfo() 는 async build() 의 transform hook 에서만 사용 가능합니다 (#1880 PR3).`);
|
|
1617
|
+
}
|
|
1618
|
+
return fn(id);
|
|
1451
1619
|
} };
|
|
1620
|
+
return ctx;
|
|
1452
1621
|
}
|
|
1453
1622
|
function createDropWarner(context) {
|
|
1454
1623
|
const seen = new Set();
|
|
@@ -1458,11 +1627,17 @@ function createDropWarner(context) {
|
|
|
1458
1627
|
context.warn(`sourcemap dropped: ${reason}`);
|
|
1459
1628
|
};
|
|
1460
1629
|
}
|
|
1630
|
+
function forwardEmitContext(nativeThis,viteCtx) {
|
|
1631
|
+
const from = nativeThis,to = viteCtx;
|
|
1632
|
+
to.__emitFile = from?.__emitFile;
|
|
1633
|
+
to.__getFileName = from?.__getFileName;
|
|
1634
|
+
}
|
|
1461
1635
|
function vitePlugin(rollupPlugin) {
|
|
1462
1636
|
return { name: rollupPlugin.name, setup(build) {
|
|
1463
1637
|
const context = createRollupPluginContext(rollupPlugin.name),onDropSourceMap = createDropWarner(context),resolveId = extractHandler(rollupPlugin.resolveId);
|
|
1464
1638
|
if (resolveId) {
|
|
1465
|
-
build.onResolve({ filter: /.*/ }, (args)
|
|
1639
|
+
build.onResolve({ filter: /.*/ }, function(args) {
|
|
1640
|
+
forwardEmitContext(this, context);
|
|
1466
1641
|
const result = resolveId.call(context, args.path, args.importer);
|
|
1467
1642
|
return mapMaybePromise(result, (result) => {
|
|
1468
1643
|
if (result == null)return null;
|
|
@@ -1476,7 +1651,8 @@ function vitePlugin(rollupPlugin) {
|
|
|
1476
1651
|
}
|
|
1477
1652
|
const load = extractHandler(rollupPlugin.load);
|
|
1478
1653
|
if (load) {
|
|
1479
|
-
build.onLoad({ filter: /.*/ }, (args)
|
|
1654
|
+
build.onLoad({ filter: /.*/ }, function(args) {
|
|
1655
|
+
forwardEmitContext(this, context);
|
|
1480
1656
|
const result = load.call(context, args.path);
|
|
1481
1657
|
return mapMaybePromise(result, (result) => {
|
|
1482
1658
|
if (result == null)return null;
|
|
@@ -1490,7 +1666,8 @@ function vitePlugin(rollupPlugin) {
|
|
|
1490
1666
|
}
|
|
1491
1667
|
const transform = extractHandler(rollupPlugin.transform);
|
|
1492
1668
|
if (transform) {
|
|
1493
|
-
build.onTransform({ filter: /.*/ }, (args)
|
|
1669
|
+
build.onTransform({ filter: /.*/ }, function(args) {
|
|
1670
|
+
forwardEmitContext(this, context);
|
|
1494
1671
|
const result = transform.call(context, args.code, args.path);
|
|
1495
1672
|
return mapMaybePromise(result, (result) => {
|
|
1496
1673
|
if (result == null)return null;
|
|
@@ -1504,7 +1681,8 @@ function vitePlugin(rollupPlugin) {
|
|
|
1504
1681
|
}
|
|
1505
1682
|
const renderChunk = extractHandler(rollupPlugin.renderChunk);
|
|
1506
1683
|
if (renderChunk) {
|
|
1507
|
-
build.onRenderChunk({ filter: /.*/ }, (args)
|
|
1684
|
+
build.onRenderChunk({ filter: /.*/ }, function(args) {
|
|
1685
|
+
forwardEmitContext(this, context);
|
|
1508
1686
|
const result = renderChunk.call(context, args.code, args.chunk);
|
|
1509
1687
|
return mapMaybePromise(result, (result) => {
|
|
1510
1688
|
if (result == null)return null;
|
|
@@ -1518,28 +1696,44 @@ function vitePlugin(rollupPlugin) {
|
|
|
1518
1696
|
}
|
|
1519
1697
|
const generateBundle = extractHandler(rollupPlugin.generateBundle);
|
|
1520
1698
|
if (generateBundle) {
|
|
1521
|
-
build.onGenerateBundle((outputs)
|
|
1699
|
+
build.onGenerateBundle(function(outputs) {
|
|
1700
|
+
forwardEmitContext(this, context);
|
|
1701
|
+
return generateBundle.call(context, outputs);
|
|
1702
|
+
});
|
|
1522
1703
|
}
|
|
1523
1704
|
const buildStart = extractHandler(rollupPlugin.buildStart);
|
|
1524
1705
|
if (buildStart) {
|
|
1525
|
-
build.onBuildStart(()
|
|
1706
|
+
build.onBuildStart(function() {
|
|
1707
|
+
forwardEmitContext(this, context);
|
|
1708
|
+
return buildStart.call(context);
|
|
1709
|
+
});
|
|
1526
1710
|
}
|
|
1527
1711
|
const buildEnd = extractHandler(rollupPlugin.buildEnd);
|
|
1528
1712
|
if (buildEnd) {
|
|
1529
|
-
build.onBuildEnd((err)
|
|
1713
|
+
build.onBuildEnd(function(err) {
|
|
1714
|
+
forwardEmitContext(this, context);
|
|
1715
|
+
return buildEnd.call(context, err);
|
|
1716
|
+
});
|
|
1530
1717
|
}
|
|
1531
1718
|
const closeBundle = extractHandler(rollupPlugin.closeBundle);
|
|
1532
1719
|
if (closeBundle) {
|
|
1533
|
-
build.onCloseBundle(()
|
|
1720
|
+
build.onCloseBundle(function() {
|
|
1721
|
+
forwardEmitContext(this, context);
|
|
1722
|
+
return closeBundle.call(context);
|
|
1723
|
+
});
|
|
1534
1724
|
}
|
|
1535
1725
|
} };
|
|
1536
1726
|
}
|
|
1537
1727
|
function watch(options) {
|
|
1538
|
-
const n = ensureNative(),{ napiOptions:nativeOpts, cleanup:cleanup } = prepareNapiOptions(options)
|
|
1728
|
+
const n = ensureNative(),{ napiOptions:nativeOpts, cleanup:cleanup } = prepareNapiOptions(options);
|
|
1729
|
+
if (options.outdir !== undefined)nativeOpts.outdir = options.outdir;
|
|
1730
|
+
const dispatcher = resolveDispatcher(options);
|
|
1539
1731
|
if (dispatcher) {
|
|
1540
1732
|
nativeOpts._pluginDispatcher = dispatcher;
|
|
1541
1733
|
const dispatchCloseBundle = () => {
|
|
1542
1734
|
void dispatcher("closeBundle", undefined, null).catch(() => {
|
|
1735
|
+
}).finally(() => {
|
|
1736
|
+
for (const w of dispatcher.takePluginWarnings())console.warn(w.text);
|
|
1543
1737
|
});
|
|
1544
1738
|
},wrapWatchCallback = (callback) => (event) => {
|
|
1545
1739
|
void Promise.resolve().then(() => callback?.(event)).finally(dispatchCloseBundle).catch(() => {
|
|
@@ -1565,6 +1759,8 @@ function watch(options) {
|
|
|
1565
1759
|
return handle.getBundleSourceMap();
|
|
1566
1760
|
}, getHmrSourceMap(moduleId) {
|
|
1567
1761
|
return handle.getHmrSourceMap(moduleId);
|
|
1762
|
+
}, requestLazySeed(path) {
|
|
1763
|
+
handle.requestLazySeed(path);
|
|
1568
1764
|
} };
|
|
1569
1765
|
}
|
|
1570
1766
|
exports.isPlainObject = isPlainObject;
|
|
@@ -1595,6 +1791,11 @@ exports.transpile = transpile;
|
|
|
1595
1791
|
exports.tokenize = tokenize;
|
|
1596
1792
|
exports.configureProfile = configureProfile;
|
|
1597
1793
|
exports.profileReport = profileReport;
|
|
1794
|
+
exports.tlsSelfCheck = tlsSelfCheck;
|
|
1795
|
+
exports.startDevServer = startDevServer;
|
|
1796
|
+
exports.stopDevServer = stopDevServer;
|
|
1797
|
+
exports.getDevServerPort = getDevServerPort;
|
|
1798
|
+
exports.resolveOutputPath = resolveOutputPath;
|
|
1598
1799
|
exports.build = build;
|
|
1599
1800
|
exports.buildSync = buildSync;
|
|
1600
1801
|
exports.BuildInstance = BuildInstance;
|