@rolldown/browser 1.0.0-beta.32 → 1.0.0-beta.34

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.
Files changed (41) hide show
  1. package/dist/cli.cjs +5 -5
  2. package/dist/cli.mjs +5 -5
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +3 -3
  7. package/dist/experimental-index.browser.mjs +34 -3
  8. package/dist/experimental-index.cjs +36 -2
  9. package/dist/experimental-index.d.cts +36 -4
  10. package/dist/experimental-index.d.mts +36 -4
  11. package/dist/experimental-index.mjs +35 -4
  12. package/dist/filter-index.d.cts +2 -2
  13. package/dist/filter-index.d.mts +2 -2
  14. package/dist/index.browser.mjs +1 -1
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.mjs +2 -2
  19. package/dist/parallel-plugin-worker.cjs +2 -2
  20. package/dist/parallel-plugin-worker.mjs +2 -2
  21. package/dist/parallel-plugin.d.cts +2 -2
  22. package/dist/parallel-plugin.d.mts +2 -2
  23. package/dist/parse-ast-index.cjs +1 -1
  24. package/dist/parse-ast-index.d.cts +1 -1
  25. package/dist/parse-ast-index.d.mts +1 -1
  26. package/dist/parse-ast-index.mjs +1 -1
  27. package/dist/rolldown-binding.wasi-browser.js +3 -0
  28. package/dist/rolldown-binding.wasi.cjs +3 -0
  29. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  30. package/dist/shared/{binding-BEeJNtY4.d.mts → binding-9k0egz6L.d.mts} +110 -10
  31. package/dist/shared/{binding-CRMJJtol.d.cts → binding-D13M6Llu.d.cts} +110 -10
  32. package/dist/shared/{define-config-Dw9PP95x.d.cts → define-config-D5AluabE.d.cts} +69 -24
  33. package/dist/shared/{define-config-rQzrgjTj.d.mts → define-config-DzIQxNqU.d.mts} +69 -24
  34. package/dist/shared/{load-config-Dv1HB87g.mjs → load-config--VYNOtUY.mjs} +1 -1
  35. package/dist/shared/{load-config-Df5heSrD.cjs → load-config-DfHD1OI9.cjs} +1 -1
  36. package/dist/shared/{parse-ast-index-CqHkFxPM.mjs → parse-ast-index-C_CZT4St.mjs} +1 -1
  37. package/dist/shared/{parse-ast-index-DAsDnaa1.cjs → parse-ast-index-ChWj_C49.cjs} +1 -1
  38. package/dist/shared/{src-ZwxjvPpL.mjs → src-B4V64IkU.mjs} +114 -95
  39. package/dist/shared/{src-BDMOiU9t.cjs → src-McCMqGpa.cjs} +125 -94
  40. package/dist/{src-ZTshMqyf.js → src-Bl12Y5ab.js} +111 -92
  41. package/package.json +19 -11
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
- const require_parse_ast_index = require('./parse-ast-index-DAsDnaa1.cjs');
2
+ const require_parse_ast_index = require('./parse-ast-index-ChWj_C49.cjs');
3
3
  const require_dist = require('./dist-CK0hotcm.cjs');
4
4
  const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
5
5
  const node_path = require_chunk.__toESM(require("node:path"));
@@ -9,22 +9,17 @@ const node_os = require_chunk.__toESM(require("node:os"));
9
9
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
10
10
 
11
11
  //#region package.json
12
- var version = "1.0.0-beta.32";
12
+ var version = "1.0.0-beta.34";
13
13
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
14
14
 
15
- //#endregion
16
- //#region src/utils/normalize-string-or-regex.ts
17
- function normalizedStringOrRegex(pattern) {
18
- if (!pattern) return void 0;
19
- if (!isReadonlyArray(pattern)) return [pattern];
20
- return pattern;
21
- }
22
- function isReadonlyArray(input) {
23
- return Array.isArray(input);
24
- }
25
-
26
15
  //#endregion
27
16
  //#region src/builtin-plugin/utils.ts
17
+ var BuiltinPlugin = class {
18
+ constructor(name, _options) {
19
+ this.name = name;
20
+ this._options = _options;
21
+ }
22
+ };
28
23
  function makeBuiltinPluginCallable(plugin) {
29
24
  let callablePlugin = new src_rolldown_binding_wasi_cjs.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
30
25
  const wrappedPlugin = plugin;
@@ -48,67 +43,6 @@ function bindingifyBuiltInPlugin(plugin) {
48
43
  };
49
44
  }
50
45
 
51
- //#endregion
52
- //#region src/builtin-plugin/constructors.ts
53
- var BuiltinPlugin = class {
54
- constructor(name, _options) {
55
- this.name = name;
56
- this._options = _options;
57
- }
58
- };
59
- function modulePreloadPolyfillPlugin(config) {
60
- return new BuiltinPlugin("builtin:module-preload-polyfill", config);
61
- }
62
- function dynamicImportVarsPlugin(config) {
63
- if (config) {
64
- config.include = normalizedStringOrRegex(config.include);
65
- config.exclude = normalizedStringOrRegex(config.exclude);
66
- }
67
- return new BuiltinPlugin("builtin:dynamic-import-vars", config);
68
- }
69
- function importGlobPlugin(config) {
70
- return new BuiltinPlugin("builtin:import-glob", config);
71
- }
72
- function reporterPlugin(config) {
73
- return new BuiltinPlugin("builtin:reporter", config);
74
- }
75
- function manifestPlugin(config) {
76
- return new BuiltinPlugin("builtin:manifest", config);
77
- }
78
- function wasmHelperPlugin(config) {
79
- return new BuiltinPlugin("builtin:wasm-helper", config);
80
- }
81
- function wasmFallbackPlugin() {
82
- const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
83
- return makeBuiltinPluginCallable(builtinPlugin);
84
- }
85
- function loadFallbackPlugin() {
86
- return new BuiltinPlugin("builtin:load-fallback");
87
- }
88
- function jsonPlugin(config) {
89
- const builtinPlugin = new BuiltinPlugin("builtin:json", config);
90
- return makeBuiltinPluginCallable(builtinPlugin);
91
- }
92
- function buildImportAnalysisPlugin(config) {
93
- return new BuiltinPlugin("builtin:build-import-analysis", config);
94
- }
95
- function viteResolvePlugin(config) {
96
- const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", config);
97
- return makeBuiltinPluginCallable(builtinPlugin);
98
- }
99
- function isolatedDeclarationPlugin(config) {
100
- return new BuiltinPlugin("builtin:isolated-declaration", config);
101
- }
102
- function assetPlugin(config) {
103
- return new BuiltinPlugin("builtin:asset", config);
104
- }
105
- function webWorkerPostPlugin() {
106
- return new BuiltinPlugin("builtin:web-worker-post");
107
- }
108
- function oxcRuntimePlugin(config) {
109
- return new BuiltinPlugin("builtin:oxc-runtime", config);
110
- }
111
-
112
46
  //#endregion
113
47
  //#region src/log/logging.ts
114
48
  const LOG_LEVEL_SILENT = "silent";
@@ -233,6 +167,75 @@ function normalizeHook(hook) {
233
167
  require_dist.unreachable("Invalid hook type");
234
168
  }
235
169
 
170
+ //#endregion
171
+ //#region src/utils/normalize-string-or-regex.ts
172
+ function normalizedStringOrRegex(pattern) {
173
+ if (!pattern) return void 0;
174
+ if (!isReadonlyArray(pattern)) return [pattern];
175
+ return pattern;
176
+ }
177
+ function isReadonlyArray(input) {
178
+ return Array.isArray(input);
179
+ }
180
+
181
+ //#endregion
182
+ //#region src/builtin-plugin/constructors.ts
183
+ function modulePreloadPolyfillPlugin(config) {
184
+ return new BuiltinPlugin("builtin:module-preload-polyfill", config);
185
+ }
186
+ function dynamicImportVarsPlugin(config) {
187
+ if (config) {
188
+ config.include = normalizedStringOrRegex(config.include);
189
+ config.exclude = normalizedStringOrRegex(config.exclude);
190
+ }
191
+ return new BuiltinPlugin("builtin:dynamic-import-vars", config);
192
+ }
193
+ function importGlobPlugin(config) {
194
+ return new BuiltinPlugin("builtin:import-glob", config);
195
+ }
196
+ function reporterPlugin(config) {
197
+ return new BuiltinPlugin("builtin:reporter", config);
198
+ }
199
+ function manifestPlugin(config) {
200
+ return new BuiltinPlugin("builtin:manifest", config);
201
+ }
202
+ function wasmHelperPlugin(config) {
203
+ return new BuiltinPlugin("builtin:wasm-helper", config);
204
+ }
205
+ function wasmFallbackPlugin() {
206
+ const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
207
+ return makeBuiltinPluginCallable(builtinPlugin);
208
+ }
209
+ function loadFallbackPlugin() {
210
+ return new BuiltinPlugin("builtin:load-fallback");
211
+ }
212
+ function jsonPlugin(config) {
213
+ const builtinPlugin = new BuiltinPlugin("builtin:json", config);
214
+ return makeBuiltinPluginCallable(builtinPlugin);
215
+ }
216
+ function buildImportAnalysisPlugin(config) {
217
+ return new BuiltinPlugin("builtin:build-import-analysis", config);
218
+ }
219
+ function viteResolvePlugin(config) {
220
+ const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", config);
221
+ return makeBuiltinPluginCallable(builtinPlugin);
222
+ }
223
+ function isolatedDeclarationPlugin(config) {
224
+ return new BuiltinPlugin("builtin:isolated-declaration", config);
225
+ }
226
+ function assetPlugin(config) {
227
+ return new BuiltinPlugin("builtin:asset", config);
228
+ }
229
+ function webWorkerPostPlugin() {
230
+ return new BuiltinPlugin("builtin:web-worker-post");
231
+ }
232
+ function oxcRuntimePlugin(config) {
233
+ return new BuiltinPlugin("builtin:oxc-runtime", config);
234
+ }
235
+ function esmExternalRequirePlugin(config) {
236
+ return new BuiltinPlugin("builtin:esm-external-require", config);
237
+ }
238
+
236
239
  //#endregion
237
240
  //#region src/constants/plugin.ts
238
241
  const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
@@ -2011,7 +2014,7 @@ const TransformOptionsSchema = object({
2011
2014
  typescript: optional(TypescriptSchema),
2012
2015
  helpers: optional(HelpersSchema),
2013
2016
  decorators: optional(DecoratorOptionSchema),
2014
- jsx: optional(JsxOptionsSchema),
2017
+ jsx: optional(union([literal("preserve"), JsxOptionsSchema])),
2015
2018
  target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
2016
2019
  });
2017
2020
  const WatchOptionsSchema = strictObject({
@@ -2039,7 +2042,8 @@ const ChecksOptionsSchema = strictObject({
2039
2042
  commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
2040
2043
  importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
2041
2044
  emptyImportMeta: pipe(optional(boolean()), description("Whether to emit warning when detecting empty import meta")),
2042
- configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
2045
+ configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict")),
2046
+ preferBuiltinFeature: pipe(optional(boolean()), description("Whether to emit warning when detecting prefer builtin feature"))
2043
2047
  });
2044
2048
  const MinifyOptionsSchema = strictObject({
2045
2049
  mangle: optional(boolean()),
@@ -2057,7 +2061,6 @@ const ResolveOptionsSchema = strictObject({
2057
2061
  mainFiles: optional(array(string())),
2058
2062
  modules: optional(array(string())),
2059
2063
  symlinks: optional(boolean()),
2060
- tsconfigFilename: optional(string()),
2061
2064
  yarnPnp: optional(boolean())
2062
2065
  });
2063
2066
  const TreeshakingOptionsSchema = union([boolean(), looseObject({
@@ -2141,7 +2144,8 @@ const InputOptionsSchema = strictObject({
2141
2144
  literal("allow-extension"),
2142
2145
  literal("exports-only"),
2143
2146
  literal(false)
2144
- ])))
2147
+ ]))),
2148
+ tsconfig: pipe(optional(string()), description("Path to the tsconfig.json file."))
2145
2149
  });
2146
2150
  const InputCliOverrideSchema = strictObject({
2147
2151
  input: pipe(optional(array(string())), description("Entry file")),
@@ -2263,7 +2267,8 @@ const OutputOptionsSchema = strictObject({
2263
2267
  preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2264
2268
  preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2265
2269
  virtualDirname: optional(string()),
2266
- minifyInternalExports: pipe(optional(boolean()), description("Minify internal exports"))
2270
+ minifyInternalExports: pipe(optional(boolean()), description("Minify internal exports")),
2271
+ topLevelVar: pipe(optional(boolean()), description("Rewrite top-level declarations to use `var`."))
2267
2272
  });
2268
2273
  const getAddonDescription = (placement, wrapper) => {
2269
2274
  return `Code to insert the ${ansis_default.bold(placement)} of the bundled file (${ansis_default.bold(wrapper)} the wrapper function)`;
@@ -2717,7 +2722,8 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
2717
2722
  ...res,
2718
2723
  external: res.external === "relative" ? require_dist.unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2719
2724
  ...info,
2720
- moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null
2725
+ moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
2726
+ packageJsonPath: res.packageJsonPath
2721
2727
  };
2722
2728
  }
2723
2729
  emitFile = (file) => {
@@ -2843,7 +2849,8 @@ function bindingifyResolveId(args$1) {
2843
2849
  id: ret.id,
2844
2850
  external: ret.external,
2845
2851
  normalizeExternalId: false,
2846
- moduleSideEffects: exist.moduleSideEffects ?? void 0
2852
+ moduleSideEffects: exist.moduleSideEffects ?? void 0,
2853
+ packageJsonPath: ret.packageJsonPath
2847
2854
  };
2848
2855
  },
2849
2856
  meta: bindingifyPluginHookMeta(meta),
@@ -3550,6 +3557,9 @@ var NormalizedInputOptionsImpl = class {
3550
3557
  get platform() {
3551
3558
  return this.inner.platform;
3552
3559
  }
3560
+ get context() {
3561
+ return this.inner.context;
3562
+ }
3553
3563
  };
3554
3564
 
3555
3565
  //#endregion
@@ -3766,7 +3776,13 @@ var NormalizedOutputOptionsImpl = class {
3766
3776
  return this.outputOptions.sourcemapPathTransform;
3767
3777
  }
3768
3778
  get minify() {
3769
- return this.inner.minify;
3779
+ let ret = this.inner.minify;
3780
+ if (typeof ret === "object" && ret !== null) {
3781
+ delete ret["codegen"];
3782
+ delete ret["module"];
3783
+ delete ret["sourcemap"];
3784
+ }
3785
+ return ret;
3770
3786
  }
3771
3787
  get legalComments() {
3772
3788
  return this.inner.legalComments;
@@ -3950,7 +3966,8 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
3950
3966
  markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData),
3951
3967
  preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
3952
3968
  optimization: inputOptions.optimization,
3953
- context: inputOptions.context
3969
+ context: inputOptions.context,
3970
+ tsconfig: inputOptions.tsconfig
3954
3971
  };
3955
3972
  }
3956
3973
  function bindingifyHmr(hmr) {
@@ -4219,12 +4236,12 @@ const availableParallelism = () => {
4219
4236
 
4220
4237
  //#endregion
4221
4238
  //#region src/utils/create-bundler-option.ts
4222
- async function createBundlerOptions(inputOptions, outputOptions, watchMode, isClose) {
4239
+ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4223
4240
  const inputPlugins = await normalizePluginOption(inputOptions.plugins);
4224
4241
  const outputPlugins = await normalizePluginOption(outputOptions.plugins);
4225
4242
  const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
4226
4243
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
4227
- if (!isClose) outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
4244
+ outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
4228
4245
  const normalizedOutputPlugins = await normalizePluginOption(outputOptions.plugins);
4229
4246
  let plugins = [
4230
4247
  ...BUILTIN_PLUGINS,
@@ -4254,8 +4271,8 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4254
4271
  //#endregion
4255
4272
  //#region src/utils/create-bundler.ts
4256
4273
  let asyncRuntimeShutdown = false;
4257
- async function createBundlerImpl(bundler, inputOptions, outputOptions, isClose) {
4258
- const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
4274
+ async function createBundlerImpl(bundler, inputOptions, outputOptions) {
4275
+ const option = await createBundlerOptions(inputOptions, outputOptions, false);
4259
4276
  if (asyncRuntimeShutdown) (0, src_rolldown_binding_wasi_cjs.startAsyncRuntime)();
4260
4277
  try {
4261
4278
  return {
@@ -4296,11 +4313,11 @@ var RolldownBuild = class {
4296
4313
  this.#bundler = new src_rolldown_binding_wasi_cjs.BindingBundler();
4297
4314
  }
4298
4315
  get closed() {
4299
- return this.#bundlerImpl?.impl.closed ?? false;
4316
+ return this.#bundlerImpl?.impl.closed ?? true;
4300
4317
  }
4301
- async #getBundlerWithStopWorker(outputOptions, isClose) {
4318
+ async #getBundlerWithStopWorker(outputOptions) {
4302
4319
  if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4303
- return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions, isClose);
4320
+ return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions);
4304
4321
  }
4305
4322
  async generate(outputOptions = {}) {
4306
4323
  validateOption("output", outputOptions);
@@ -4315,10 +4332,12 @@ var RolldownBuild = class {
4315
4332
  return transformToRollupOutput(output);
4316
4333
  }
4317
4334
  async close() {
4318
- const { impl, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4319
- await stopWorkers?.();
4320
- await impl.close();
4321
- shutdown();
4335
+ if (this.#bundlerImpl) {
4336
+ await this.#bundlerImpl.stopWorkers?.();
4337
+ await this.#bundlerImpl.impl.close();
4338
+ this.#bundlerImpl.shutdown();
4339
+ this.#bundlerImpl = void 0;
4340
+ }
4322
4341
  }
4323
4342
  async [Symbol.asyncDispose]() {
4324
4343
  await this.close();
@@ -4567,6 +4586,12 @@ Object.defineProperty(exports, 'createBundlerImpl', {
4567
4586
  return createBundlerImpl;
4568
4587
  }
4569
4588
  });
4589
+ Object.defineProperty(exports, 'createBundlerOptions', {
4590
+ enumerable: true,
4591
+ get: function () {
4592
+ return createBundlerOptions;
4593
+ }
4594
+ });
4570
4595
  Object.defineProperty(exports, 'defineConfig', {
4571
4596
  enumerable: true,
4572
4597
  get: function () {
@@ -4585,6 +4610,12 @@ Object.defineProperty(exports, 'dynamicImportVarsPlugin', {
4585
4610
  return dynamicImportVarsPlugin;
4586
4611
  }
4587
4612
  });
4613
+ Object.defineProperty(exports, 'esmExternalRequirePlugin', {
4614
+ enumerable: true,
4615
+ get: function () {
4616
+ return esmExternalRequirePlugin;
4617
+ }
4618
+ });
4588
4619
  Object.defineProperty(exports, 'getInputCliKeys', {
4589
4620
  enumerable: true,
4590
4621
  get: function () {