elit 3.6.0 → 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/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 {
@@ -61322,22 +61327,30 @@ async function resolveWorkspaceElitImportBasePath(rootDir, basePath, _mode) {
61322
61327
  }
61323
61328
  return void 0;
61324
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
+ }
61325
61350
  var createElitImportMap = async (rootDir, basePath = "", mode = "dev") => {
61326
61351
  const workspaceImportBasePath = await resolveWorkspaceElitImportBasePath(rootDir, basePath, mode);
61327
- const fileExt = ".js";
61328
- const elitImports = workspaceImportBasePath ? {
61329
- "elit": `${workspaceImportBasePath}/index${fileExt}`,
61330
- "elit/": `${workspaceImportBasePath}/`,
61331
- "elit/dom": `${workspaceImportBasePath}/dom${fileExt}`,
61332
- "elit/state": `${workspaceImportBasePath}/state${fileExt}`,
61333
- "elit/style": `${workspaceImportBasePath}/style${fileExt}`,
61334
- "elit/el": `${workspaceImportBasePath}/el${fileExt}`,
61335
- "elit/universal": `${workspaceImportBasePath}/universal${fileExt}`,
61336
- "elit/router": `${workspaceImportBasePath}/router${fileExt}`,
61337
- "elit/hmr": `${workspaceImportBasePath}/hmr${fileExt}`,
61338
- "elit/types": `${workspaceImportBasePath}/types${fileExt}`,
61339
- "elit/native": `${workspaceImportBasePath}/native${fileExt}`
61340
- } : {};
61352
+ const fileExt = ".mjs";
61353
+ const elitImports = workspaceImportBasePath ? createBrowserSafeElitImports(workspaceImportBasePath, fileExt) : {};
61341
61354
  const externalImports = await generateExternalImportMaps(rootDir, basePath);
61342
61355
  const allImports = { ...externalImports, ...elitImports };
61343
61356
  return `<script type="importmap">${JSON.stringify({ imports: allImports }, null, 2)}</script>`;
@@ -61608,6 +61621,29 @@ async function processPackage(nodeModulesPath, pkgName, importMap, basePath) {
61608
61621
  }
61609
61622
  }
61610
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
+ }
61611
61647
  if (typeof exports2 === "string") {
61612
61648
  importMap[pkgName] = `${baseUrl}/${exports2}`;
61613
61649
  importMap[`${pkgName}/`] = `${baseUrl}/`;
@@ -61851,6 +61887,85 @@ function shouldUseClientFallbackRoot(primaryRoot, fallbackRoot, indexPath) {
61851
61887
  const primaryHasRuntimeSources = existsSync(join(resolvedPrimaryRoot, "src")) || existsSync(join(resolvedPrimaryRoot, "public")) || existsSync(join(resolvedPrimaryRoot, normalizedIndexPath));
61852
61888
  return !primaryHasRuntimeSources;
61853
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
+ }
61854
61969
  function createDevServer(options) {
61855
61970
  const config = { ...defaultOptions, ...options };
61856
61971
  const wsClients = /* @__PURE__ */ new Set();
@@ -61880,6 +61995,7 @@ function createDevServer(options) {
61880
61995
  const activeRoot = useFallbackRoot ? client.fallbackRoot || client.root : client.root;
61881
61996
  return {
61882
61997
  root: activeRoot,
61998
+ fallbackRoot: useFallbackRoot ? void 0 : client.fallbackRoot,
61883
61999
  basePath,
61884
62000
  index: useFallbackRoot ? void 0 : indexPath,
61885
62001
  ssr: useFallbackRoot ? void 0 : client.ssr,
@@ -61981,75 +62097,26 @@ function createDevServer(options) {
61981
62097
  return send403(res, "403 Forbidden");
61982
62098
  }
61983
62099
  normalizedPath = tempPath;
61984
- const rootDir = await realpath(resolve(matchedClient.root));
61985
- let baseDir = rootDir;
61986
- if (isDistRequest || isNodeModulesRequest) {
61987
- const targetDir = isDistRequest ? "dist" : "node_modules";
61988
- const foundDir = await findSpecialDir(matchedClient.root, targetDir);
61989
- baseDir = foundDir ? await realpath(foundDir) : rootDir;
61990
- }
61991
62100
  let fullPath;
61992
- try {
61993
- const unresolvedPath = resolve(join(baseDir, normalizedPath));
61994
- if (!unresolvedPath.startsWith(baseDir.endsWith(sep) ? baseDir : baseDir + sep)) {
61995
- if (config.logging) console.log(`[403] File access outside of root (before symlink): ${unresolvedPath}`);
61996
- return send403(res, "403 Forbidden");
61997
- }
61998
- fullPath = await realpath(unresolvedPath);
61999
- if (config.logging && filePath === "/src/pages") {
62000
- console.log(`[DEBUG] Initial resolve succeeded: ${fullPath}`);
62001
- }
62002
- } catch (firstError) {
62003
- let resolvedPath;
62004
- if (config.logging && !normalizedPath.includes(".")) {
62005
- console.log(`[DEBUG] File not found: ${normalizedPath}, trying extensions...`);
62006
- }
62007
- if (normalizedPath.endsWith(".js")) {
62008
- const tsPath = normalizedPath.replace(/\.js$/, ".ts");
62009
- try {
62010
- const tsFullPath = await realpath(resolve(join(baseDir, tsPath)));
62011
- if (!tsFullPath.startsWith(baseDir.endsWith(sep) ? baseDir : baseDir + sep)) {
62012
- if (config.logging) console.log(`[403] Fallback TS path outside of root: ${tsFullPath}`);
62013
- return send403(res, "403 Forbidden");
62014
- }
62015
- resolvedPath = tsFullPath;
62016
- } catch {
62017
- }
62018
- }
62019
- if (!resolvedPath && !normalizedPath.includes(".")) {
62020
- try {
62021
- resolvedPath = await realpath(resolve(join(baseDir, normalizedPath + ".ts")));
62022
- if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}.ts`);
62023
- } catch {
62024
- try {
62025
- resolvedPath = await realpath(resolve(join(baseDir, normalizedPath + ".js")));
62026
- if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}.js`);
62027
- } catch {
62028
- try {
62029
- resolvedPath = await realpath(resolve(join(baseDir, normalizedPath, "index.ts")));
62030
- if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}/index.ts`);
62031
- } catch {
62032
- try {
62033
- resolvedPath = await realpath(resolve(join(baseDir, normalizedPath, "index.js")));
62034
- if (config.logging) console.log(`[DEBUG] Found: ${normalizedPath}/index.js`);
62035
- } catch {
62036
- if (config.logging) console.log(`[DEBUG] Not found: all attempts failed for ${normalizedPath}`);
62037
- }
62038
- }
62039
- }
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}`);
62040
62107
  }
62108
+ break;
62041
62109
  }
62042
- if (!resolvedPath) {
62043
- if (!res.headersSent) {
62044
- if (filePath === "/index.html" && matchedClient.ssr) {
62045
- return await serveSSR(res, matchedClient);
62046
- }
62047
- if (config.logging) console.log(`[404] ${filePath}`);
62048
- 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);
62049
62115
  }
62050
- return;
62116
+ if (config.logging) console.log(`[404] ${filePath}`);
62117
+ return send404(res, "404 Not Found");
62051
62118
  }
62052
- fullPath = resolvedPath;
62119
+ return;
62053
62120
  }
62054
62121
  try {
62055
62122
  const stats = await stat(fullPath);
@@ -62078,11 +62145,12 @@ function createDevServer(options) {
62078
62145
  return send404(res, "404 Not Found");
62079
62146
  }
62080
62147
  try {
62148
+ const allowedRoots = await getAllowedClientRoots(matchedClient);
62081
62149
  const stats = await stat(fullPath);
62082
62150
  if (stats.isDirectory()) {
62083
62151
  try {
62084
62152
  const indexPath = await realpath(resolve(join(fullPath, "index.html")));
62085
- if (!indexPath.startsWith(rootDir + sep) && indexPath !== rootDir) {
62153
+ if (!isPathWithinRoot(indexPath, fullPath) && !allowedRoots.some((rootDir) => isPathWithinRoot(indexPath, rootDir))) {
62086
62154
  return send403(res, "403 Forbidden");
62087
62155
  }
62088
62156
  await stat(indexPath);
@@ -62104,10 +62172,11 @@ function createDevServer(options) {
62104
62172
  return input.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
62105
62173
  }
62106
62174
  try {
62107
- const rootDir = await realpath(resolve(client.root));
62175
+ const allowedRoots = await getAllowedClientRoots(client);
62176
+ const rootDir = allowedRoots[0] || await realpath(resolve(client.root));
62108
62177
  const unresolvedPath = resolve(filePath);
62109
62178
  if (!isNodeModulesOrDist) {
62110
- if (!unresolvedPath.startsWith(rootDir + sep) && unresolvedPath !== rootDir) {
62179
+ if (!allowedRoots.some((allowedRoot) => isPathWithinRoot(unresolvedPath, allowedRoot))) {
62111
62180
  if (config.logging) console.log(`[403] Attempted to serve file outside allowed directories: ${filePath}`);
62112
62181
  return send403(res, "403 Forbidden");
62113
62182
  }
@@ -62529,12 +62598,12 @@ function readFileAsString2(filePath) {
62529
62598
  const contentBuffer = readFileSync(filePath, "utf-8");
62530
62599
  return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
62531
62600
  }
62532
- function createWorkspacePackagePlugin(entryDir) {
62601
+ function createWorkspacePackagePlugin(entryDir, options = {}) {
62533
62602
  return {
62534
62603
  name: "workspace-package-self-reference",
62535
62604
  setup(build2) {
62536
62605
  build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
62537
- const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir);
62606
+ const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || entryDir, options);
62538
62607
  return resolved ? { path: resolved } : void 0;
62539
62608
  });
62540
62609
  }
@@ -62608,7 +62677,10 @@ async function build(options) {
62608
62677
  };
62609
62678
  try {
62610
62679
  const platform = config.platform || (config.format === "cjs" ? "node" : "browser");
62611
- const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath));
62680
+ const workspacePackagePlugin = createWorkspacePackagePlugin(dirname(entryPath), {
62681
+ preferBuilt: platform === "browser",
62682
+ preferredBuiltFormat: platform === "browser" ? "esm" : void 0
62683
+ });
62612
62684
  const plugins = platform === "browser" ? [workspacePackagePlugin, browserOnlyPlugin] : [workspacePackagePlugin];
62613
62685
  const define2 = {};
62614
62686
  if (config.env) {
@@ -81831,12 +81903,12 @@ init_path();
81831
81903
  // src/preview-build.ts
81832
81904
  init_fs();
81833
81905
  init_path();
81834
- function createWorkspacePackagePlugin3(resolveDir) {
81906
+ function createWorkspacePackagePlugin3(resolveDir, options = {}) {
81835
81907
  return {
81836
81908
  name: "workspace-package-self-reference",
81837
81909
  setup(build2) {
81838
81910
  build2.onResolve({ filter: /^elit(?:\/.*)?$/ }, (args) => {
81839
- const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir);
81911
+ const resolved = resolveWorkspacePackageImport(args.path, args.resolveDir || resolveDir, options);
81840
81912
  return resolved ? { path: resolved } : void 0;
81841
81913
  });
81842
81914
  }
@@ -82018,7 +82090,10 @@ async function buildStandalonePreviewServer(options) {
82018
82090
  const outputDir = dirname(plan.outputPath);
82019
82091
  mkdirSync(outputDir, { recursive: true });
82020
82092
  const { build: build2 } = await import("esbuild");
82021
- const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd);
82093
+ const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd, {
82094
+ preferBuilt: true,
82095
+ preferredBuiltFormat: "cjs"
82096
+ });
82022
82097
  const entrySource = createStandalonePreviewEntrySource(options.configPath, plan, options.previewConfig);
82023
82098
  await build2({
82024
82099
  stdin: {
@@ -82246,7 +82321,10 @@ async function buildStandaloneDevServer(options) {
82246
82321
  const outputDir = dirname(plan.outputPath);
82247
82322
  mkdirSync(outputDir, { recursive: true });
82248
82323
  const { build: build2, version } = await import("esbuild");
82249
- const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd);
82324
+ const workspacePackagePlugin = createWorkspacePackagePlugin3(cwd, {
82325
+ preferBuilt: true,
82326
+ preferredBuiltFormat: "cjs"
82327
+ });
82250
82328
  const entrySource = createStandaloneDevEntrySource(options.configPath, plan, options.devConfig, {
82251
82329
  cwd,
82252
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.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 {