rolldown 1.0.0-beta.1-commit.3a0e84b → 1.0.0-beta.1-commit.f90856a

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,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-DvU-87mM.cjs');
3
+ const require_src = require('../shared/src-BrRo9ibF.cjs');
4
4
  const require_consola_36c0034f = require('../shared/consola_36c0034f-C_-uQ5ge.cjs');
5
5
  const node_fs = require_chunk.__toESM(require("node:fs"));
6
6
  const zod = require_chunk.__toESM(require("zod"));
@@ -10,6 +10,7 @@ const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
10
10
  const tty = require_chunk.__toESM(require("tty"));
11
11
  const node_util = require_chunk.__toESM(require("node:util"));
12
12
  const node_tty = require_chunk.__toESM(require("node:tty"));
13
+ const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
13
14
  const node_url = require_chunk.__toESM(require("node:url"));
14
15
 
15
16
  //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
@@ -287,14 +288,6 @@ function createTestingLogger() {
287
288
 
288
289
  //#endregion
289
290
  //#region src/cli/load-config.ts
290
- async function loadTsConfig(configFile) {
291
- const file = await bundleTsConfig(configFile);
292
- try {
293
- return (await import((0, node_url.pathToFileURL)(file).href)).default;
294
- } finally {
295
- node_fs.default.unlink(file, () => {});
296
- }
297
- }
298
291
  async function bundleTsConfig(configFile) {
299
292
  const dirnameVarName = "injected_original_dirname";
300
293
  const filenameVarName = "injected_original_filename";
@@ -326,13 +319,15 @@ async function bundleTsConfig(configFile) {
326
319
  }
327
320
  }]
328
321
  });
322
+ const outputDir = node_path.default.dirname(configFile);
329
323
  const result = await bundle.write({
330
- dir: node_path.default.dirname(configFile),
324
+ dir: outputDir,
331
325
  format: "esm",
332
326
  sourcemap: "inline",
333
327
  entryFileNames: "rolldown.config.[hash].js"
334
328
  });
335
- return result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
329
+ const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
330
+ return node_path.default.join(outputDir, fileName);
336
331
  }
337
332
  const SUPPORTED_JS_CONFIG_FORMATS = [
338
333
  ".js",
@@ -345,12 +340,31 @@ const SUPPORTED_TS_CONFIG_FORMATS = [
345
340
  ".cts"
346
341
  ];
347
342
  const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
343
+ const DEFAULT_CONFIG_BASE = "rolldown.config";
344
+ async function findConfigFileNameInCwd() {
345
+ const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)((0, node_process.cwd)()));
346
+ for (const extension of SUPPORTED_CONFIG_FORMATS) {
347
+ const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
348
+ if (filesInWorkingDirectory.has(fileName)) return fileName;
349
+ }
350
+ throw new Error("No `rolldown.config` configuration file found.");
351
+ }
352
+ async function loadTsConfig(configFile) {
353
+ const file = await bundleTsConfig(configFile);
354
+ try {
355
+ return (await import((0, node_url.pathToFileURL)(file).href)).default;
356
+ } finally {
357
+ node_fs.default.unlink(file, () => {});
358
+ }
359
+ }
348
360
  async function loadConfig(configPath) {
349
- const ext = node_path.default.extname(configPath);
361
+ const ext = node_path.default.extname(configPath = configPath || await findConfigFileNameInCwd());
350
362
  try {
351
363
  if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import((0, node_url.pathToFileURL)(configPath).href)).default;
352
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(configPath);
353
- else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
364
+ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
365
+ const rawConfigPath = node_path.default.resolve(configPath);
366
+ return await loadTsConfig(rawConfigPath);
367
+ } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
354
368
  } catch (err) {
355
369
  throw new Error("Error happened while loading config.", { cause: err });
356
370
  }
@@ -1821,7 +1835,7 @@ function normalizeCliOptions(cliOptions, positionals) {
1821
1835
  version: options$1.version ?? false,
1822
1836
  watch: options$1.watch ?? false
1823
1837
  };
1824
- if (typeof options$1.config === "string") result.config = options$1.config ? options$1.config : "rolldown.config.js";
1838
+ if (typeof options$1.config === "string") result.config = options$1.config;
1825
1839
  const reservedKeys = [
1826
1840
  "help",
1827
1841
  "version",
@@ -2003,7 +2017,7 @@ function showHelp() {
2003
2017
  //#region src/cli/index.ts
2004
2018
  async function main() {
2005
2019
  const cliOptions = parseCliArguments();
2006
- if (cliOptions.config) {
2020
+ if (cliOptions.config || cliOptions.config === "") {
2007
2021
  await bundleWithConfig(cliOptions.config, cliOptions);
2008
2022
  return;
2009
2023
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-DvU-87mM.cjs');
3
+ const require_src = require('../shared/src-BrRo9ibF.cjs');
4
4
  const node_url = require_chunk.__toESM(require("node:url"));
5
5
 
6
6
  //#region src/plugin/parallel-plugin.ts
@@ -1,4 +1,4 @@
1
- const require_src = require('../shared/src-DvU-87mM.cjs');
1
+ const require_src = require('../shared/src-BrRo9ibF.cjs');
2
2
 
3
3
  exports.VERSION = require_src.VERSION
4
4
  exports.build = require_src.build
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-DvU-87mM.cjs');
3
+ const require_src = require('../shared/src-BrRo9ibF.cjs');
4
4
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
5
5
 
6
6
  //#region src/parallel-plugin-worker.ts
package/dist/esm/cli.mjs CHANGED
@@ -1,12 +1,13 @@
1
- import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-B74WDvF2.mjs";
2
- import { createConsola } from "../shared/consola_36c0034f-D9ce-831.mjs";
1
+ import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-CJteen6H.mjs";
2
+ import { createConsola } from "../shared/consola_36c0034f-DnM2mwLf.mjs";
3
3
  import fs from "node:fs";
4
4
  import { ZodFirstPartyTypeKind, z } from "zod";
5
5
  import path from "node:path";
6
- import process$1, { env } from "node:process";
6
+ import process$1, { cwd, env } from "node:process";
7
7
  import { performance } from "node:perf_hooks";
8
8
  import * as tty from "tty";
9
9
  import { parseArgs } from "node:util";
10
+ import { readdir } from "node:fs/promises";
10
11
  import { pathToFileURL } from "node:url";
11
12
 
12
13
  //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
@@ -284,14 +285,6 @@ function createTestingLogger() {
284
285
 
285
286
  //#endregion
286
287
  //#region src/cli/load-config.ts
287
- async function loadTsConfig(configFile) {
288
- const file = await bundleTsConfig(configFile);
289
- try {
290
- return (await import(pathToFileURL(file).href)).default;
291
- } finally {
292
- fs.unlink(file, () => {});
293
- }
294
- }
295
288
  async function bundleTsConfig(configFile) {
296
289
  const dirnameVarName = "injected_original_dirname";
297
290
  const filenameVarName = "injected_original_filename";
@@ -323,13 +316,15 @@ async function bundleTsConfig(configFile) {
323
316
  }
324
317
  }]
325
318
  });
319
+ const outputDir = path.dirname(configFile);
326
320
  const result = await bundle.write({
327
- dir: path.dirname(configFile),
321
+ dir: outputDir,
328
322
  format: "esm",
329
323
  sourcemap: "inline",
330
324
  entryFileNames: "rolldown.config.[hash].js"
331
325
  });
332
- return result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
326
+ const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
327
+ return path.join(outputDir, fileName);
333
328
  }
334
329
  const SUPPORTED_JS_CONFIG_FORMATS = [
335
330
  ".js",
@@ -342,12 +337,31 @@ const SUPPORTED_TS_CONFIG_FORMATS = [
342
337
  ".cts"
343
338
  ];
344
339
  const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
340
+ const DEFAULT_CONFIG_BASE = "rolldown.config";
341
+ async function findConfigFileNameInCwd() {
342
+ const filesInWorkingDirectory = new Set(await readdir(cwd()));
343
+ for (const extension of SUPPORTED_CONFIG_FORMATS) {
344
+ const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
345
+ if (filesInWorkingDirectory.has(fileName)) return fileName;
346
+ }
347
+ throw new Error("No `rolldown.config` configuration file found.");
348
+ }
349
+ async function loadTsConfig(configFile) {
350
+ const file = await bundleTsConfig(configFile);
351
+ try {
352
+ return (await import(pathToFileURL(file).href)).default;
353
+ } finally {
354
+ fs.unlink(file, () => {});
355
+ }
356
+ }
345
357
  async function loadConfig(configPath) {
346
- const ext = path.extname(configPath);
358
+ const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
347
359
  try {
348
360
  if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
349
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(configPath);
350
- else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
361
+ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
362
+ const rawConfigPath = path.resolve(configPath);
363
+ return await loadTsConfig(rawConfigPath);
364
+ } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
351
365
  } catch (err) {
352
366
  throw new Error("Error happened while loading config.", { cause: err });
353
367
  }
@@ -1818,7 +1832,7 @@ function normalizeCliOptions(cliOptions, positionals) {
1818
1832
  version: options$1.version ?? false,
1819
1833
  watch: options$1.watch ?? false
1820
1834
  };
1821
- if (typeof options$1.config === "string") result.config = options$1.config ? options$1.config : "rolldown.config.js";
1835
+ if (typeof options$1.config === "string") result.config = options$1.config;
1822
1836
  const reservedKeys = [
1823
1837
  "help",
1824
1838
  "version",
@@ -2000,7 +2014,7 @@ function showHelp() {
2000
2014
  //#region src/cli/index.ts
2001
2015
  async function main() {
2002
2016
  const cliOptions = parseCliArguments();
2003
- if (cliOptions.config) {
2017
+ if (cliOptions.config || cliOptions.config === "") {
2004
2018
  await bundleWithConfig(cliOptions.config, cliOptions);
2005
2019
  return;
2006
2020
  }
@@ -1,4 +1,4 @@
1
- import { BuiltinPlugin, __toESM, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-B74WDvF2.mjs";
1
+ import { BuiltinPlugin, __toESM, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-CJteen6H.mjs";
2
2
  import { pathToFileURL } from "node:url";
3
3
 
4
4
  //#region src/plugin/parallel-plugin.ts
@@ -1,3 +1,3 @@
1
- import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-B74WDvF2.mjs";
1
+ import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-CJteen6H.mjs";
2
2
 
3
3
  export { VERSION, build, defineConfig, rolldown, watch };
@@ -1,4 +1,4 @@
1
- import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src-B74WDvF2.mjs";
1
+ import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src-CJteen6H.mjs";
2
2
  import { parentPort, workerData } from "node:worker_threads";
3
3
 
4
4
  //#region src/parallel-plugin-worker.ts
@@ -298,8 +298,8 @@ function createConsola$1(options = {}) {
298
298
  //#endregion
299
299
  //#region ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
300
300
  function parseStack(stack) {
301
- const cwd = process.cwd() + sep;
302
- const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
301
+ const cwd$1 = process.cwd() + sep;
302
+ const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd$1, ""));
303
303
  return lines;
304
304
  }
305
305
  function writeStream(data, stream) {
@@ -815,7 +815,7 @@ function createConsola(options = {}) {
815
815
  defaults: { level },
816
816
  stdout: process.stdout,
817
817
  stderr: process.stderr,
818
- prompt: (...args) => import("./prompt-DlQ-08lk.mjs").then((m) => m.prompt(...args)),
818
+ prompt: (...args) => import("./prompt-DhKXGIIR.mjs").then((m) => m.prompt(...args)),
819
819
  reporters: options.reporters || [options.fancy ?? !(isCI || isTest) ? new FancyReporter() : new BasicReporter()],
820
820
  ...options
821
821
  });
@@ -1,4 +1,4 @@
1
- import { colors, getDefaultExportFromCjs, isUnicodeSupported } from "./consola_36c0034f-D9ce-831.mjs";
1
+ import { colors, getDefaultExportFromCjs, isUnicodeSupported } from "./consola_36c0034f-DnM2mwLf.mjs";
2
2
  import { stdin, stdout } from "node:process";
3
3
  import require$$0 from "tty";
4
4
  import { WriteStream } from "node:tty";
@@ -2817,7 +2817,7 @@ const watch = (input) => {
2817
2817
 
2818
2818
  //#endregion
2819
2819
  //#region package.json
2820
- var version = "1.0.0-beta.1-commit.3a0e84b";
2820
+ var version = "1.0.0-beta.1-commit.f90856a";
2821
2821
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2822
2822
 
2823
2823
  //#endregion
@@ -2843,7 +2843,7 @@ const watch = (input) => {
2843
2843
 
2844
2844
  //#endregion
2845
2845
  //#region package.json
2846
- var version = "1.0.0-beta.1-commit.3a0e84b";
2846
+ var version = "1.0.0-beta.1-commit.f90856a";
2847
2847
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2848
2848
 
2849
2849
  //#endregion