rolldown 1.0.0-beta.3-commit.d298c0b → 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-GI88yV1N.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-CQpWnODq.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"));
@@ -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-GI88yV1N.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-CQpWnODq.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-GI88yV1N.cjs');
2
- require('../shared/parse-ast-index-CQpWnODq.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-GI88yV1N.cjs');
4
- const require_parse_ast_index = require('../shared/parse-ast-index-CQpWnODq.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-CQpWnODq.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-Aeq00bwr.mjs";
2
- import { arraify, description, getInputCliKeys, getJsonSchema, getOutputCliKeys, rolldown, validateCliOptions, version, watch } from "../shared/src-CeA4I13P.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";
@@ -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-Aeq00bwr.mjs";
2
- import { BuiltinPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src-CeA4I13P.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-Aeq00bwr.mjs";
2
- import { VERSION, build, defineConfig, rolldown, watch } from "../shared/src-CeA4I13P.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-Aeq00bwr.mjs";
2
- import { PluginContextData, bindingifyPlugin } from "../shared/src-CeA4I13P.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-Aeq00bwr.mjs";
1
+ import { parseAst, parseAstAsync } from "../shared/parse-ast-index-DIxeQDpE.mjs";
2
2
 
3
3
  export { parseAst, parseAstAsync };
@@ -597,11 +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;
607
+ module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
608
+ module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
605
609
  module.exports.registerPlugins = nativeBinding.registerPlugins;
606
610
  module.exports.Severity = nativeBinding.Severity;
607
611
  module.exports.transform = nativeBinding.transform;
@@ -571,11 +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;
581
+ module.exports.parseSyncRaw = nativeBinding.parseSyncRaw;
582
+ module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
579
583
  module.exports.registerPlugins = nativeBinding.registerPlugins;
580
584
  module.exports.Severity = nativeBinding.Severity;
581
585
  module.exports.transform = nativeBinding.transform;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const require_chunk = require('./chunk-qZFfknuJ.cjs');
3
- const require_parse_ast_index = require('./parse-ast-index-CQpWnODq.cjs');
3
+ const require_parse_ast_index = require('./parse-ast-index-Dh_sWnMa.cjs');
4
4
  const node_path = require_chunk.__toESM(require("node:path"));
5
5
  const valibot = require_chunk.__toESM(require("valibot"));
6
6
  const __valibot_to_json_schema = require_chunk.__toESM(require("@valibot/to-json-schema"));
@@ -522,7 +522,13 @@ const InputOptionsSchema = valibot.strictObject({
522
522
  define: valibot.pipe(valibot.optional(valibot.record(valibot.string(), valibot.string())), valibot.description("Define global variables")),
523
523
  inject: valibot.optional(valibot.record(valibot.string(), valibot.union([valibot.string(), valibot.tuple([valibot.string(), valibot.string()])]))),
524
524
  profilerNames: valibot.optional(valibot.boolean()),
525
- jsx: valibot.optional(valibot.union([valibot.boolean(), JsxOptionsSchema])),
525
+ jsx: valibot.optional(valibot.union([
526
+ valibot.boolean(),
527
+ JsxOptionsSchema,
528
+ valibot.string("react"),
529
+ valibot.string("react-jsx"),
530
+ valibot.string("preserve")
531
+ ])),
526
532
  watch: valibot.optional(valibot.union([WatchOptionsSchema, valibot.literal(false)])),
527
533
  dropLabels: valibot.pipe(valibot.optional(valibot.array(valibot.string())), valibot.description("Remove labeled statements with these label names")),
528
534
  checks: valibot.optional(ChecksOptionsSchema),
@@ -547,7 +553,7 @@ const InputCliOptionsSchema = valibot.omit(valibot.strictObject({
547
553
  "profilerNames",
548
554
  "watch"
549
555
  ]);
550
- var ESTarget = function(ESTarget$1) {
556
+ var ESTarget = /* @__PURE__ */ function(ESTarget$1) {
551
557
  ESTarget$1["ES6"] = "es6";
552
558
  ESTarget$1["ES2015"] = "es2015";
553
559
  ESTarget$1["ES2016"] = "es2016";
@@ -2077,30 +2083,34 @@ function bindingifyInput(input) {
2077
2083
  if (input === void 0) return [];
2078
2084
  if (typeof input === "string") return [{ import: input }];
2079
2085
  if (Array.isArray(input)) return input.map((src) => ({ import: src }));
2080
- return Object.entries(input).map((value) => {
2086
+ return Object.entries(input).map(([name, import_path]) => {
2081
2087
  return {
2082
- name: value[0],
2083
- import: value[1]
2088
+ name,
2089
+ import: import_path
2084
2090
  };
2085
2091
  });
2086
2092
  }
2087
2093
  function bindingifyJsx(input) {
2088
- if (input === false) return { type: "Disable" };
2089
- if (input) {
2090
- if (input.mode === "preserve") return { type: "Preserve" };
2091
- const mode = input.mode ?? "automatic";
2092
- return {
2093
- type: "Enable",
2094
- field0: {
2095
- runtime: mode,
2096
- importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0,
2097
- pragma: input.factory,
2098
- pragmaFrag: input.fragment,
2099
- development: input.development,
2100
- refresh: input.refresh
2101
- }
2102
- };
2094
+ switch (input) {
2095
+ case false: return { type: "Disable" };
2096
+ case "react": return { type: "React" };
2097
+ case "react-jsx": return { type: "ReactJsx" };
2098
+ case "preserve": return { type: "Preserve" };
2099
+ case void 0: return void 0;
2103
2100
  }
2101
+ if (input.mode === "preserve") return { type: "Preserve" };
2102
+ const mode = input.mode ?? "automatic";
2103
+ return {
2104
+ type: "Enable",
2105
+ field0: {
2106
+ runtime: mode,
2107
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0,
2108
+ pragma: input.factory,
2109
+ pragmaFrag: input.fragment,
2110
+ development: input.development,
2111
+ refresh: input.refresh
2112
+ }
2113
+ };
2104
2114
  }
2105
2115
  function bindingifyWatch(watch$1) {
2106
2116
  if (watch$1) return {
@@ -2741,7 +2751,7 @@ const watch = (input) => {
2741
2751
 
2742
2752
  //#endregion
2743
2753
  //#region package.json
2744
- var version = "1.0.0-beta.3-commit.d298c0b";
2754
+ var version = "1.0.0-beta.3-commit.4666fd5";
2745
2755
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2746
2756
 
2747
2757
  //#endregion
@@ -1,4 +1,4 @@
1
- import { augmentCodeLocation, colors, error, import_binding, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-Aeq00bwr.mjs";
1
+ import { augmentCodeLocation, colors, error, import_binding, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-DIxeQDpE.mjs";
2
2
  import path from "node:path";
3
3
  import * as v from "valibot";
4
4
  import { toJsonSchema } from "@valibot/to-json-schema";
@@ -520,7 +520,13 @@ const InputOptionsSchema = v.strictObject({
520
520
  define: v.pipe(v.optional(v.record(v.string(), v.string())), v.description("Define global variables")),
521
521
  inject: v.optional(v.record(v.string(), v.union([v.string(), v.tuple([v.string(), v.string()])]))),
522
522
  profilerNames: v.optional(v.boolean()),
523
- jsx: v.optional(v.union([v.boolean(), JsxOptionsSchema])),
523
+ jsx: v.optional(v.union([
524
+ v.boolean(),
525
+ JsxOptionsSchema,
526
+ v.string("react"),
527
+ v.string("react-jsx"),
528
+ v.string("preserve")
529
+ ])),
524
530
  watch: v.optional(v.union([WatchOptionsSchema, v.literal(false)])),
525
531
  dropLabels: v.pipe(v.optional(v.array(v.string())), v.description("Remove labeled statements with these label names")),
526
532
  checks: v.optional(ChecksOptionsSchema),
@@ -545,7 +551,7 @@ const InputCliOptionsSchema = v.omit(v.strictObject({
545
551
  "profilerNames",
546
552
  "watch"
547
553
  ]);
548
- var ESTarget = function(ESTarget$1) {
554
+ var ESTarget = /* @__PURE__ */ function(ESTarget$1) {
549
555
  ESTarget$1["ES6"] = "es6";
550
556
  ESTarget$1["ES2015"] = "es2015";
551
557
  ESTarget$1["ES2016"] = "es2016";
@@ -2075,30 +2081,34 @@ function bindingifyInput(input) {
2075
2081
  if (input === void 0) return [];
2076
2082
  if (typeof input === "string") return [{ import: input }];
2077
2083
  if (Array.isArray(input)) return input.map((src) => ({ import: src }));
2078
- return Object.entries(input).map((value) => {
2084
+ return Object.entries(input).map(([name, import_path]) => {
2079
2085
  return {
2080
- name: value[0],
2081
- import: value[1]
2086
+ name,
2087
+ import: import_path
2082
2088
  };
2083
2089
  });
2084
2090
  }
2085
2091
  function bindingifyJsx(input) {
2086
- if (input === false) return { type: "Disable" };
2087
- if (input) {
2088
- if (input.mode === "preserve") return { type: "Preserve" };
2089
- const mode = input.mode ?? "automatic";
2090
- return {
2091
- type: "Enable",
2092
- field0: {
2093
- runtime: mode,
2094
- importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0,
2095
- pragma: input.factory,
2096
- pragmaFrag: input.fragment,
2097
- development: input.development,
2098
- refresh: input.refresh
2099
- }
2100
- };
2092
+ switch (input) {
2093
+ case false: return { type: "Disable" };
2094
+ case "react": return { type: "React" };
2095
+ case "react-jsx": return { type: "ReactJsx" };
2096
+ case "preserve": return { type: "Preserve" };
2097
+ case void 0: return void 0;
2101
2098
  }
2099
+ if (input.mode === "preserve") return { type: "Preserve" };
2100
+ const mode = input.mode ?? "automatic";
2101
+ return {
2102
+ type: "Enable",
2103
+ field0: {
2104
+ runtime: mode,
2105
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : void 0,
2106
+ pragma: input.factory,
2107
+ pragmaFrag: input.fragment,
2108
+ development: input.development,
2109
+ refresh: input.refresh
2110
+ }
2111
+ };
2102
2112
  }
2103
2113
  function bindingifyWatch(watch$1) {
2104
2114
  if (watch$1) return {
@@ -2739,7 +2749,7 @@ const watch = (input) => {
2739
2749
 
2740
2750
  //#endregion
2741
2751
  //#region package.json
2742
- var version = "1.0.0-beta.3-commit.d298c0b";
2752
+ var version = "1.0.0-beta.3-commit.4666fd5";
2743
2753
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2744
2754
 
2745
2755
  //#endregion
@@ -405,9 +405,12 @@ export interface BindingJsWatchChangeEvent {
405
405
  event: string
406
406
  }
407
407
 
408
+ /** TODO: support `preserve-react` mode */
408
409
  export type BindingJsx =
409
410
  | { type: 'Disable' }
410
411
  | { type: 'Preserve' }
412
+ | { type: 'React' }
413
+ | { type: 'ReactJsx' }
411
414
  | { type: 'Enable', field0: JsxOptions }
412
415
 
413
416
  export interface BindingLog {
@@ -823,6 +826,14 @@ export interface ExtensionAliasItem {
823
826
  replacements: Array<string>
824
827
  }
825
828
 
829
+ /**
830
+ * Get offset within a `Uint8Array` which is aligned on 4 GiB.
831
+ *
832
+ * Does not check that the offset is within bounds of `buffer`.
833
+ * To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
834
+ */
835
+ export declare function getBufferOffset(buffer: Uint8Array): number
836
+
826
837
  export type HelperMode = /**
827
838
  * Runtime mode (default): Helper functions are imported from a runtime package.
828
839
  *
@@ -1010,6 +1021,59 @@ export interface JsxOptions {
1010
1021
  refresh?: boolean | ReactRefreshOptions
1011
1022
  }
1012
1023
 
1024
+ /**
1025
+ * Transform JavaScript code to a Vite Node runnable module.
1026
+ *
1027
+ * @param filename The name of the file being transformed.
1028
+ * @param sourceText the source code itself
1029
+ * @param options The options for the transformation. See {@link
1030
+ * ModuleRunnerTransformOptions} for more information.
1031
+ *
1032
+ * @returns an object containing the transformed code, source maps, and any
1033
+ * errors that occurred during parsing or transformation.
1034
+ *
1035
+ * @deprecated Only works for Vite.
1036
+ */
1037
+ export declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult
1038
+
1039
+ export interface ModuleRunnerTransformOptions {
1040
+ /**
1041
+ * Enable source map generation.
1042
+ *
1043
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
1044
+ *
1045
+ * @default false
1046
+ *
1047
+ * @see {@link SourceMap}
1048
+ */
1049
+ sourcemap?: boolean
1050
+ }
1051
+
1052
+ export interface ModuleRunnerTransformResult {
1053
+ /**
1054
+ * The transformed code.
1055
+ *
1056
+ * If parsing failed, this will be an empty string.
1057
+ */
1058
+ code: string
1059
+ /**
1060
+ * The source map for the transformed code.
1061
+ *
1062
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
1063
+ */
1064
+ map?: SourceMap
1065
+ deps: Array<string>
1066
+ dynamicDeps: Array<string>
1067
+ /**
1068
+ * Parse and transformation errors.
1069
+ *
1070
+ * Oxc's parser recovers from common syntax errors, meaning that
1071
+ * transformed code may still be available even if there are errors in this
1072
+ * list.
1073
+ */
1074
+ errors: Array<OxcError>
1075
+ }
1076
+
1013
1077
  export interface OxcError {
1014
1078
  severity: Severity
1015
1079
  message: string
@@ -1028,6 +1092,14 @@ export interface ParserOptions {
1028
1092
  sourceType?: 'script' | 'module' | 'unambiguous' | undefined
1029
1093
  /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1030
1094
  lang?: 'js' | 'jsx' | 'ts' | 'tsx'
1095
+ /**
1096
+ * Return an AST which includes TypeScript-related properties, or excludes them.
1097
+ *
1098
+ * `'js'` is default for JS / JSX files.
1099
+ * `'ts'` is default for TS / TSX files.
1100
+ * The type of the file is determined from `lang` option, or extension of provided `filename`.
1101
+ */
1102
+ astType?: 'js' | 'ts'
1031
1103
  /**
1032
1104
  * Emit `ParenthesizedExpression` in AST.
1033
1105
  *
@@ -1051,6 +1123,34 @@ export interface ParserOptions {
1051
1123
  /** Parse synchronously. */
1052
1124
  export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
1053
1125
 
1126
+ /**
1127
+ * Parses AST into provided `Uint8Array` buffer.
1128
+ *
1129
+ * Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
1130
+ * provided as `source_len`.
1131
+ *
1132
+ * This function will parse the source, and write the AST into the buffer, starting at the end.
1133
+ *
1134
+ * It also writes to the very end of the buffer the offset of `Program` within the buffer.
1135
+ *
1136
+ * Caller can deserialize data from the buffer on JS side.
1137
+ *
1138
+ * # SAFETY
1139
+ *
1140
+ * Caller must ensure:
1141
+ * * Source text is written into start of the buffer.
1142
+ * * Source text's UTF-8 byte length is `source_len`.
1143
+ * * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
1144
+ *
1145
+ * If source text is originally a JS string on JS side, and converted to a buffer with
1146
+ * `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
1147
+ *
1148
+ * # Panics
1149
+ *
1150
+ * Panics if source text is too long, or AST takes more memory than is available in the buffer.
1151
+ */
1152
+ export declare function parseSyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): void
1153
+
1054
1154
  export interface PreRenderedChunk {
1055
1155
  name: string
1056
1156
  isEntry: boolean
@@ -1060,6 +1160,9 @@ export interface PreRenderedChunk {
1060
1160
  exports: Array<string>
1061
1161
  }
1062
1162
 
1163
+ /** Returns `true` if raw transfer is supported on this platform. */
1164
+ export declare function rawTransferSupported(): boolean
1165
+
1063
1166
  export interface ReactRefreshOptions {
1064
1167
  /**
1065
1168
  * Specify the identifier of the refresh registration variable.
@@ -1,3 +1,5 @@
1
1
  import type { ConfigExport } from '../types/config-export';
2
2
  export declare function loadTsConfig(configFile: string): Promise<ConfigExport>;
3
+ export declare function isFilePathESM(filePath: string): boolean;
4
+ export declare function findNearestPackageData(basedir: string): any | null;
3
5
  export declare function loadConfig(configPath: string): Promise<ConfigExport>;
@@ -156,13 +156,14 @@ export interface InputOptions {
156
156
  inject?: Record<string, string | [string, string]>;
157
157
  profilerNames?: boolean;
158
158
  /**
159
- * The `false` is disabled jsx parser, it will give you a syntax error if you use jsx syntax
160
- * The `mode: preserve` is disabled jsx transformer, it perverse original jsx syntax in the output.
161
- * The `mode: classic` is enabled jsx `classic` transformer.
162
- * The `mode: automatic` is enabled jsx `automatic` transformer.
163
- * @default mode = 'automatic'
159
+ * - `false` disables the JSX parser, resulting in a syntax error if JSX syntax is used.
160
+ * - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
161
+ * - `"react"` enables the `classic` JSX transformer.
162
+ * - `"react-jsx"` enables the `automatic` JSX transformer.
163
+ *
164
+ * @default mode = "automatic"
164
165
  */
165
- jsx?: false | JsxOptions;
166
+ jsx?: false | 'react' | 'react-jsx' | 'preserve' | JsxOptions;
166
167
  watch?: WatchOptions | false;
167
168
  dropLabels?: string[];
168
169
  keepNames?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown",
3
- "version": "1.0.0-beta.3-commit.d298c0b",
3
+ "version": "1.0.0-beta.3-commit.4666fd5",
4
4
  "description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
5
5
  "homepage": "https://rolldown.rs/",
6
6
  "repository": {
@@ -84,12 +84,12 @@
84
84
  "dtsHeader": "type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\nexport type BindingStringOrRegex = string | RegExp\n\n"
85
85
  },
86
86
  "dependencies": {
87
- "@oxc-project/types": "0.54.0",
87
+ "@oxc-project/types": "0.56.0",
88
88
  "@valibot/to-json-schema": "1.0.0-rc.0",
89
89
  "valibot": "1.0.0-rc.3"
90
90
  },
91
91
  "peerDependencies": {
92
- "@oxc-project/runtime": "0.54.0"
92
+ "@oxc-project/runtime": "0.56.0"
93
93
  },
94
94
  "peerDependenciesMeta": {
95
95
  "@oxc-project/runtime": {
@@ -122,26 +122,26 @@
122
122
  "unbuild": "^3.0.0",
123
123
  "why-is-node-running": "^3.0.0",
124
124
  "@rolldown/testing": "0.0.1",
125
- "rolldown": "1.0.0-beta.3-commit.d298c0b"
125
+ "rolldown": "1.0.0-beta.3-commit.4666fd5"
126
126
  },
127
127
  "optionalDependencies": {
128
- "@rolldown/binding-darwin-arm64": "1.0.0-beta.3-commit.d298c0b",
129
- "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.3-commit.d298c0b",
130
- "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.3-commit.d298c0b",
131
- "@rolldown/binding-darwin-x64": "1.0.0-beta.3-commit.d298c0b",
132
- "@rolldown/binding-freebsd-x64": "1.0.0-beta.3-commit.d298c0b",
133
- "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.3-commit.d298c0b",
134
- "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.3-commit.d298c0b",
135
- "@rolldown/binding-linux-x64-musl": "1.0.0-beta.3-commit.d298c0b",
136
- "@rolldown/binding-wasm32-wasi": "1.0.0-beta.3-commit.d298c0b",
137
- "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.3-commit.d298c0b",
138
- "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.3-commit.d298c0b",
139
- "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.3-commit.d298c0b"
128
+ "@rolldown/binding-darwin-x64": "1.0.0-beta.3-commit.4666fd5",
129
+ "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.3-commit.4666fd5",
130
+ "@rolldown/binding-darwin-arm64": "1.0.0-beta.3-commit.4666fd5",
131
+ "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.3-commit.4666fd5",
132
+ "@rolldown/binding-freebsd-x64": "1.0.0-beta.3-commit.4666fd5",
133
+ "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.3-commit.4666fd5",
134
+ "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.3-commit.4666fd5",
135
+ "@rolldown/binding-wasm32-wasi": "1.0.0-beta.3-commit.4666fd5",
136
+ "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.3-commit.4666fd5",
137
+ "@rolldown/binding-linux-x64-musl": "1.0.0-beta.3-commit.4666fd5",
138
+ "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.3-commit.4666fd5",
139
+ "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.3-commit.4666fd5"
140
140
  },
141
141
  "scripts": {
142
142
  "# Scrips for binding #": "_",
143
143
  "artifacts": "napi artifacts --cwd ./src --package-json-path ../package.json -o=../artifacts --npm-dir ../npm",
144
- "build-binding": "napi build -o=./src --manifest-path ../../crates/rolldown_binding/Cargo.toml --platform -p rolldown_binding --js binding.js --dts binding.d.ts --no-const-enum --no-dts-cache",
144
+ "build-binding": "node ./build-binding.js",
145
145
  "build-binding:release": "pnpm build-binding --release",
146
146
  "build-binding:wasi": "pnpm build-binding --target wasm32-wasip1-threads",
147
147
  "build-binding:wasi:release": "pnpm build-binding --profile release-wasi --target wasm32-wasip1-threads",
@@ -149,8 +149,9 @@
149
149
  "bak_build-node": "unbuild",
150
150
  "build-node": "tsx ./build.ts",
151
151
  "build-types": "tsc -p ./tsconfig.json",
152
- "build-native:debug": "run-s build-binding build-types build-node build-types-check",
153
- "build-native:release": "run-s build-binding:release build-types build-node build-types-check",
152
+ "build-js-glue": "run-s build-types build-node build-types-check",
153
+ "build-native:debug": "run-s build-binding build-js-glue",
154
+ "build-native:release": "run-s build-binding:release build-js-glue",
154
155
  "build-wasi:debug": "run-s build-binding build-binding:wasi build-node",
155
156
  "build-wasi:release": "run-s build-binding build-binding:wasi:release build-node",
156
157
  "build-types-check": "tsc -p ./tsconfig.check.json",