elit 3.5.9 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +1 -1
- package/dist/build.cjs +11 -4
- package/dist/build.d.ts +1 -1
- package/dist/build.js +11 -4
- package/dist/build.mjs +11 -4
- package/dist/cli.cjs +170 -93
- package/dist/cli.mjs +170 -93
- package/dist/config.cjs +7 -2
- package/dist/config.d.ts +1 -1
- package/dist/config.js +7 -2
- package/dist/config.mjs +7 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/desktop-auto-render.d.ts +1 -1
- package/dist/render-context.d.ts +1 -1
- package/dist/{server-FCdUqabc.d.ts → server-CcBFc2F5.d.ts} +1 -1
- package/dist/server.cjs +147 -84
- package/dist/server.d.ts +1 -1
- package/dist/server.js +147 -84
- package/dist/server.mjs +147 -84
- package/package.json +66 -35
package/dist/cli.mjs
CHANGED
|
@@ -59447,7 +59447,11 @@ function findInstalledPackageRoot(startDir, packageName) {
|
|
|
59447
59447
|
}
|
|
59448
59448
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
59449
59449
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
59450
|
-
const builtCandidates = [
|
|
59450
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
59451
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
59452
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
59453
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
59454
|
+
] : [
|
|
59451
59455
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
59452
59456
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
59453
59457
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -59579,7 +59583,8 @@ async function loadConfigFile(configPath) {
|
|
|
59579
59583
|
setup(build3) {
|
|
59580
59584
|
build3.onResolve({ filter: /.*/ }, (args) => {
|
|
59581
59585
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
59582
|
-
preferBuilt: true
|
|
59586
|
+
preferBuilt: true,
|
|
59587
|
+
preferredBuiltFormat: "esm"
|
|
59583
59588
|
});
|
|
59584
59589
|
if (workspacePackageImport) {
|
|
59585
59590
|
return {
|
|
@@ -61310,35 +61315,42 @@ var sendError = (res, code, msg) => {
|
|
|
61310
61315
|
var send404 = (res, msg = "Not Found") => sendError(res, 404, msg);
|
|
61311
61316
|
var send403 = (res, msg = "Forbidden") => sendError(res, 403, msg);
|
|
61312
61317
|
var send500 = (res, msg = "Internal Server Error") => sendError(res, 500, msg);
|
|
61313
|
-
async function resolveWorkspaceElitImportBasePath(rootDir, basePath,
|
|
61318
|
+
async function resolveWorkspaceElitImportBasePath(rootDir, basePath, _mode) {
|
|
61314
61319
|
const resolvedRootDir = await realpath(resolve(rootDir));
|
|
61315
61320
|
try {
|
|
61316
61321
|
const packageJsonBuffer = await readFile(join(resolvedRootDir, "package.json"));
|
|
61317
61322
|
const packageJson = JSON.parse(packageJsonBuffer.toString());
|
|
61318
61323
|
if (packageJson.name === "elit") {
|
|
61319
|
-
|
|
61320
|
-
return basePath ? `${basePath}/${workspaceDir}` : `/${workspaceDir}`;
|
|
61324
|
+
return basePath ? `${basePath}/dist` : "/dist";
|
|
61321
61325
|
}
|
|
61322
61326
|
} catch {
|
|
61323
61327
|
}
|
|
61324
61328
|
return void 0;
|
|
61325
61329
|
}
|
|
61330
|
+
var BROWSER_SAFE_ELIT_IMPORTS = {
|
|
61331
|
+
"elit": "index",
|
|
61332
|
+
"elit/dom": "dom",
|
|
61333
|
+
"elit/el": "el",
|
|
61334
|
+
"elit/native": "native",
|
|
61335
|
+
"elit/universal": "universal",
|
|
61336
|
+
"elit/router": "router",
|
|
61337
|
+
"elit/state": "state",
|
|
61338
|
+
"elit/style": "style",
|
|
61339
|
+
"elit/hmr": "hmr",
|
|
61340
|
+
"elit/types": "types"
|
|
61341
|
+
};
|
|
61342
|
+
function createBrowserSafeElitImports(basePath, fileExt) {
|
|
61343
|
+
return Object.fromEntries(
|
|
61344
|
+
Object.entries(BROWSER_SAFE_ELIT_IMPORTS).map(([specifier, outputName]) => [
|
|
61345
|
+
specifier,
|
|
61346
|
+
`${basePath}/${outputName}${fileExt}`
|
|
61347
|
+
])
|
|
61348
|
+
);
|
|
61349
|
+
}
|
|
61326
61350
|
var createElitImportMap = async (rootDir, basePath = "", mode = "dev") => {
|
|
61327
61351
|
const workspaceImportBasePath = await resolveWorkspaceElitImportBasePath(rootDir, basePath, mode);
|
|
61328
|
-
const fileExt =
|
|
61329
|
-
const elitImports = workspaceImportBasePath ? {
|
|
61330
|
-
"elit": `${workspaceImportBasePath}/index${fileExt}`,
|
|
61331
|
-
"elit/": `${workspaceImportBasePath}/`,
|
|
61332
|
-
"elit/dom": `${workspaceImportBasePath}/dom${fileExt}`,
|
|
61333
|
-
"elit/state": `${workspaceImportBasePath}/state${fileExt}`,
|
|
61334
|
-
"elit/style": `${workspaceImportBasePath}/style${fileExt}`,
|
|
61335
|
-
"elit/el": `${workspaceImportBasePath}/el${fileExt}`,
|
|
61336
|
-
"elit/universal": `${workspaceImportBasePath}/universal${fileExt}`,
|
|
61337
|
-
"elit/router": `${workspaceImportBasePath}/router${fileExt}`,
|
|
61338
|
-
"elit/hmr": `${workspaceImportBasePath}/hmr${fileExt}`,
|
|
61339
|
-
"elit/types": `${workspaceImportBasePath}/types${fileExt}`,
|
|
61340
|
-
"elit/native": `${workspaceImportBasePath}/native${fileExt}`
|
|
61341
|
-
} : {};
|
|
61352
|
+
const fileExt = ".mjs";
|
|
61353
|
+
const elitImports = workspaceImportBasePath ? createBrowserSafeElitImports(workspaceImportBasePath, fileExt) : {};
|
|
61342
61354
|
const externalImports = await generateExternalImportMaps(rootDir, basePath);
|
|
61343
61355
|
const allImports = { ...externalImports, ...elitImports };
|
|
61344
61356
|
return `<script type="importmap">${JSON.stringify({ imports: allImports }, null, 2)}</script>`;
|
|
@@ -61609,6 +61621,29 @@ async function processPackage(nodeModulesPath, pkgName, importMap, basePath) {
|
|
|
61609
61621
|
}
|
|
61610
61622
|
}
|
|
61611
61623
|
function processExportsField(pkgName, exports2, baseUrl, importMap) {
|
|
61624
|
+
if (pkgName === "elit") {
|
|
61625
|
+
if (typeof exports2 !== "object" || exports2 === null) {
|
|
61626
|
+
return;
|
|
61627
|
+
}
|
|
61628
|
+
const elitExports = exports2;
|
|
61629
|
+
const browserSafeImports = {};
|
|
61630
|
+
const rootResolved = "." in elitExports ? resolveExport(elitExports["."]) : "import" in elitExports ? resolveExport(elitExports) : null;
|
|
61631
|
+
if (rootResolved) {
|
|
61632
|
+
browserSafeImports.elit = `${baseUrl}/${rootResolved}`;
|
|
61633
|
+
}
|
|
61634
|
+
const allowedSubpaths = Object.keys(BROWSER_SAFE_ELIT_IMPORTS).filter((specifier) => specifier !== "elit").map((specifier) => ({
|
|
61635
|
+
exportKey: `./${specifier.slice("elit/".length)}`,
|
|
61636
|
+
importName: specifier
|
|
61637
|
+
}));
|
|
61638
|
+
for (const { exportKey, importName } of allowedSubpaths) {
|
|
61639
|
+
const resolved = resolveExport(elitExports[exportKey]);
|
|
61640
|
+
if (resolved) {
|
|
61641
|
+
browserSafeImports[importName] = `${baseUrl}/${resolved}`;
|
|
61642
|
+
}
|
|
61643
|
+
}
|
|
61644
|
+
Object.assign(importMap, browserSafeImports);
|
|
61645
|
+
return;
|
|
61646
|
+
}
|
|
61612
61647
|
if (typeof exports2 === "string") {
|
|
61613
61648
|
importMap[pkgName] = `${baseUrl}/${exports2}`;
|
|
61614
61649
|
importMap[`${pkgName}/`] = `${baseUrl}/`;
|
|
@@ -61852,6 +61887,85 @@ function shouldUseClientFallbackRoot(primaryRoot, fallbackRoot, indexPath) {
|
|
|
61852
61887
|
const primaryHasRuntimeSources = existsSync(join(resolvedPrimaryRoot, "src")) || existsSync(join(resolvedPrimaryRoot, "public")) || existsSync(join(resolvedPrimaryRoot, normalizedIndexPath));
|
|
61853
61888
|
return !primaryHasRuntimeSources;
|
|
61854
61889
|
}
|
|
61890
|
+
function isPathWithinRoot(filePath, rootDir) {
|
|
61891
|
+
return filePath === rootDir || filePath.startsWith(rootDir.endsWith(sep) ? rootDir : `${rootDir}${sep}`);
|
|
61892
|
+
}
|
|
61893
|
+
async function getAllowedClientRoots(client) {
|
|
61894
|
+
const allowedRoots = [];
|
|
61895
|
+
for (const candidateRoot of [client.root, client.fallbackRoot]) {
|
|
61896
|
+
if (!candidateRoot) {
|
|
61897
|
+
continue;
|
|
61898
|
+
}
|
|
61899
|
+
try {
|
|
61900
|
+
const resolvedRoot = await realpath(resolve(candidateRoot));
|
|
61901
|
+
if (!allowedRoots.includes(resolvedRoot)) {
|
|
61902
|
+
allowedRoots.push(resolvedRoot);
|
|
61903
|
+
}
|
|
61904
|
+
} catch {
|
|
61905
|
+
}
|
|
61906
|
+
}
|
|
61907
|
+
return allowedRoots;
|
|
61908
|
+
}
|
|
61909
|
+
async function getClientBaseDirs(client, isDistRequest, isNodeModulesRequest) {
|
|
61910
|
+
const baseDirs = [];
|
|
61911
|
+
for (const candidateRoot of [client.root, client.fallbackRoot]) {
|
|
61912
|
+
if (!candidateRoot) {
|
|
61913
|
+
continue;
|
|
61914
|
+
}
|
|
61915
|
+
try {
|
|
61916
|
+
const resolvedRoot = await realpath(resolve(candidateRoot));
|
|
61917
|
+
let baseDir = resolvedRoot;
|
|
61918
|
+
if (isDistRequest || isNodeModulesRequest) {
|
|
61919
|
+
const targetDir = isDistRequest ? "dist" : "node_modules";
|
|
61920
|
+
const foundDir = await findSpecialDir(candidateRoot, targetDir);
|
|
61921
|
+
baseDir = foundDir ? await realpath(foundDir) : resolvedRoot;
|
|
61922
|
+
}
|
|
61923
|
+
if (!baseDirs.includes(baseDir)) {
|
|
61924
|
+
baseDirs.push(baseDir);
|
|
61925
|
+
}
|
|
61926
|
+
} catch {
|
|
61927
|
+
}
|
|
61928
|
+
}
|
|
61929
|
+
return baseDirs;
|
|
61930
|
+
}
|
|
61931
|
+
async function resolveClientPathFromBaseDir(baseDir, normalizedPath) {
|
|
61932
|
+
const tryRealpathWithinBaseDir = async (relativePath2) => {
|
|
61933
|
+
const unresolvedPath = resolve(join(baseDir, relativePath2));
|
|
61934
|
+
if (!isPathWithinRoot(unresolvedPath, baseDir)) {
|
|
61935
|
+
return void 0;
|
|
61936
|
+
}
|
|
61937
|
+
try {
|
|
61938
|
+
return await realpath(unresolvedPath);
|
|
61939
|
+
} catch {
|
|
61940
|
+
return void 0;
|
|
61941
|
+
}
|
|
61942
|
+
};
|
|
61943
|
+
const exactPath = await tryRealpathWithinBaseDir(normalizedPath);
|
|
61944
|
+
if (exactPath) {
|
|
61945
|
+
return exactPath;
|
|
61946
|
+
}
|
|
61947
|
+
if (normalizedPath.endsWith(".js")) {
|
|
61948
|
+
const tsPath = await tryRealpathWithinBaseDir(normalizedPath.replace(/\.js$/, ".ts"));
|
|
61949
|
+
if (tsPath) {
|
|
61950
|
+
return tsPath;
|
|
61951
|
+
}
|
|
61952
|
+
}
|
|
61953
|
+
if (normalizedPath.includes(".")) {
|
|
61954
|
+
return void 0;
|
|
61955
|
+
}
|
|
61956
|
+
for (const candidatePath of [
|
|
61957
|
+
`${normalizedPath}.ts`,
|
|
61958
|
+
`${normalizedPath}.js`,
|
|
61959
|
+
join(normalizedPath, "index.ts"),
|
|
61960
|
+
join(normalizedPath, "index.js")
|
|
61961
|
+
]) {
|
|
61962
|
+
const resolvedPath = await tryRealpathWithinBaseDir(candidatePath);
|
|
61963
|
+
if (resolvedPath) {
|
|
61964
|
+
return resolvedPath;
|
|
61965
|
+
}
|
|
61966
|
+
}
|
|
61967
|
+
return void 0;
|
|
61968
|
+
}
|
|
61855
61969
|
function createDevServer(options) {
|
|
61856
61970
|
const config = { ...defaultOptions, ...options };
|
|
61857
61971
|
const wsClients = /* @__PURE__ */ new Set();
|
|
@@ -61881,6 +61995,7 @@ function createDevServer(options) {
|
|
|
61881
61995
|
const activeRoot = useFallbackRoot ? client.fallbackRoot || client.root : client.root;
|
|
61882
61996
|
return {
|
|
61883
61997
|
root: activeRoot,
|
|
61998
|
+
fallbackRoot: useFallbackRoot ? void 0 : client.fallbackRoot,
|
|
61884
61999
|
basePath,
|
|
61885
62000
|
index: useFallbackRoot ? void 0 : indexPath,
|
|
61886
62001
|
ssr: useFallbackRoot ? void 0 : client.ssr,
|
|
@@ -61982,75 +62097,26 @@ function createDevServer(options) {
|
|
|
61982
62097
|
return send403(res, "403 Forbidden");
|
|
61983
62098
|
}
|
|
61984
62099
|
normalizedPath = tempPath;
|
|
61985
|
-
const rootDir = await realpath(resolve(matchedClient.root));
|
|
61986
|
-
let baseDir = rootDir;
|
|
61987
|
-
if (isDistRequest || isNodeModulesRequest) {
|
|
61988
|
-
const targetDir = isDistRequest ? "dist" : "node_modules";
|
|
61989
|
-
const foundDir = await findSpecialDir(matchedClient.root, targetDir);
|
|
61990
|
-
baseDir = foundDir ? await realpath(foundDir) : rootDir;
|
|
61991
|
-
}
|
|
61992
62100
|
let fullPath;
|
|
61993
|
-
|
|
61994
|
-
|
|
61995
|
-
|
|
61996
|
-
|
|
61997
|
-
|
|
61998
|
-
|
|
61999
|
-
fullPath = await realpath(unresolvedPath);
|
|
62000
|
-
if (config.logging && filePath === "/src/pages") {
|
|
62001
|
-
console.log(`[DEBUG] Initial resolve succeeded: ${fullPath}`);
|
|
62002
|
-
}
|
|
62003
|
-
} catch (firstError) {
|
|
62004
|
-
let resolvedPath;
|
|
62005
|
-
if (config.logging && !normalizedPath.includes(".")) {
|
|
62006
|
-
console.log(`[DEBUG] File not found: ${normalizedPath}, trying extensions...`);
|
|
62007
|
-
}
|
|
62008
|
-
if (normalizedPath.endsWith(".js")) {
|
|
62009
|
-
const tsPath = normalizedPath.replace(/\.js$/, ".ts");
|
|
62010
|
-
try {
|
|
62011
|
-
const tsFullPath = await realpath(resolve(join(baseDir, tsPath)));
|
|
62012
|
-
if (!tsFullPath.startsWith(baseDir.endsWith(sep) ? baseDir : baseDir + sep)) {
|
|
62013
|
-
if (config.logging) console.log(`[403] Fallback TS path outside of root: ${tsFullPath}`);
|
|
62014
|
-
return send403(res, "403 Forbidden");
|
|
62015
|
-
}
|
|
62016
|
-
resolvedPath = tsFullPath;
|
|
62017
|
-
} catch {
|
|
62018
|
-
}
|
|
62019
|
-
}
|
|
62020
|
-
if (!resolvedPath && !normalizedPath.includes(".")) {
|
|
62021
|
-
try {
|
|
62022
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath + ".ts")));
|
|
62023
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}.ts`);
|
|
62024
|
-
} catch {
|
|
62025
|
-
try {
|
|
62026
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath + ".js")));
|
|
62027
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}.js`);
|
|
62028
|
-
} catch {
|
|
62029
|
-
try {
|
|
62030
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath, "index.ts")));
|
|
62031
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}/index.ts`);
|
|
62032
|
-
} catch {
|
|
62033
|
-
try {
|
|
62034
|
-
resolvedPath = await realpath(resolve(join(baseDir, normalizedPath, "index.js")));
|
|
62035
|
-
if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}/index.js`);
|
|
62036
|
-
} catch {
|
|
62037
|
-
if (config.logging) console.log(`[DEBUG] Not found: all attempts failed for ${normalizedPath}`);
|
|
62038
|
-
}
|
|
62039
|
-
}
|
|
62040
|
-
}
|
|
62101
|
+
const baseDirs = await getClientBaseDirs(matchedClient, isDistRequest, isNodeModulesRequest);
|
|
62102
|
+
for (const baseDir of baseDirs) {
|
|
62103
|
+
fullPath = await resolveClientPathFromBaseDir(baseDir, normalizedPath);
|
|
62104
|
+
if (fullPath) {
|
|
62105
|
+
if (config.logging && filePath === "/src/pages") {
|
|
62106
|
+
console.log(`[DEBUG] Initial resolve succeeded: ${fullPath}`);
|
|
62041
62107
|
}
|
|
62108
|
+
break;
|
|
62042
62109
|
}
|
|
62043
|
-
|
|
62044
|
-
|
|
62045
|
-
|
|
62046
|
-
|
|
62047
|
-
|
|
62048
|
-
if (config.logging) console.log(`[404] ${filePath}`);
|
|
62049
|
-
return send404(res, "404 Not Found");
|
|
62110
|
+
}
|
|
62111
|
+
if (!fullPath) {
|
|
62112
|
+
if (!res.headersSent) {
|
|
62113
|
+
if (filePath === "/index.html" && matchedClient.ssr) {
|
|
62114
|
+
return await serveSSR(res, matchedClient);
|
|
62050
62115
|
}
|
|
62051
|
-
|
|
62116
|
+
if (config.logging) console.log(`[404] ${filePath}`);
|
|
62117
|
+
return send404(res, "404 Not Found");
|
|
62052
62118
|
}
|
|
62053
|
-
|
|
62119
|
+
return;
|
|
62054
62120
|
}
|
|
62055
62121
|
try {
|
|
62056
62122
|
const stats = await stat(fullPath);
|
|
@@ -62079,11 +62145,12 @@ function createDevServer(options) {
|
|
|
62079
62145
|
return send404(res, "404 Not Found");
|
|
62080
62146
|
}
|
|
62081
62147
|
try {
|
|
62148
|
+
const allowedRoots = await getAllowedClientRoots(matchedClient);
|
|
62082
62149
|
const stats = await stat(fullPath);
|
|
62083
62150
|
if (stats.isDirectory()) {
|
|
62084
62151
|
try {
|
|
62085
62152
|
const indexPath = await realpath(resolve(join(fullPath, "index.html")));
|
|
62086
|
-
if (!indexPath.
|
|
62153
|
+
if (!isPathWithinRoot(indexPath, fullPath) && !allowedRoots.some((rootDir) => isPathWithinRoot(indexPath, rootDir))) {
|
|
62087
62154
|
return send403(res, "403 Forbidden");
|
|
62088
62155
|
}
|
|
62089
62156
|
await stat(indexPath);
|
|
@@ -62105,10 +62172,11 @@ function createDevServer(options) {
|
|
|
62105
62172
|
return input.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
62106
62173
|
}
|
|
62107
62174
|
try {
|
|
62108
|
-
const
|
|
62175
|
+
const allowedRoots = await getAllowedClientRoots(client);
|
|
62176
|
+
const rootDir = allowedRoots[0] || await realpath(resolve(client.root));
|
|
62109
62177
|
const unresolvedPath = resolve(filePath);
|
|
62110
62178
|
if (!isNodeModulesOrDist) {
|
|
62111
|
-
if (!
|
|
62179
|
+
if (!allowedRoots.some((allowedRoot) => isPathWithinRoot(unresolvedPath, allowedRoot))) {
|
|
62112
62180
|
if (config.logging) console.log(`[403] Attempted to serve file outside allowed directories: ${filePath}`);
|
|
62113
62181
|
return send403(res, "403 Forbidden");
|
|
62114
62182
|
}
|
|
@@ -62530,12 +62598,12 @@ function readFileAsString2(filePath) {
|
|
|
62530
62598
|
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
62531
62599
|
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
62532
62600
|
}
|
|
62533
|
-
function createWorkspacePackagePlugin(entryDir) {
|
|
62601
|
+
function createWorkspacePackagePlugin(entryDir, options = {}) {
|
|
62534
62602
|
return {
|
|
62535
62603
|
name: "workspace-package-self-reference",
|
|
62536
62604
|
setup(build2) {
|
|
62537
62605
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
62538
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
|
|
62606
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir, options);
|
|
62539
62607
|
return resolved ? { path: resolved } : void 0;
|
|
62540
62608
|
});
|
|
62541
62609
|
}
|
|
@@ -62609,7 +62677,10 @@ async function build(options) {
|
|
|
62609
62677
|
};
|
|
62610
62678
|
try {
|
|
62611
62679
|
const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
|
|
62612
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath)
|
|
62680
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
|
|
62681
|
+
preferBuilt: platform === "browser",
|
|
62682
|
+
preferredBuiltFormat: platform === "browser" ? "esm" : void 0
|
|
62683
|
+
});
|
|
62613
62684
|
const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
|
|
62614
62685
|
const define2 = {};
|
|
62615
62686
|
if (config.env) {
|
|
@@ -81832,12 +81903,12 @@ init_path();
|
|
|
81832
81903
|
// src/preview-build.ts
|
|
81833
81904
|
init_fs();
|
|
81834
81905
|
init_path();
|
|
81835
|
-
function createWorkspacePackagePlugin3(resolveDir) {
|
|
81906
|
+
function createWorkspacePackagePlugin3(resolveDir, options = {}) {
|
|
81836
81907
|
return {
|
|
81837
81908
|
name: "workspace-package-self-reference",
|
|
81838
81909
|
setup(build2) {
|
|
81839
81910
|
build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
|
|
81840
|
-
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir);
|
|
81911
|
+
const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir, options);
|
|
81841
81912
|
return resolved ? { path: resolved } : void 0;
|
|
81842
81913
|
});
|
|
81843
81914
|
}
|
|
@@ -82019,7 +82090,10 @@ async function buildStandalonePreviewServer(options) {
|
|
|
82019
82090
|
const outputDir = dirname(plan.outputPath);
|
|
82020
82091
|
mkdirSync(outputDir, { recursive: true });
|
|
82021
82092
|
const { build: build2 } = await import("esbuild");
|
|
82022
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd
|
|
82093
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd, {
|
|
82094
|
+
preferBuilt: true,
|
|
82095
|
+
preferredBuiltFormat: "cjs"
|
|
82096
|
+
});
|
|
82023
82097
|
const entrySource = createStandalonePreviewEntrySource(options.configPath, plan, options.previewConfig);
|
|
82024
82098
|
await build2({
|
|
82025
82099
|
stdin: {
|
|
@@ -82247,7 +82321,10 @@ async function buildStandaloneDevServer(options) {
|
|
|
82247
82321
|
const outputDir = dirname(plan.outputPath);
|
|
82248
82322
|
mkdirSync(outputDir, { recursive: true });
|
|
82249
82323
|
const { build: build2, version } = await import("esbuild");
|
|
82250
|
-
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd
|
|
82324
|
+
const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd, {
|
|
82325
|
+
preferBuilt: true,
|
|
82326
|
+
preferredBuiltFormat: "cjs"
|
|
82327
|
+
});
|
|
82251
82328
|
const entrySource = createStandaloneDevEntrySource(options.configPath, plan, options.devConfig, {
|
|
82252
82329
|
cwd,
|
|
82253
82330
|
buildConfig: options.buildConfig,
|
package/dist/config.cjs
CHANGED
|
@@ -782,7 +782,11 @@ function findInstalledPackageRoot(startDir, packageName) {
|
|
|
782
782
|
}
|
|
783
783
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
784
784
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
785
|
-
const builtCandidates = [
|
|
785
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
786
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
787
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
788
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
789
|
+
] : [
|
|
786
790
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
787
791
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
788
792
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -917,7 +921,8 @@ async function loadConfigFile(configPath) {
|
|
|
917
921
|
setup(build2) {
|
|
918
922
|
build2.onResolve({ filter: /.*/ }, (args) => {
|
|
919
923
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
920
|
-
preferBuilt: true
|
|
924
|
+
preferBuilt: true,
|
|
925
|
+
preferredBuiltFormat: "esm"
|
|
921
926
|
});
|
|
922
927
|
if (workspacePackageImport) {
|
|
923
928
|
return {
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DevServerOptions, B as BuildOptions, P as PreviewOptions, T as TestOptions } from './server-
|
|
1
|
+
import { D as DevServerOptions, B as BuildOptions, P as PreviewOptions, T as TestOptions } from './server-CcBFc2F5.js';
|
|
2
2
|
import './http.js';
|
|
3
3
|
import 'node:events';
|
|
4
4
|
import './ws.js';
|
package/dist/config.js
CHANGED
|
@@ -3282,7 +3282,11 @@ error: ${text}`);
|
|
|
3282
3282
|
}
|
|
3283
3283
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
3284
3284
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
3285
|
-
const builtCandidates = [
|
|
3285
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
3286
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
3287
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
3288
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
3289
|
+
] : [
|
|
3286
3290
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
3287
3291
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
3288
3292
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -3417,7 +3421,8 @@ error: ${text}`);
|
|
|
3417
3421
|
setup(build2) {
|
|
3418
3422
|
build2.onResolve({ filter: /.*/ }, (args) => {
|
|
3419
3423
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
3420
|
-
preferBuilt: true
|
|
3424
|
+
preferBuilt: true,
|
|
3425
|
+
preferredBuiltFormat: "esm"
|
|
3421
3426
|
});
|
|
3422
3427
|
if (workspacePackageImport) {
|
|
3423
3428
|
return {
|
package/dist/config.mjs
CHANGED
|
@@ -757,7 +757,11 @@ function findInstalledPackageRoot(startDir, packageName) {
|
|
|
757
757
|
}
|
|
758
758
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
759
759
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
760
|
-
const builtCandidates = [
|
|
760
|
+
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
761
|
+
resolve(packageRoot, "dist", `${subpath}.cjs`),
|
|
762
|
+
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
763
|
+
resolve(packageRoot, "dist", `${subpath}.mjs`)
|
|
764
|
+
] : [
|
|
761
765
|
resolve(packageRoot, "dist", `${subpath}.mjs`),
|
|
762
766
|
resolve(packageRoot, "dist", `${subpath}.js`),
|
|
763
767
|
resolve(packageRoot, "dist", `${subpath}.cjs`)
|
|
@@ -892,7 +896,8 @@ async function loadConfigFile(configPath) {
|
|
|
892
896
|
setup(build2) {
|
|
893
897
|
build2.onResolve({ filter: /.*/ }, (args) => {
|
|
894
898
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
895
|
-
preferBuilt: true
|
|
899
|
+
preferBuilt: true,
|
|
900
|
+
preferredBuiltFormat: "esm"
|
|
896
901
|
});
|
|
897
902
|
if (workspacePackageImport) {
|
|
898
903
|
return {
|
package/dist/coverage.d.ts
CHANGED
package/dist/render-context.d.ts
CHANGED
|
@@ -376,7 +376,7 @@ declare const json: (res: ServerResponse, data: any, status?: number) => ServerR
|
|
|
376
376
|
declare const text: (res: ServerResponse, data: string, status?: number) => ServerResponse;
|
|
377
377
|
declare const html: (res: ServerResponse, data: string, status?: number) => ServerResponse;
|
|
378
378
|
declare const status: (res: ServerResponse, code: number, message?: string) => ServerResponse;
|
|
379
|
-
declare function resolveWorkspaceElitImportBasePath(rootDir: string, basePath: string,
|
|
379
|
+
declare function resolveWorkspaceElitImportBasePath(rootDir: string, basePath: string, _mode: 'dev' | 'preview'): Promise<string | undefined>;
|
|
380
380
|
declare const createElitImportMap: (rootDir: string, basePath?: string, mode?: "dev" | "preview") => Promise<string>;
|
|
381
381
|
/**
|
|
382
382
|
* Clear import map cache (useful when packages are added/removed)
|