rolldown 0.12.2-snapshot-a2bb2ca-20240811003152 → 0.12.2-snapshot-e65c643-20240811191124

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { __toESM } = require("./chunk-whRFQvSK.cjs");
4
- const { LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_WARN, PluginContextData, arraify, bindingifyPlugin, error, getLogHandler, isNullish, logLevelPriority, logPluginError, normalizeHook, normalizeLog, require_binding, transformToRollupOutput, unimplemented } = require("./plugin-context-data-1VeqieJQ.cjs");
4
+ const { LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_WARN, PluginContextData, arraify, bindingifyPlugin, error, getLogHandler, isNullish, logLevelPriority, logPluginError, normalizeHook, normalizeLog, require_binding, transformToRollupOutput, unimplemented } = require("./plugin-context-data-DXDLCu7_.cjs");
5
5
  const { default: nodePath, default: path } = __toESM(require("node:path"));
6
6
  const { isRegExp, isRegExp: isRegExp$1 } = __toESM(require("node:util/types"));
7
7
  const { Worker } = __toESM(require("node:worker_threads"));
@@ -189,7 +189,31 @@ function bindingifyInputOptions(options, outputOptions) {
189
189
  },
190
190
  treeshake: options.treeshake,
191
191
  moduleTypes: options.moduleTypes,
192
- define: options.define ? Object.entries(options.define) : undefined
192
+ define: options.define ? Object.entries(options.define) : undefined,
193
+ inject: options.inject ? (Object.entries(options.inject)).map(([alias, item]) => {
194
+ if (Array.isArray(item)) {
195
+ if (item[1] === "*") {
196
+ return {
197
+ tagNamespace: true,
198
+ alias,
199
+ from: item[0]
200
+ };
201
+ }
202
+ return {
203
+ tagNamed: true,
204
+ alias,
205
+ from: item[0],
206
+ imported: item[1]
207
+ };
208
+ } else {
209
+ return {
210
+ tagNamed: true,
211
+ imported: "default",
212
+ alias,
213
+ from: item
214
+ };
215
+ }
216
+ }) : undefined
193
217
  };
194
218
  }
195
219
  function bindingifyLogLevel(logLevel) {
@@ -384,7 +408,7 @@ class PluginDriver {
384
408
  const name = plugin.name || "unknown";
385
409
  const options = plugin.options;
386
410
  if (options) {
387
- const [handler, _optionsIgnoredSofar] = normalizeHook(options);
411
+ const { handler: handler } = normalizeHook(options);
388
412
  const result = await handler.call({
389
413
  debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
390
414
  error: (e) => error(logPluginError(normalizeLog(e), name, {hook: "onLog"})),
@@ -403,7 +427,7 @@ class PluginDriver {
403
427
  for (const plugin of plugins) {
404
428
  const options = plugin.outputOptions;
405
429
  if (options) {
406
- const [handler, _optionsIgnoredSofar] = normalizeHook(options);
430
+ const { handler: handler } = normalizeHook(options);
407
431
  const result = handler.call(null, outputOptions);
408
432
  if (result) {
409
433
  outputOptions = result;
@@ -459,7 +483,7 @@ function normalizeTreeshakeOptions(config) {
459
483
  }
460
484
 
461
485
  //#endregion
462
- //#region ../../node_modules/.pnpm/remeda@2.10.0/node_modules/remeda/dist/chunk-K26VP6CL.js
486
+ //#region ../../node_modules/.pnpm/remeda@2.10.1/node_modules/remeda/dist/chunk-K26VP6CL.js
463
487
  function u$1(t$1, n, a) {
464
488
  let o = (r) => t$1(r, ...n);
465
489
  return a === void 0 ? o : Object.assign(o, {
@@ -469,7 +493,7 @@ function u$1(t$1, n, a) {
469
493
  }
470
494
 
471
495
  //#endregion
472
- //#region ../../node_modules/.pnpm/remeda@2.10.0/node_modules/remeda/dist/chunk-RAAYCPUM.js
496
+ //#region ../../node_modules/.pnpm/remeda@2.10.1/node_modules/remeda/dist/chunk-RAAYCPUM.js
473
497
  function u(r, n, a) {
474
498
  let o = r.length - n.length;
475
499
  if (o === 0) return r(...n);
@@ -478,7 +502,7 @@ function u(r, n, a) {
478
502
  }
479
503
 
480
504
  //#endregion
481
- //#region ../../node_modules/.pnpm/remeda@2.10.0/node_modules/remeda/dist/chunk-NMJS7ULY.js
505
+ //#region ../../node_modules/.pnpm/remeda@2.10.1/node_modules/remeda/dist/chunk-NMJS7ULY.js
482
506
  function t(...n) {
483
507
  return u(Object.keys, n);
484
508
  }
@@ -555,7 +579,7 @@ function createComposedPlugin(plugins) {
555
579
  const batchedHandlers = batchedHooks.buildStart;
556
580
  composed.buildStart = async function(options) {
557
581
  await Promise.all(batchedHandlers.map((handler) => {
558
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
582
+ const { handler: handlerFn } = normalizeHook(handler);
559
583
  return handlerFn.call(this, options);
560
584
  }));
561
585
  };
@@ -567,7 +591,7 @@ function createComposedPlugin(plugins) {
567
591
  const batchedHandlers = batchedHooks.load;
568
592
  composed.load = async function(id) {
569
593
  for (const handler of batchedHandlers) {
570
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
594
+ const { handler: handlerFn } = normalizeHook(handler);
571
595
  const result = await handlerFn.call(this, id);
572
596
  if (!isNullish(result)) {
573
597
  return result;
@@ -588,7 +612,7 @@ function createComposedPlugin(plugins) {
588
612
  moduleSideEffects = newModuleSideEffects ?? undefined;
589
613
  }
590
614
  for (const handler of batchedHandlers) {
591
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
615
+ const { handler: handlerFn } = normalizeHook(handler);
592
616
  const result = await handlerFn.call(this, code, id, moduleType);
593
617
  if (!isNullish(result)) {
594
618
  if (typeof result === "string") {
@@ -613,7 +637,7 @@ function createComposedPlugin(plugins) {
613
637
  const batchedHandlers = batchedHooks.buildEnd;
614
638
  composed.buildEnd = async function(err) {
615
639
  await Promise.all(batchedHandlers.map((handler) => {
616
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
640
+ const { handler: handlerFn } = normalizeHook(handler);
617
641
  return handlerFn.call(this, err);
618
642
  }));
619
643
  };
@@ -625,7 +649,7 @@ function createComposedPlugin(plugins) {
625
649
  const batchedHandlers = batchedHooks.renderChunk;
626
650
  composed.renderChunk = async function(code, chunk, options) {
627
651
  for (const handler of batchedHandlers) {
628
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
652
+ const { handler: handlerFn } = normalizeHook(handler);
629
653
  const result = await handlerFn.call(this, code, chunk, options);
630
654
  if (!isNullish(result)) {
631
655
  return result;
@@ -647,7 +671,24 @@ function isComposablePlugin(plugin) {
647
671
  if ("_parallel"in plugin) {
648
672
  return false;
649
673
  }
650
- if ((t(plugin)).some((hookName) => isUnsupportedHooks(hookName))) {
674
+ const hasNotComposablePattern = (t(plugin)).some((hookName) => {
675
+ const OK_TO_COMPOSE = false;
676
+ switch (hookName) {
677
+ case "name":
678
+ case "api": return OK_TO_COMPOSE;
679
+ }
680
+ if (isUnsupportedHooks(hookName)) {
681
+ return !OK_TO_COMPOSE;
682
+ }
683
+ if (plugin[hookName]) {
684
+ const { meta: meta } = normalizeHook(plugin[hookName]);
685
+ if (meta.order === "pre" || meta.order === "post") {
686
+ return !OK_TO_COMPOSE;
687
+ }
688
+ }
689
+ return OK_TO_COMPOSE;
690
+ });
691
+ if (hasNotComposablePattern) {
651
692
  return false;
652
693
  }
653
694
  return true;
@@ -1,6 +1,6 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_WARN, PluginContextData, __toESM, arraify, bindingifyPlugin, error, getLogHandler, isNullish, logLevelPriority, logPluginError, normalizeHook, normalizeLog, require_binding, transformToRollupOutput, unimplemented } from "./plugin-context-data-N8cNBCJA.mjs";
3
+ import { LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_WARN, PluginContextData, __toESM, arraify, bindingifyPlugin, error, getLogHandler, isNullish, logLevelPriority, logPluginError, normalizeHook, normalizeLog, require_binding, transformToRollupOutput, unimplemented } from "./plugin-context-data-ymCbOD0T.mjs";
4
4
  import { default as nodePath, default as path } from "node:path";
5
5
  import { isRegExp, isRegExp as isRegExp$1 } from "node:util/types";
6
6
  import { Worker } from "node:worker_threads";
@@ -188,7 +188,31 @@ function bindingifyInputOptions(options, outputOptions) {
188
188
  },
189
189
  treeshake: options.treeshake,
190
190
  moduleTypes: options.moduleTypes,
191
- define: options.define ? Object.entries(options.define) : undefined
191
+ define: options.define ? Object.entries(options.define) : undefined,
192
+ inject: options.inject ? (Object.entries(options.inject)).map(([alias, item]) => {
193
+ if (Array.isArray(item)) {
194
+ if (item[1] === "*") {
195
+ return {
196
+ tagNamespace: true,
197
+ alias,
198
+ from: item[0]
199
+ };
200
+ }
201
+ return {
202
+ tagNamed: true,
203
+ alias,
204
+ from: item[0],
205
+ imported: item[1]
206
+ };
207
+ } else {
208
+ return {
209
+ tagNamed: true,
210
+ imported: "default",
211
+ alias,
212
+ from: item
213
+ };
214
+ }
215
+ }) : undefined
192
216
  };
193
217
  }
194
218
  function bindingifyLogLevel(logLevel) {
@@ -383,7 +407,7 @@ class PluginDriver {
383
407
  const name = plugin.name || "unknown";
384
408
  const options = plugin.options;
385
409
  if (options) {
386
- const [handler, _optionsIgnoredSofar] = normalizeHook(options);
410
+ const { handler: handler } = normalizeHook(options);
387
411
  const result = await handler.call({
388
412
  debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
389
413
  error: (e) => error(logPluginError(normalizeLog(e), name, {hook: "onLog"})),
@@ -402,7 +426,7 @@ class PluginDriver {
402
426
  for (const plugin of plugins) {
403
427
  const options = plugin.outputOptions;
404
428
  if (options) {
405
- const [handler, _optionsIgnoredSofar] = normalizeHook(options);
429
+ const { handler: handler } = normalizeHook(options);
406
430
  const result = handler.call(null, outputOptions);
407
431
  if (result) {
408
432
  outputOptions = result;
@@ -458,7 +482,7 @@ function normalizeTreeshakeOptions(config) {
458
482
  }
459
483
 
460
484
  //#endregion
461
- //#region ../../node_modules/.pnpm/remeda@2.10.0/node_modules/remeda/dist/chunk-K26VP6CL.js
485
+ //#region ../../node_modules/.pnpm/remeda@2.10.1/node_modules/remeda/dist/chunk-K26VP6CL.js
462
486
  function u$1(t$1, n, a) {
463
487
  let o = (r) => t$1(r, ...n);
464
488
  return a === void 0 ? o : Object.assign(o, {
@@ -468,7 +492,7 @@ function u$1(t$1, n, a) {
468
492
  }
469
493
 
470
494
  //#endregion
471
- //#region ../../node_modules/.pnpm/remeda@2.10.0/node_modules/remeda/dist/chunk-RAAYCPUM.js
495
+ //#region ../../node_modules/.pnpm/remeda@2.10.1/node_modules/remeda/dist/chunk-RAAYCPUM.js
472
496
  function u(r, n, a) {
473
497
  let o = r.length - n.length;
474
498
  if (o === 0) return r(...n);
@@ -477,7 +501,7 @@ function u(r, n, a) {
477
501
  }
478
502
 
479
503
  //#endregion
480
- //#region ../../node_modules/.pnpm/remeda@2.10.0/node_modules/remeda/dist/chunk-NMJS7ULY.js
504
+ //#region ../../node_modules/.pnpm/remeda@2.10.1/node_modules/remeda/dist/chunk-NMJS7ULY.js
481
505
  function t(...n) {
482
506
  return u(Object.keys, n);
483
507
  }
@@ -554,7 +578,7 @@ function createComposedPlugin(plugins) {
554
578
  const batchedHandlers = batchedHooks.buildStart;
555
579
  composed.buildStart = async function(options) {
556
580
  await Promise.all(batchedHandlers.map((handler) => {
557
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
581
+ const { handler: handlerFn } = normalizeHook(handler);
558
582
  return handlerFn.call(this, options);
559
583
  }));
560
584
  };
@@ -566,7 +590,7 @@ function createComposedPlugin(plugins) {
566
590
  const batchedHandlers = batchedHooks.load;
567
591
  composed.load = async function(id) {
568
592
  for (const handler of batchedHandlers) {
569
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
593
+ const { handler: handlerFn } = normalizeHook(handler);
570
594
  const result = await handlerFn.call(this, id);
571
595
  if (!isNullish(result)) {
572
596
  return result;
@@ -587,7 +611,7 @@ function createComposedPlugin(plugins) {
587
611
  moduleSideEffects = newModuleSideEffects ?? undefined;
588
612
  }
589
613
  for (const handler of batchedHandlers) {
590
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
614
+ const { handler: handlerFn } = normalizeHook(handler);
591
615
  const result = await handlerFn.call(this, code, id, moduleType);
592
616
  if (!isNullish(result)) {
593
617
  if (typeof result === "string") {
@@ -612,7 +636,7 @@ function createComposedPlugin(plugins) {
612
636
  const batchedHandlers = batchedHooks.buildEnd;
613
637
  composed.buildEnd = async function(err) {
614
638
  await Promise.all(batchedHandlers.map((handler) => {
615
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
639
+ const { handler: handlerFn } = normalizeHook(handler);
616
640
  return handlerFn.call(this, err);
617
641
  }));
618
642
  };
@@ -624,7 +648,7 @@ function createComposedPlugin(plugins) {
624
648
  const batchedHandlers = batchedHooks.renderChunk;
625
649
  composed.renderChunk = async function(code, chunk, options) {
626
650
  for (const handler of batchedHandlers) {
627
- const [handlerFn, _handlerOptions] = normalizeHook(handler);
651
+ const { handler: handlerFn } = normalizeHook(handler);
628
652
  const result = await handlerFn.call(this, code, chunk, options);
629
653
  if (!isNullish(result)) {
630
654
  return result;
@@ -646,7 +670,24 @@ function isComposablePlugin(plugin) {
646
670
  if ("_parallel"in plugin) {
647
671
  return false;
648
672
  }
649
- if ((t(plugin)).some((hookName) => isUnsupportedHooks(hookName))) {
673
+ const hasNotComposablePattern = (t(plugin)).some((hookName) => {
674
+ const OK_TO_COMPOSE = false;
675
+ switch (hookName) {
676
+ case "name":
677
+ case "api": return OK_TO_COMPOSE;
678
+ }
679
+ if (isUnsupportedHooks(hookName)) {
680
+ return !OK_TO_COMPOSE;
681
+ }
682
+ if (plugin[hookName]) {
683
+ const { meta: meta } = normalizeHook(plugin[hookName]);
684
+ if (meta.order === "pre" || meta.order === "post") {
685
+ return !OK_TO_COMPOSE;
686
+ }
687
+ }
688
+ return OK_TO_COMPOSE;
689
+ });
690
+ if (hasNotComposablePattern) {
650
691
  return false;
651
692
  }
652
693
  return true;
@@ -94,57 +94,59 @@ function __napi_rs_initialize_modules(__napiInstance) {
94
94
  __napiInstance.exports['__napi_register__transform_9']?.()
95
95
  __napiInstance.exports['__napi_register__Bundler_struct_0']?.()
96
96
  __napiInstance.exports['__napi_register__Bundler_impl_5']?.()
97
- __napiInstance.exports['__napi_register__BindingInputItem_struct_6']?.()
98
- __napiInstance.exports['__napi_register__BindingResolveOptions_struct_7']?.()
99
- __napiInstance.exports['__napi_register__BindingTreeshake_struct_8']?.()
100
- __napiInstance.exports['__napi_register__BindingInputOptions_struct_9']?.()
101
- __napiInstance.exports['__napi_register__BindingOutputOptions_struct_10']?.()
102
- __napiInstance.exports['__napi_register__BindingPluginContext_struct_11']?.()
103
- __napiInstance.exports['__napi_register__BindingPluginContext_impl_17']?.()
104
- __napiInstance.exports['__napi_register__BindingPluginContextResolvedId_struct_18']?.()
105
- __napiInstance.exports['__napi_register__BindingPluginOptions_struct_19']?.()
106
- __napiInstance.exports['__napi_register__BindingPluginWithIndex_struct_20']?.()
107
- __napiInstance.exports['__napi_register__BindingTransformPluginContext_struct_21']?.()
108
- __napiInstance.exports['__napi_register__BindingTransformPluginContext_impl_23']?.()
109
- __napiInstance.exports['__napi_register__BindingAssetSource_struct_24']?.()
110
- __napiInstance.exports['__napi_register__BindingEmittedAsset_struct_25']?.()
111
- __napiInstance.exports['__napi_register__BindingHookLoadOutput_struct_26']?.()
112
- __napiInstance.exports['__napi_register__BindingHookRenderChunkOutput_struct_27']?.()
113
- __napiInstance.exports['__napi_register__BindingHookResolveIdExtraArgs_struct_28']?.()
114
- __napiInstance.exports['__napi_register__BindingHookResolveIdOutput_struct_29']?.()
115
- __napiInstance.exports['__napi_register__BindingHookSideEffects_30']?.()
116
- __napiInstance.exports['__napi_register__BindingHookTransformOutput_struct_31']?.()
117
- __napiInstance.exports['__napi_register__BindingStringOrRegex_struct_32']?.()
118
- __napiInstance.exports['__napi_register__BindingPluginContextResolveOptions_struct_33']?.()
119
- __napiInstance.exports['__napi_register__BindingTransformHookExtraArgs_struct_34']?.()
120
- __napiInstance.exports['__napi_register__BindingBuiltinPlugin_struct_35']?.()
121
- __napiInstance.exports['__napi_register__BindingBuiltinPluginName_36']?.()
122
- __napiInstance.exports['__napi_register__BindingGlobImportPluginConfig_struct_37']?.()
123
- __napiInstance.exports['__napi_register__BindingManifestPluginConfig_struct_38']?.()
124
- __napiInstance.exports['__napi_register__BindingModulePreloadPolyfillPluginConfig_struct_39']?.()
125
- __napiInstance.exports['__napi_register__BindingTransformPluginConfig_struct_40']?.()
126
- __napiInstance.exports['__napi_register__BindingPluginOrder_41']?.()
127
- __napiInstance.exports['__napi_register__BindingPluginHookMeta_struct_42']?.()
128
- __napiInstance.exports['__napi_register__ParallelJsPluginRegistry_struct_43']?.()
129
- __napiInstance.exports['__napi_register__ParallelJsPluginRegistry_impl_45']?.()
130
- __napiInstance.exports['__napi_register__register_plugins_46']?.()
131
- __napiInstance.exports['__napi_register__BindingLog_struct_47']?.()
132
- __napiInstance.exports['__napi_register__BindingLogLevel_48']?.()
133
- __napiInstance.exports['__napi_register__BindingModuleInfo_struct_49']?.()
134
- __napiInstance.exports['__napi_register__BindingModuleInfo_impl_51']?.()
135
- __napiInstance.exports['__napi_register__BindingOutputAsset_struct_52']?.()
136
- __napiInstance.exports['__napi_register__BindingOutputAsset_impl_57']?.()
137
- __napiInstance.exports['__napi_register__BindingOutputChunk_struct_58']?.()
138
- __napiInstance.exports['__napi_register__BindingOutputChunk_impl_76']?.()
139
- __napiInstance.exports['__napi_register__BindingOutputs_struct_77']?.()
140
- __napiInstance.exports['__napi_register__BindingOutputs_impl_81']?.()
141
- __napiInstance.exports['__napi_register__FinalBindingOutputs_struct_82']?.()
142
- __napiInstance.exports['__napi_register__FinalBindingOutputs_impl_85']?.()
143
- __napiInstance.exports['__napi_register__RenderedChunk_struct_86']?.()
144
- __napiInstance.exports['__napi_register__BindingRenderedModule_struct_87']?.()
145
- __napiInstance.exports['__napi_register__AliasItem_struct_88']?.()
146
- __napiInstance.exports['__napi_register__BindingSourcemap_struct_89']?.()
147
- __napiInstance.exports['__napi_register__BindingJsonSourcemap_struct_90']?.()
97
+ __napiInstance.exports['__napi_register__BindingInjectImportNamed_struct_6']?.()
98
+ __napiInstance.exports['__napi_register__BindingInjectImportNamespace_struct_7']?.()
99
+ __napiInstance.exports['__napi_register__BindingInputItem_struct_8']?.()
100
+ __napiInstance.exports['__napi_register__BindingResolveOptions_struct_9']?.()
101
+ __napiInstance.exports['__napi_register__BindingTreeshake_struct_10']?.()
102
+ __napiInstance.exports['__napi_register__BindingInputOptions_struct_11']?.()
103
+ __napiInstance.exports['__napi_register__BindingOutputOptions_struct_12']?.()
104
+ __napiInstance.exports['__napi_register__BindingPluginContext_struct_13']?.()
105
+ __napiInstance.exports['__napi_register__BindingPluginContext_impl_19']?.()
106
+ __napiInstance.exports['__napi_register__BindingPluginContextResolvedId_struct_20']?.()
107
+ __napiInstance.exports['__napi_register__BindingPluginOptions_struct_21']?.()
108
+ __napiInstance.exports['__napi_register__BindingPluginWithIndex_struct_22']?.()
109
+ __napiInstance.exports['__napi_register__BindingTransformPluginContext_struct_23']?.()
110
+ __napiInstance.exports['__napi_register__BindingTransformPluginContext_impl_25']?.()
111
+ __napiInstance.exports['__napi_register__BindingAssetSource_struct_26']?.()
112
+ __napiInstance.exports['__napi_register__BindingEmittedAsset_struct_27']?.()
113
+ __napiInstance.exports['__napi_register__BindingHookLoadOutput_struct_28']?.()
114
+ __napiInstance.exports['__napi_register__BindingHookRenderChunkOutput_struct_29']?.()
115
+ __napiInstance.exports['__napi_register__BindingHookResolveIdExtraArgs_struct_30']?.()
116
+ __napiInstance.exports['__napi_register__BindingHookResolveIdOutput_struct_31']?.()
117
+ __napiInstance.exports['__napi_register__BindingHookSideEffects_32']?.()
118
+ __napiInstance.exports['__napi_register__BindingHookTransformOutput_struct_33']?.()
119
+ __napiInstance.exports['__napi_register__BindingStringOrRegex_struct_34']?.()
120
+ __napiInstance.exports['__napi_register__BindingPluginContextResolveOptions_struct_35']?.()
121
+ __napiInstance.exports['__napi_register__BindingTransformHookExtraArgs_struct_36']?.()
122
+ __napiInstance.exports['__napi_register__BindingBuiltinPlugin_struct_37']?.()
123
+ __napiInstance.exports['__napi_register__BindingBuiltinPluginName_38']?.()
124
+ __napiInstance.exports['__napi_register__BindingGlobImportPluginConfig_struct_39']?.()
125
+ __napiInstance.exports['__napi_register__BindingManifestPluginConfig_struct_40']?.()
126
+ __napiInstance.exports['__napi_register__BindingModulePreloadPolyfillPluginConfig_struct_41']?.()
127
+ __napiInstance.exports['__napi_register__BindingTransformPluginConfig_struct_42']?.()
128
+ __napiInstance.exports['__napi_register__BindingPluginOrder_43']?.()
129
+ __napiInstance.exports['__napi_register__BindingPluginHookMeta_struct_44']?.()
130
+ __napiInstance.exports['__napi_register__ParallelJsPluginRegistry_struct_45']?.()
131
+ __napiInstance.exports['__napi_register__ParallelJsPluginRegistry_impl_47']?.()
132
+ __napiInstance.exports['__napi_register__register_plugins_48']?.()
133
+ __napiInstance.exports['__napi_register__BindingLog_struct_49']?.()
134
+ __napiInstance.exports['__napi_register__BindingLogLevel_50']?.()
135
+ __napiInstance.exports['__napi_register__BindingModuleInfo_struct_51']?.()
136
+ __napiInstance.exports['__napi_register__BindingModuleInfo_impl_53']?.()
137
+ __napiInstance.exports['__napi_register__BindingOutputAsset_struct_54']?.()
138
+ __napiInstance.exports['__napi_register__BindingOutputAsset_impl_59']?.()
139
+ __napiInstance.exports['__napi_register__BindingOutputChunk_struct_60']?.()
140
+ __napiInstance.exports['__napi_register__BindingOutputChunk_impl_78']?.()
141
+ __napiInstance.exports['__napi_register__BindingOutputs_struct_79']?.()
142
+ __napiInstance.exports['__napi_register__BindingOutputs_impl_83']?.()
143
+ __napiInstance.exports['__napi_register__FinalBindingOutputs_struct_84']?.()
144
+ __napiInstance.exports['__napi_register__FinalBindingOutputs_impl_87']?.()
145
+ __napiInstance.exports['__napi_register__RenderedChunk_struct_88']?.()
146
+ __napiInstance.exports['__napi_register__BindingRenderedModule_struct_89']?.()
147
+ __napiInstance.exports['__napi_register__AliasItem_struct_90']?.()
148
+ __napiInstance.exports['__napi_register__BindingSourcemap_struct_91']?.()
149
+ __napiInstance.exports['__napi_register__BindingJsonSourcemap_struct_92']?.()
148
150
  }
149
151
  module.exports.BindingLog = __napiModule.exports.BindingLog
150
152
  module.exports.BindingModuleInfo = __napiModule.exports.BindingModuleInfo
@@ -167,6 +167,19 @@ export interface BindingHookTransformOutput {
167
167
  moduleType?: string
168
168
  }
169
169
 
170
+ export interface BindingInjectImportNamed {
171
+ tagNamed: true
172
+ imported: string
173
+ alias?: string
174
+ from: string
175
+ }
176
+
177
+ export interface BindingInjectImportNamespace {
178
+ tagNamespace: true
179
+ alias: string
180
+ from: string
181
+ }
182
+
170
183
  export interface BindingInputItem {
171
184
  name?: string
172
185
  import: string
@@ -185,6 +198,7 @@ export interface BindingInputOptions {
185
198
  treeshake?: BindingTreeshake
186
199
  moduleTypes?: Record<string, string>
187
200
  define?: Array<[string, string]>
201
+ inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>
188
202
  }
189
203
 
190
204
  export interface BindingJsonSourcemap {
@@ -1,9 +1,36 @@
1
1
  import { Plugin } from '../plugin';
2
+ export declare const ENUMERATED_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro"];
2
3
  /**
3
4
  * Names of all properties in a `Plugin` object. Includes `name` and `api`.
4
5
  */
5
6
  export type PluginProps = keyof Plugin;
7
+ type EnumeratedPluginHookNames = typeof ENUMERATED_PLUGIN_HOOK_NAMES;
6
8
  /**
7
9
  * Names of all hooks in a `Plugin` object. Does not include `name` and `api`, since they are not hooks.
8
10
  */
9
- export type PluginHookNames = Exclude<PluginProps, 'name' | 'api'>;
11
+ export type PluginHookNames = EnumeratedPluginHookNames[number];
12
+ /**
13
+ * Names of all defined hooks. It's like
14
+ * ```ts
15
+ * type DefinedHookNames = {
16
+ * options: 'options',
17
+ * buildStart: 'buildStart',
18
+ * ...
19
+ * }
20
+ * ```
21
+ */
22
+ export type DefinedHookNames = {
23
+ readonly [K in PluginHookNames]: K;
24
+ };
25
+ /**
26
+ * Names of all defined hooks. It's like
27
+ * ```js
28
+ * const DEFINED_HOOK_NAMES ={
29
+ * options: 'options',
30
+ * buildStart: 'buildStart',
31
+ * ...
32
+ * }
33
+ * ```
34
+ */
35
+ export declare const DEFINED_HOOK_NAMES: DefinedHookNames;
36
+ export {};
@@ -1,6 +1,4 @@
1
- import { defineParallelPlugin } from './plugin/parallel-plugin';
2
- import { experimental_scan } from './rolldown';
3
- import { modulePreloadPolyfillPlugin, dynamicImportVarsPlugin, globImportPlugin, manifestPlugin, wasmPlugin, loadFallbackPlugin, transformPlugin } from './plugin/builtin-plugin';
4
- import { transform } from './binding';
5
- export { defineParallelPlugin, experimental_scan as scan, transform };
6
- export { modulePreloadPolyfillPlugin, dynamicImportVarsPlugin, wasmPlugin, globImportPlugin, manifestPlugin, loadFallbackPlugin, transformPlugin, };
1
+ export { defineParallelPlugin } from './plugin/parallel-plugin';
2
+ export { experimental_scan as scan } from './rolldown';
3
+ export { transform } from './binding';
4
+ export { modulePreloadPolyfillPlugin, dynamicImportVarsPlugin, wasmPlugin, globImportPlugin, manifestPlugin, loadFallbackPlugin, transformPlugin, } from './plugin/builtin-plugin';
@@ -1,11 +1,11 @@
1
- import type { RolldownPlugin } from '../plugin';
1
+ import type { RolldownPluginRec } from '../plugin';
2
2
  import { z } from 'zod';
3
3
  import { TreeshakingOptions } from '../treeshake';
4
4
  declare const inputOptionSchema: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodRecord<z.ZodString, z.ZodString>]>;
5
5
  declare const externalSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodOptional<z.ZodString>, z.ZodBoolean], z.ZodUnknown>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodVoid, z.ZodNull]>, z.ZodUndefined]>, z.ZodBoolean]>>]>;
6
6
  declare const inputOptionsSchema: z.ZodObject<{
7
7
  input: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodRecord<z.ZodString, z.ZodString>]>>;
8
- plugins: z.ZodOptional<z.ZodArray<z.ZodType<RolldownPlugin, z.ZodTypeDef, RolldownPlugin>, "many">>;
8
+ plugins: z.ZodOptional<z.ZodArray<z.ZodType<RolldownPluginRec, z.ZodTypeDef, RolldownPluginRec>, "many">>;
9
9
  external: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodOptional<z.ZodString>, z.ZodBoolean], z.ZodUnknown>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodVoid, z.ZodNull]>, z.ZodUndefined]>, z.ZodBoolean]>>]>>;
10
10
  resolve: z.ZodOptional<z.ZodObject<{
11
11
  alias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -44,15 +44,7 @@ declare const inputOptionsSchema: z.ZodObject<{
44
44
  cwd: z.ZodOptional<z.ZodString>;
45
45
  platform: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"node">, z.ZodLiteral<"browser">]>, z.ZodLiteral<"neutral">]>>;
46
46
  shimMissingExports: z.ZodOptional<z.ZodBoolean>;
47
- treeshake: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<z.objectUtil.extendShape<{
48
- moduleSideEffects: z.ZodUnion<[z.ZodBoolean, z.ZodString]>;
49
- }, {
50
- moduleSideEffects: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
51
- }>, "strict", z.ZodTypeAny, {
52
- moduleSideEffects?: string | boolean | undefined;
53
- }, {
54
- moduleSideEffects?: string | boolean | undefined;
55
- }>]>>;
47
+ treeshake: z.ZodOptional<z.ZodType<boolean | TreeshakingOptions, z.ZodTypeDef, boolean | TreeshakingOptions>>;
56
48
  logLevel: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"info">, z.ZodLiteral<"debug">]>, z.ZodLiteral<"warn">]>, z.ZodLiteral<"silent">]>>;
57
49
  onLog: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"info">, z.ZodLiteral<"debug">]>, z.ZodLiteral<"warn">]>, z.ZodAny, z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"info">, z.ZodLiteral<"debug">]>, z.ZodLiteral<"warn">]>, z.ZodLiteral<"error">]>, z.ZodUnion<[z.ZodAny, z.ZodString]>], z.ZodUnknown>, z.ZodUnknown>], z.ZodUnknown>, z.ZodUnknown>>;
58
50
  onwarn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodUnion<[z.ZodAny, z.ZodString]>, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodAny, z.ZodString]>>]>], z.ZodUnknown>, z.ZodUnknown>], z.ZodUnknown>, z.ZodUnknown>>;
@@ -65,9 +57,10 @@ declare const inputOptionsSchema: z.ZodObject<{
65
57
  enableComposingJsPlugins?: boolean | undefined;
66
58
  }>>;
67
59
  define: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
60
+ inject: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>>;
68
61
  }, "strict", z.ZodTypeAny, {
69
62
  input?: string | string[] | Record<string, string> | undefined;
70
- plugins?: RolldownPlugin[] | undefined;
63
+ plugins?: RolldownPluginRec[] | undefined;
71
64
  external?: string | RegExp | (string | RegExp)[] | ((args_0: string, args_1: string | undefined, args_2: boolean, ...args_3: unknown[]) => boolean | void | null | undefined) | undefined;
72
65
  resolve?: {
73
66
  alias?: Record<string, string> | undefined;
@@ -84,9 +77,7 @@ declare const inputOptionsSchema: z.ZodObject<{
84
77
  cwd?: string | undefined;
85
78
  platform?: "node" | "browser" | "neutral" | undefined;
86
79
  shimMissingExports?: boolean | undefined;
87
- treeshake?: boolean | {
88
- moduleSideEffects?: string | boolean | undefined;
89
- } | undefined;
80
+ treeshake?: boolean | TreeshakingOptions | undefined;
90
81
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
91
82
  onLog?: ((args_0: "info" | "debug" | "warn", args_1: any, args_2: (args_0: "info" | "debug" | "warn" | "error", args_1: any, ...args_2: unknown[]) => unknown, ...args_3: unknown[]) => unknown) | undefined;
92
83
  onwarn?: ((args_0: any, args_1: (args_0: any, ...args_1: unknown[]) => unknown, ...args_2: unknown[]) => unknown) | undefined;
@@ -95,9 +86,10 @@ declare const inputOptionsSchema: z.ZodObject<{
95
86
  enableComposingJsPlugins?: boolean | undefined;
96
87
  } | undefined;
97
88
  define?: Record<string, string> | undefined;
89
+ inject?: Record<string, string | [string, string]> | undefined;
98
90
  }, {
99
91
  input?: string | string[] | Record<string, string> | undefined;
100
- plugins?: RolldownPlugin[] | undefined;
92
+ plugins?: RolldownPluginRec[] | undefined;
101
93
  external?: string | RegExp | (string | RegExp)[] | ((args_0: string, args_1: string | undefined, args_2: boolean, ...args_3: unknown[]) => boolean | void | null | undefined) | undefined;
102
94
  resolve?: {
103
95
  alias?: Record<string, string> | undefined;
@@ -114,9 +106,7 @@ declare const inputOptionsSchema: z.ZodObject<{
114
106
  cwd?: string | undefined;
115
107
  platform?: "node" | "browser" | "neutral" | undefined;
116
108
  shimMissingExports?: boolean | undefined;
117
- treeshake?: boolean | {
118
- moduleSideEffects?: string | boolean | undefined;
119
- } | undefined;
109
+ treeshake?: boolean | TreeshakingOptions | undefined;
120
110
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
121
111
  onLog?: ((args_0: "info" | "debug" | "warn", args_1: any, args_2: (args_0: "info" | "debug" | "warn" | "error", args_1: any, ...args_2: unknown[]) => unknown, ...args_3: unknown[]) => unknown) | undefined;
122
112
  onwarn?: ((args_0: any, args_1: (args_0: any, ...args_1: unknown[]) => unknown, ...args_2: unknown[]) => unknown) | undefined;
@@ -125,10 +115,36 @@ declare const inputOptionsSchema: z.ZodObject<{
125
115
  enableComposingJsPlugins?: boolean | undefined;
126
116
  } | undefined;
127
117
  define?: Record<string, string> | undefined;
118
+ inject?: Record<string, string | [string, string]> | undefined;
128
119
  }>;
120
+ type RawInputOptions = z.infer<typeof inputOptionsSchema>;
121
+ interface OverwriteInputOptionsWithDoc {
122
+ /**
123
+ * Inject import statements on demand.
124
+ *
125
+ * ## Supported patterns
126
+ * ```js
127
+ * {
128
+ * // import { Promise } from 'es6-promise'
129
+ * Promise: ['es6-promise', 'Promise'],
130
+ *
131
+ * // import { Promise as P } from 'es6-promise'
132
+ * P: ['es6-promise', 'Promise'],
133
+ *
134
+ * // import $ from 'jquery'
135
+ * $: 'jquery',
136
+ *
137
+ * // import * as fs from 'node:fs'
138
+ * fs: ['node:fs', '*'],
139
+ *
140
+ * // Inject shims for property access pattern
141
+ * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
142
+ * }
143
+ * ```
144
+ */
145
+ inject?: RawInputOptions['inject'];
146
+ }
129
147
  export type InputOption = z.infer<typeof inputOptionSchema>;
148
+ export type InputOptions = Omit<RawInputOptions, keyof OverwriteInputOptionsWithDoc> & OverwriteInputOptionsWithDoc;
130
149
  export type ExternalOption = z.infer<typeof externalSchema>;
131
- export type InputOptions = Omit<z.infer<typeof inputOptionsSchema>, 'treeshake'> & {
132
- treeshake?: boolean | TreeshakingOptions;
133
- };
134
150
  export {};