rolldown 1.0.0-beta.1-commit.67a0051 → 1.0.0-beta.1-commit.2fe52d4

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,9 +1,10 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-ed8l008o.cjs');
4
- const require_consola_36c0034f = require('../shared/consola_36c0034f-BBnpcLZ5.cjs');
5
- const node_fs = require_chunk.__toESM(require("node:fs"));
3
+ const require_src = require('../shared/src-Dck9jWki.cjs');
4
+ require('../shared/binding-Cw1COxB5.cjs');
5
+ const require_consola_36c0034f = require('../shared/consola_36c0034f-7VQAd79i.cjs');
6
6
  const node_path = require_chunk.__toESM(require("node:path"));
7
+ const node_fs = require_chunk.__toESM(require("node:fs"));
7
8
  const node_process = require_chunk.__toESM(require("node:process"));
8
9
  const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
9
10
  const node_util = require_chunk.__toESM(require("node:util"));
@@ -65,7 +66,7 @@ var Emitter = class {
65
66
  const i = list.indexOf(fn);
66
67
  if (i === -1) return;
67
68
  if (i === 0 && list.length === 1) list.length = 0;
68
- else list.splice(i, 1);
69
+ else list.splice(i, 1);
69
70
  }
70
71
  emit(ev, code, signal) {
71
72
  if (this.emitted[ev]) return false;
@@ -282,7 +283,7 @@ async function loadConfig(configPath) {
282
283
  const ext = node_path.default.extname(configPath = configPath || await findConfigFileNameInCwd());
283
284
  try {
284
285
  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;
285
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
286
+ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
286
287
  const rawConfigPath = node_path.default.resolve(configPath);
287
288
  return await loadTsConfig(rawConfigPath);
288
289
  } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
@@ -300,7 +301,7 @@ async function bundleWithConfig(configPath, cliOptions) {
300
301
  process.exit(1);
301
302
  }
302
303
  if (cliOptions.watch) await watchInner(config, cliOptions);
303
- else await bundleInner(config, cliOptions);
304
+ else await bundleInner(config, cliOptions);
304
305
  }
305
306
  async function bundleWithCliOptions(cliOptions) {
306
307
  if (cliOptions.output.dir || cliOptions.output.file) {
@@ -374,19 +375,17 @@ async function bundleInner(config, cliOptions) {
374
375
  const configList = require_src.arraify(config);
375
376
  for (const config$1 of configList) {
376
377
  const outputList = require_src.arraify(config$1.output || {});
377
- for (const output of outputList) {
378
- const build = await require_src.rolldown({
379
- ...config$1,
380
- ...cliOptions.input
381
- });
382
- try {
383
- result.push(await build.write({
384
- ...output,
385
- ...cliOptions.output
386
- }));
387
- } finally {
388
- await build.close();
389
- }
378
+ const build = await require_src.rolldown({
379
+ ...config$1,
380
+ ...cliOptions.input
381
+ });
382
+ for (const output of outputList) try {
383
+ result.push(await build.write({
384
+ ...output,
385
+ ...cliOptions.output
386
+ }));
387
+ } finally {
388
+ await build.close();
390
389
  }
391
390
  }
392
391
  result.forEach(printBundleOutputPretty);
@@ -520,8 +519,8 @@ function flattenSchema(schema, base = {}, parent = "") {
520
519
  for (const [k, value] of Object.entries(schema)) {
521
520
  const key = parent ? `${parent}.${k}` : k;
522
521
  if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
523
- else base[key] = value;
524
- else base[key] = value;
522
+ else base[key] = value;
523
+ else base[key] = value;
525
524
  }
526
525
  return base;
527
526
  }
@@ -578,8 +577,8 @@ function normalizeCliOptions(cliOptions, positionals) {
578
577
  const keys = key.split(".");
579
578
  const [primary] = keys;
580
579
  if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
581
- else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
582
- else if (!reservedKeys.includes(key)) {
580
+ else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
581
+ else if (!reservedKeys.includes(key)) {
583
582
  logger.error(`Unknown option: ${key}`);
584
583
  process.exit(1);
585
584
  }
@@ -602,7 +601,7 @@ const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, sc
602
601
  };
603
602
  if (config && config?.abbreviation) result.short = config?.abbreviation;
604
603
  if (config && config.reverse) if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
605
- else result.description = `disable ${result.description}`;
604
+ else result.description = `disable ${result.description}`;
606
605
  key = camelCaseToKebabCase(key);
607
606
  return [config?.reverse ? `no-${key}` : key, result];
608
607
  }));
@@ -668,7 +667,7 @@ function parseCliArguments() {
668
667
  configurable: true,
669
668
  writable: true
670
669
  });
671
- else Object.defineProperty(values, option.name, {
670
+ else Object.defineProperty(values, option.name, {
672
671
  value: option.value ?? "",
673
672
  enumerable: true,
674
673
  configurable: true,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-ed8l008o.cjs');
3
+ const require_src = require('../shared/src-Dck9jWki.cjs');
4
+ const require_binding$1 = require('../shared/binding-Cw1COxB5.cjs');
4
5
  const node_url = require_chunk.__toESM(require("node:url"));
5
6
 
6
7
  //#region src/plugin/parallel-plugin.ts
@@ -54,7 +55,7 @@ function aliasPlugin(config) {
54
55
 
55
56
  //#endregion
56
57
  //#region src/experimental-index.ts
57
- var import_binding = require_chunk.__toESM(require_src.require_binding());
58
+ var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
58
59
 
59
60
  //#endregion
60
61
  exports.aliasPlugin = aliasPlugin
@@ -1,4 +1,5 @@
1
- const require_src = require('../shared/src-ed8l008o.cjs');
1
+ const require_src = require('../shared/src-Dck9jWki.cjs');
2
+ require('../shared/binding-Cw1COxB5.cjs');
2
3
 
3
4
  exports.VERSION = require_src.VERSION
4
5
  exports.build = require_src.build
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
- const require_src = require('../shared/src-ed8l008o.cjs');
3
+ const require_src = require('../shared/src-Dck9jWki.cjs');
4
+ const require_binding$1 = require('../shared/binding-Cw1COxB5.cjs');
4
5
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
5
6
 
6
7
  //#region src/parallel-plugin-worker.ts
7
- var import_binding = require_chunk.__toESM(require_src.require_binding());
8
+ var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
8
9
  const { registryId, pluginInfos, threadNumber } = node_worker_threads.workerData;
9
10
  (async () => {
10
11
  try {
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
3
+ const require_binding$1 = require('../shared/binding-Cw1COxB5.cjs');
4
+
5
+ //#region src/parse-ast-index.ts
6
+ var import_binding = require_chunk.__toESM(require_binding$1.require_binding());
7
+ function wrap(result, sourceText) {
8
+ let program, module$1, comments, errors, magicString;
9
+ return {
10
+ get program() {
11
+ if (!errors) errors = result.errors;
12
+ if (errors.length > 0) return normalizeParseError(sourceText, errors);
13
+ if (!program) program = JSON.parse(result.program);
14
+ return program;
15
+ },
16
+ get module() {
17
+ if (!module$1) module$1 = result.module;
18
+ return module$1;
19
+ },
20
+ get comments() {
21
+ if (!comments) comments = result.comments;
22
+ return comments;
23
+ },
24
+ get errors() {
25
+ if (!errors) errors = result.errors;
26
+ return errors;
27
+ },
28
+ get magicString() {
29
+ if (!magicString) magicString = result.magicString;
30
+ return magicString;
31
+ }
32
+ };
33
+ }
34
+ function normalizeParseError(sourceText, errors) {
35
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
36
+ for (let i = 0; i < errors.length; i++) {
37
+ if (i >= 5) {
38
+ message += "\n...";
39
+ break;
40
+ }
41
+ const e = errors[i];
42
+ message += e.message + "\n" + e.labels.map((label) => {
43
+ const location = require_binding$1.locate(sourceText, label.start, { offsetLine: 1 });
44
+ if (!location) return;
45
+ return require_binding$1.getCodeFrame(sourceText, location.line, location.column);
46
+ }).filter(Boolean).join("\n");
47
+ }
48
+ return require_binding$1.error(require_binding$1.logParseError(message));
49
+ }
50
+ function parseAst(filename, sourceText, options) {
51
+ return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText);
52
+ }
53
+ async function parseAstAsync(filename, sourceText, options) {
54
+ return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText);
55
+ }
56
+
57
+ //#endregion
58
+ exports.parseAst = parseAst
59
+ exports.parseAstAsync = parseAstAsync
package/dist/esm/cli.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { arraify, colors, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-BvPrj1a4.mjs";
2
- import { createConsola } from "../shared/consola_36c0034f-BwyQ494_.mjs";
3
- import fs from "node:fs";
1
+ import "../shared/binding-BMSG-hw7.mjs";
2
+ import { arraify, colors, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-genj5En-.mjs";
3
+ import { createConsola } from "../shared/consola_36c0034f-DJFB73x3.mjs";
4
4
  import path from "node:path";
5
+ import fs from "node:fs";
5
6
  import process$1, { cwd } from "node:process";
6
7
  import { performance } from "node:perf_hooks";
7
8
  import { parseArgs } from "node:util";
@@ -62,7 +63,7 @@ var Emitter = class {
62
63
  const i = list.indexOf(fn);
63
64
  if (i === -1) return;
64
65
  if (i === 0 && list.length === 1) list.length = 0;
65
- else list.splice(i, 1);
66
+ else list.splice(i, 1);
66
67
  }
67
68
  emit(ev, code, signal) {
68
69
  if (this.emitted[ev]) return false;
@@ -279,7 +280,7 @@ async function loadConfig(configPath) {
279
280
  const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
280
281
  try {
281
282
  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;
282
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
283
+ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
283
284
  const rawConfigPath = path.resolve(configPath);
284
285
  return await loadTsConfig(rawConfigPath);
285
286
  } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
@@ -297,7 +298,7 @@ async function bundleWithConfig(configPath, cliOptions) {
297
298
  process.exit(1);
298
299
  }
299
300
  if (cliOptions.watch) await watchInner(config, cliOptions);
300
- else await bundleInner(config, cliOptions);
301
+ else await bundleInner(config, cliOptions);
301
302
  }
302
303
  async function bundleWithCliOptions(cliOptions) {
303
304
  if (cliOptions.output.dir || cliOptions.output.file) {
@@ -371,19 +372,17 @@ async function bundleInner(config, cliOptions) {
371
372
  const configList = arraify(config);
372
373
  for (const config$1 of configList) {
373
374
  const outputList = arraify(config$1.output || {});
374
- for (const output of outputList) {
375
- const build = await rolldown({
376
- ...config$1,
377
- ...cliOptions.input
378
- });
379
- try {
380
- result.push(await build.write({
381
- ...output,
382
- ...cliOptions.output
383
- }));
384
- } finally {
385
- await build.close();
386
- }
375
+ const build = await rolldown({
376
+ ...config$1,
377
+ ...cliOptions.input
378
+ });
379
+ for (const output of outputList) try {
380
+ result.push(await build.write({
381
+ ...output,
382
+ ...cliOptions.output
383
+ }));
384
+ } finally {
385
+ await build.close();
387
386
  }
388
387
  }
389
388
  result.forEach(printBundleOutputPretty);
@@ -517,8 +516,8 @@ function flattenSchema(schema, base = {}, parent = "") {
517
516
  for (const [k, value] of Object.entries(schema)) {
518
517
  const key = parent ? `${parent}.${k}` : k;
519
518
  if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
520
- else base[key] = value;
521
- else base[key] = value;
519
+ else base[key] = value;
520
+ else base[key] = value;
522
521
  }
523
522
  return base;
524
523
  }
@@ -575,8 +574,8 @@ function normalizeCliOptions(cliOptions, positionals) {
575
574
  const keys = key.split(".");
576
575
  const [primary] = keys;
577
576
  if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
578
- else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
579
- else if (!reservedKeys.includes(key)) {
577
+ else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
578
+ else if (!reservedKeys.includes(key)) {
580
579
  logger.error(`Unknown option: ${key}`);
581
580
  process.exit(1);
582
581
  }
@@ -599,7 +598,7 @@ const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, sc
599
598
  };
600
599
  if (config && config?.abbreviation) result.short = config?.abbreviation;
601
600
  if (config && config.reverse) if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
602
- else result.description = `disable ${result.description}`;
601
+ else result.description = `disable ${result.description}`;
603
602
  key = camelCaseToKebabCase(key);
604
603
  return [config?.reverse ? `no-${key}` : key, result];
605
604
  }));
@@ -665,7 +664,7 @@ function parseCliArguments() {
665
664
  configurable: true,
666
665
  writable: true
667
666
  });
668
- else Object.defineProperty(values, option.name, {
667
+ else Object.defineProperty(values, option.name, {
669
668
  value: option.value ?? "",
670
669
  enumerable: true,
671
670
  configurable: true,
@@ -1,4 +1,5 @@
1
- import { BuiltinPlugin, __toESM, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-BvPrj1a4.mjs";
1
+ import { __toESM, require_binding } from "../shared/binding-BMSG-hw7.mjs";
2
+ import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-genj5En-.mjs";
2
3
  import { pathToFileURL } from "node:url";
3
4
 
4
5
  //#region src/plugin/parallel-plugin.ts
@@ -1,3 +1,4 @@
1
- import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-BvPrj1a4.mjs";
1
+ import "../shared/binding-BMSG-hw7.mjs";
2
+ import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-genj5En-.mjs";
2
3
 
3
4
  export { VERSION, build, defineConfig, rolldown, watch };
@@ -1,4 +1,5 @@
1
- import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src-BvPrj1a4.mjs";
1
+ import { __toESM, require_binding } from "../shared/binding-BMSG-hw7.mjs";
2
+ import { PluginContextData, bindingifyPlugin } from "../shared/src-genj5En-.mjs";
2
3
  import { parentPort, workerData } from "node:worker_threads";
3
4
 
4
5
  //#region src/parallel-plugin-worker.ts
@@ -0,0 +1,56 @@
1
+ import { __toESM, error, getCodeFrame, locate, logParseError, require_binding } from "../shared/binding-BMSG-hw7.mjs";
2
+
3
+ //#region src/parse-ast-index.ts
4
+ var import_binding = __toESM(require_binding());
5
+ function wrap(result, sourceText) {
6
+ let program, module, comments, errors, magicString;
7
+ return {
8
+ get program() {
9
+ if (!errors) errors = result.errors;
10
+ if (errors.length > 0) return normalizeParseError(sourceText, errors);
11
+ if (!program) program = JSON.parse(result.program);
12
+ return program;
13
+ },
14
+ get module() {
15
+ if (!module) module = result.module;
16
+ return module;
17
+ },
18
+ get comments() {
19
+ if (!comments) comments = result.comments;
20
+ return comments;
21
+ },
22
+ get errors() {
23
+ if (!errors) errors = result.errors;
24
+ return errors;
25
+ },
26
+ get magicString() {
27
+ if (!magicString) magicString = result.magicString;
28
+ return magicString;
29
+ }
30
+ };
31
+ }
32
+ function normalizeParseError(sourceText, errors) {
33
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
34
+ for (let i = 0; i < errors.length; i++) {
35
+ if (i >= 5) {
36
+ message += "\n...";
37
+ break;
38
+ }
39
+ const e = errors[i];
40
+ message += e.message + "\n" + e.labels.map((label) => {
41
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
42
+ if (!location) return;
43
+ return getCodeFrame(sourceText, location.line, location.column);
44
+ }).filter(Boolean).join("\n");
45
+ }
46
+ return error(logParseError(message));
47
+ }
48
+ function parseAst(filename, sourceText, options) {
49
+ return wrap((0, import_binding.parseSync)(filename, sourceText, options), sourceText);
50
+ }
51
+ async function parseAstAsync(filename, sourceText, options) {
52
+ return wrap(await (0, import_binding.parseAsync)(filename, sourceText, options), sourceText);
53
+ }
54
+
55
+ //#endregion
56
+ export { parseAst, parseAstAsync };