rolldown 1.0.0-beta.3-commit.62fba31 → 1.0.0-beta.3-commit.4666fd5

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/cjs/cli.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-BZ9nUXsY.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-DtSwpkV3.cjs');
3
+ const require_src = require('../shared/src-4ko3ERfv.cjs');
4
+ const require_parse_ast_index = require('../shared/parse-ast-index-Dh_sWnMa.cjs');
5
5
  const node_process = require_chunk.__toESM(require("node:process"));
6
6
  const node_path = require_chunk.__toESM(require("node:path"));
7
7
  const node_fs = require_chunk.__toESM(require("node:fs"));
@@ -954,7 +954,7 @@ function n(e) {
954
954
  const I = globalThis.process?.platform || "", T = n(s$1.CI) || l.ci !== false, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), U = n(s$1.DEBUG), A = t === "test" || n(s$1.TEST);
955
955
  n(s$1.MINIMAL);
956
956
  const _ = /^win/i.test(I);
957
- !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb");
957
+ !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM);
958
958
  const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
959
959
  Number(C?.split(".")[0]);
960
960
  const y = globalThis.process || Object.create(null), c = { versions: {} };
@@ -1125,7 +1125,7 @@ function createConsola(options$1 = {}) {
1125
1125
  stdout: process.stdout,
1126
1126
  stderr: process.stderr,
1127
1127
  prompt: (...args) => Promise.resolve().then(function() {
1128
- return require("../shared/prompt-Dh7e4K1i.cjs");
1128
+ return require("../shared/prompt-ZZScCEWI.cjs");
1129
1129
  }).then((m) => m.prompt(...args)),
1130
1130
  reporters: options$1.reporters || [options$1.fancy ?? !(T || A) ? new FancyReporter() : new BasicReporter()],
1131
1131
  ...options$1
@@ -1166,7 +1166,7 @@ function createTestingLogger() {
1166
1166
 
1167
1167
  //#endregion
1168
1168
  //#region src/cli/load-config.ts
1169
- async function bundleTsConfig(configFile) {
1169
+ async function bundleTsConfig(configFile, isEsm) {
1170
1170
  const dirnameVarName = "injected_original_dirname";
1171
1171
  const filenameVarName = "injected_original_filename";
1172
1172
  const importMetaUrlVarName = "injected_original_import_meta_url";
@@ -1200,9 +1200,9 @@ async function bundleTsConfig(configFile) {
1200
1200
  const outputDir = node_path.default.dirname(configFile);
1201
1201
  const result = await bundle.write({
1202
1202
  dir: outputDir,
1203
- format: "esm",
1203
+ format: isEsm ? "esm" : "cjs",
1204
1204
  sourcemap: "inline",
1205
- entryFileNames: "rolldown.config.[hash].js"
1205
+ entryFileNames: `rolldown.config.[hash]${node_path.default.extname(configFile).replace("ts", "js")}`
1206
1206
  });
1207
1207
  const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
1208
1208
  return node_path.default.join(outputDir, fileName);
@@ -1228,13 +1228,40 @@ async function findConfigFileNameInCwd() {
1228
1228
  throw new Error("No `rolldown.config` configuration file found.");
1229
1229
  }
1230
1230
  async function loadTsConfig(configFile) {
1231
- const file = await bundleTsConfig(configFile);
1231
+ const isEsm = isFilePathESM(configFile);
1232
+ const file = await bundleTsConfig(configFile, isEsm);
1232
1233
  try {
1233
1234
  return (await import((0, node_url.pathToFileURL)(file).href)).default;
1234
1235
  } finally {
1235
1236
  node_fs.default.unlink(file, () => {});
1236
1237
  }
1237
1238
  }
1239
+ function isFilePathESM(filePath) {
1240
+ if (/\.m[jt]s$/.test(filePath)) return true;
1241
+ else if (/\.c[jt]s$/.test(filePath)) return false;
1242
+ else {
1243
+ const pkg = findNearestPackageData(node_path.default.dirname(filePath));
1244
+ if (pkg) return pkg.type === "module";
1245
+ return false;
1246
+ }
1247
+ }
1248
+ function findNearestPackageData(basedir) {
1249
+ while (basedir) {
1250
+ const pkgPath = node_path.default.join(basedir, "package.json");
1251
+ if (tryStatSync(pkgPath)?.isFile()) try {
1252
+ return JSON.parse(node_fs.default.readFileSync(pkgPath, "utf-8"));
1253
+ } catch {}
1254
+ const nextBasedir = node_path.default.dirname(basedir);
1255
+ if (nextBasedir === basedir) break;
1256
+ basedir = nextBasedir;
1257
+ }
1258
+ return null;
1259
+ }
1260
+ function tryStatSync(file) {
1261
+ try {
1262
+ return node_fs.default.statSync(file, { throwIfNoEntry: false });
1263
+ } catch {}
1264
+ }
1238
1265
  async function loadConfig(configPath) {
1239
1266
  const ext = node_path.default.extname(configPath = configPath || await findConfigFileNameInCwd());
1240
1267
  try {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-BZ9nUXsY.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-DtSwpkV3.cjs');
3
+ const require_src = require('../shared/src-4ko3ERfv.cjs');
4
+ const require_parse_ast_index = require('../shared/parse-ast-index-Dh_sWnMa.cjs');
5
5
  const node_url = require_chunk.__toESM(require("node:url"));
6
6
 
7
7
  //#region src/plugin/parallel-plugin.ts
@@ -1,5 +1,5 @@
1
- const require_src = require('../shared/src-BZ9nUXsY.cjs');
2
- require('../shared/parse-ast-index-DtSwpkV3.cjs');
1
+ const require_src = require('../shared/src-4ko3ERfv.cjs');
2
+ require('../shared/parse-ast-index-Dh_sWnMa.cjs');
3
3
 
4
4
  exports.VERSION = require_src.VERSION
5
5
  exports.build = require_src.build
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-BZ9nUXsY.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-DtSwpkV3.cjs');
3
+ const require_src = require('../shared/src-4ko3ERfv.cjs');
4
+ const require_parse_ast_index = require('../shared/parse-ast-index-Dh_sWnMa.cjs');
5
5
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
6
6
 
7
7
  //#region src/parallel-plugin-worker.ts
@@ -1,4 +1,4 @@
1
- const require_parse_ast_index = require('../shared/parse-ast-index-DtSwpkV3.cjs');
1
+ const require_parse_ast_index = require('../shared/parse-ast-index-Dh_sWnMa.cjs');
2
2
 
3
3
  exports.parseAst = require_parse_ast_index.parseAst
4
4
  exports.parseAstAsync = require_parse_ast_index.parseAstAsync
package/dist/esm/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { colors } from "../shared/parse-ast-index-CSo7-trQ.mjs";
2
- import { arraify, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-CX4-zCdU.mjs";
1
+ import { colors } from "../shared/parse-ast-index-DIxeQDpE.mjs";
2
+ import { arraify, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-ypUvsO0F.mjs";
3
3
  import process$1, { cwd } from "node:process";
4
4
  import path, { sep } from "node:path";
5
5
  import fs from "node:fs";
@@ -952,7 +952,7 @@ function n(e) {
952
952
  const I = globalThis.process?.platform || "", T = n(s$1.CI) || l.ci !== false, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), U = n(s$1.DEBUG), A = t === "test" || n(s$1.TEST);
953
953
  n(s$1.MINIMAL);
954
954
  const _ = /^win/i.test(I);
955
- !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb");
955
+ !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM);
956
956
  const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
957
957
  Number(C?.split(".")[0]);
958
958
  const y = globalThis.process || Object.create(null), c = { versions: {} };
@@ -1122,7 +1122,7 @@ function createConsola(options$1 = {}) {
1122
1122
  defaults: { level },
1123
1123
  stdout: process.stdout,
1124
1124
  stderr: process.stderr,
1125
- prompt: (...args) => import("../shared/prompt-zTLhvFXo.mjs").then((m) => m.prompt(...args)),
1125
+ prompt: (...args) => import("../shared/prompt-CxK9euq3.mjs").then((m) => m.prompt(...args)),
1126
1126
  reporters: options$1.reporters || [options$1.fancy ?? !(T || A) ? new FancyReporter() : new BasicReporter()],
1127
1127
  ...options$1
1128
1128
  });
@@ -1162,7 +1162,7 @@ function createTestingLogger() {
1162
1162
 
1163
1163
  //#endregion
1164
1164
  //#region src/cli/load-config.ts
1165
- async function bundleTsConfig(configFile) {
1165
+ async function bundleTsConfig(configFile, isEsm) {
1166
1166
  const dirnameVarName = "injected_original_dirname";
1167
1167
  const filenameVarName = "injected_original_filename";
1168
1168
  const importMetaUrlVarName = "injected_original_import_meta_url";
@@ -1196,9 +1196,9 @@ async function bundleTsConfig(configFile) {
1196
1196
  const outputDir = path.dirname(configFile);
1197
1197
  const result = await bundle.write({
1198
1198
  dir: outputDir,
1199
- format: "esm",
1199
+ format: isEsm ? "esm" : "cjs",
1200
1200
  sourcemap: "inline",
1201
- entryFileNames: "rolldown.config.[hash].js"
1201
+ entryFileNames: `rolldown.config.[hash]${path.extname(configFile).replace("ts", "js")}`
1202
1202
  });
1203
1203
  const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
1204
1204
  return path.join(outputDir, fileName);
@@ -1224,13 +1224,40 @@ async function findConfigFileNameInCwd() {
1224
1224
  throw new Error("No `rolldown.config` configuration file found.");
1225
1225
  }
1226
1226
  async function loadTsConfig(configFile) {
1227
- const file = await bundleTsConfig(configFile);
1227
+ const isEsm = isFilePathESM(configFile);
1228
+ const file = await bundleTsConfig(configFile, isEsm);
1228
1229
  try {
1229
1230
  return (await import(pathToFileURL(file).href)).default;
1230
1231
  } finally {
1231
1232
  fs.unlink(file, () => {});
1232
1233
  }
1233
1234
  }
1235
+ function isFilePathESM(filePath) {
1236
+ if (/\.m[jt]s$/.test(filePath)) return true;
1237
+ else if (/\.c[jt]s$/.test(filePath)) return false;
1238
+ else {
1239
+ const pkg = findNearestPackageData(path.dirname(filePath));
1240
+ if (pkg) return pkg.type === "module";
1241
+ return false;
1242
+ }
1243
+ }
1244
+ function findNearestPackageData(basedir) {
1245
+ while (basedir) {
1246
+ const pkgPath = path.join(basedir, "package.json");
1247
+ if (tryStatSync(pkgPath)?.isFile()) try {
1248
+ return JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
1249
+ } catch {}
1250
+ const nextBasedir = path.dirname(basedir);
1251
+ if (nextBasedir === basedir) break;
1252
+ basedir = nextBasedir;
1253
+ }
1254
+ return null;
1255
+ }
1256
+ function tryStatSync(file) {
1257
+ try {
1258
+ return fs.statSync(file, { throwIfNoEntry: false });
1259
+ } catch {}
1260
+ }
1234
1261
  async function loadConfig(configPath) {
1235
1262
  const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
1236
1263
  try {
@@ -1,5 +1,5 @@
1
- import { import_binding } from "../shared/parse-ast-index-CSo7-trQ.mjs";
2
- import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-CX4-zCdU.mjs";
1
+ import { import_binding } from "../shared/parse-ast-index-DIxeQDpE.mjs";
2
+ import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-ypUvsO0F.mjs";
3
3
  import { pathToFileURL } from "node:url";
4
4
 
5
5
  //#region src/plugin/parallel-plugin.ts
@@ -1,4 +1,4 @@
1
- import "../shared/parse-ast-index-CSo7-trQ.mjs";
2
- import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-CX4-zCdU.mjs";
1
+ import "../shared/parse-ast-index-DIxeQDpE.mjs";
2
+ import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-ypUvsO0F.mjs";
3
3
 
4
4
  export { VERSION, build, defineConfig, rolldown, watch };
@@ -1,5 +1,5 @@
1
- import { import_binding } from "../shared/parse-ast-index-CSo7-trQ.mjs";
2
- import { PluginContextData, bindingifyPlugin } from "../shared/src-CX4-zCdU.mjs";
1
+ import { import_binding } from "../shared/parse-ast-index-DIxeQDpE.mjs";
2
+ import { PluginContextData, bindingifyPlugin } from "../shared/src-ypUvsO0F.mjs";
3
3
  import { parentPort, workerData } from "node:worker_threads";
4
4
 
5
5
  //#region src/parallel-plugin-worker.ts
@@ -1,3 +1,3 @@
1
- import { parseAst, parseAstAsync } from "../shared/parse-ast-index-CSo7-trQ.mjs";
1
+ import { parseAst, parseAstAsync } from "../shared/parse-ast-index-DIxeQDpE.mjs";
2
2
 
3
3
  export { parseAst, parseAstAsync };
@@ -597,12 +597,15 @@ var require_binding = __commonJS({ "src/binding.js"(exports, module) {
597
597
  module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
598
598
  module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
599
599
  module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
600
+ module.exports.getBufferOffset = nativeBinding.getBufferOffset;
600
601
  module.exports.HelperMode = nativeBinding.HelperMode;
601
602
  module.exports.ImportNameKind = nativeBinding.ImportNameKind;
602
603
  module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
604
+ module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
603
605
  module.exports.parseAsync = nativeBinding.parseAsync;
604
606
  module.exports.parseSync = nativeBinding.parseSync;
605
- module.exports.parseWithoutReturn = nativeBinding.parseWithoutReturn;
607
+ module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
608
+ module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
606
609
  module.exports.registerPlugins = nativeBinding.registerPlugins;
607
610
  module.exports.Severity = nativeBinding.Severity;
608
611
  module.exports.transform = nativeBinding.transform;
@@ -571,12 +571,15 @@ var require_binding = require_chunk.__commonJS({ "src/binding.js"(exports, modul
571
571
  module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
572
572
  module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
573
573
  module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
574
+ module.exports.getBufferOffset = nativeBinding.getBufferOffset;
574
575
  module.exports.HelperMode = nativeBinding.HelperMode;
575
576
  module.exports.ImportNameKind = nativeBinding.ImportNameKind;
576
577
  module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
578
+ module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
577
579
  module.exports.parseAsync = nativeBinding.parseAsync;
578
580
  module.exports.parseSync = nativeBinding.parseSync;
579
- module.exports.parseWithoutReturn = nativeBinding.parseWithoutReturn;
581
+ module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
582
+ module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
580
583
  module.exports.registerPlugins = nativeBinding.registerPlugins;
581
584
  module.exports.Severity = nativeBinding.Severity;
582
585
  module.exports.transform = nativeBinding.transform;
@@ -137,8 +137,8 @@ function requirePicocolors() {
137
137
  picocolors.exports.createColors = createColors;
138
138
  return picocolors.exports;
139
139
  }
140
- var picocolorsExports = /*@__PURE__*/ requirePicocolors();
141
- const e = /*@__PURE__*/ getDefaultExportFromCjs(picocolorsExports);
140
+ var picocolorsExports = /* @__PURE__ */ requirePicocolors();
141
+ const e = /* @__PURE__ */ getDefaultExportFromCjs(picocolorsExports);
142
142
  function J({ onlyFirst: t = false } = {}) {
143
143
  const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
144
144
  return new RegExp(F, t ? void 0 : "g");
@@ -140,8 +140,8 @@ function requirePicocolors() {
140
140
  picocolors.exports.createColors = createColors;
141
141
  return picocolors.exports;
142
142
  }
143
- var picocolorsExports = /*@__PURE__*/ requirePicocolors();
144
- const e = /*@__PURE__*/ getDefaultExportFromCjs(picocolorsExports);
143
+ var picocolorsExports = /* @__PURE__ */ requirePicocolors();
144
+ const e = /* @__PURE__ */ getDefaultExportFromCjs(picocolorsExports);
145
145
  function J({ onlyFirst: t = false } = {}) {
146
146
  const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
147
147
  return new RegExp(F, t ? void 0 : "g");