rolldown 0.12.2-snapshot-3ea6797-20240810002921 → 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.
- package/dist/cjs/cli.cjs +2 -2
- package/dist/cjs/experimental-index.cjs +2 -2
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/parallel-plugin-worker.cjs +1 -1
- package/dist/esm/cli.mjs +2 -2
- package/dist/esm/experimental-index.mjs +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{plugin-context-data-I1aPS5hK.cjs → plugin-context-data-DXDLCu7_.cjs} +179 -115
- package/dist/shared/{plugin-context-data-l2hAUTQq.mjs → plugin-context-data-ymCbOD0T.mjs} +179 -115
- package/dist/shared/{rolldown-tWN4pzYf.cjs → rolldown-HPuKu0TA.cjs} +54 -13
- package/dist/shared/{rolldown-gbhp04Mo.mjs → rolldown-Lp-BFTO_.mjs} +54 -13
- package/dist/shared/rolldown-binding.wasi.cjs +54 -49
- package/dist/types/binding.d.ts +40 -0
- package/dist/types/constants/plugin.d.ts +28 -1
- package/dist/types/experimental-index.d.ts +4 -6
- package/dist/types/options/input-options.d.ts +38 -22
- package/dist/types/options/normalized-ecma-transform-plugin-config.d.ts +1 -1
- package/dist/types/options/output-options.d.ts +8 -8
- package/dist/types/plugin/bindingify-build-hooks.d.ts +8 -7
- package/dist/types/plugin/bindingify-output-hooks.d.ts +11 -10
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +7 -0
- package/dist/types/plugin/index.d.ts +30 -23
- package/dist/types/plugin/plugin-driver.d.ts +2 -2
- package/dist/types/utils/normalize-hook.d.ts +7 -2
- package/dist/types/utils/plugin/index.d.ts +2 -0
- package/package.json +14 -14
package/dist/cjs/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { __commonJSMin, __export, __toESM } = require("../shared/chunk-whRFQvSK.cjs");
|
|
2
|
-
const { arraify } = require("../shared/plugin-context-data-
|
|
3
|
-
const { rolldown } = require("../shared/rolldown-
|
|
2
|
+
const { arraify } = require("../shared/plugin-context-data-DXDLCu7_.cjs");
|
|
3
|
+
const { rolldown } = require("../shared/rolldown-HPuKu0TA.cjs");
|
|
4
4
|
const { colors, consola, createConsola } = require("../shared/consola.36c0034f-UsYo1a5T.cjs");
|
|
5
5
|
const { default: nodePath } = __toESM(require("node:path"));
|
|
6
6
|
const { default: process$1, env } = __toESM(require("node:process"));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const { __toESM } = require("../shared/chunk-whRFQvSK.cjs");
|
|
4
|
-
const { require_binding } = require("../shared/plugin-context-data-
|
|
5
|
-
const { dynamicImportVarsPlugin, experimental_scan, globImportPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, transformPlugin, wasmPlugin } = require("../shared/rolldown-
|
|
4
|
+
const { require_binding } = require("../shared/plugin-context-data-DXDLCu7_.cjs");
|
|
5
|
+
const { dynamicImportVarsPlugin, experimental_scan, globImportPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, transformPlugin, wasmPlugin } = require("../shared/rolldown-HPuKu0TA.cjs");
|
|
6
6
|
const { pathToFileURL } = __toESM(require("node:url"));
|
|
7
7
|
|
|
8
8
|
//#region src/plugin/parallel-plugin.ts
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("../shared/plugin-context-data-
|
|
4
|
-
const { rolldown } = require("../shared/rolldown-
|
|
3
|
+
require("../shared/plugin-context-data-DXDLCu7_.cjs");
|
|
4
|
+
const { rolldown } = require("../shared/rolldown-HPuKu0TA.cjs");
|
|
5
5
|
|
|
6
6
|
//#region src/utils/define-config.ts
|
|
7
7
|
function defineConfig(config) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const { __toESM } = require("../shared/chunk-whRFQvSK.cjs");
|
|
4
|
-
const { PluginContextData, bindingifyPlugin, require_binding } = require("../shared/plugin-context-data-
|
|
4
|
+
const { PluginContextData, bindingifyPlugin, require_binding } = require("../shared/plugin-context-data-DXDLCu7_.cjs");
|
|
5
5
|
const { parentPort, workerData } = __toESM(require("node:worker_threads"));
|
|
6
6
|
|
|
7
7
|
//#region src/parallel-plugin-worker.ts
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import __node_module__ from 'node:module';
|
|
2
2
|
const require = __node_module__.createRequire(import.meta.url)
|
|
3
|
-
import { __commonJSMin, __export, __toESM, arraify } from "../shared/plugin-context-data-
|
|
4
|
-
import { rolldown } from "../shared/rolldown-
|
|
3
|
+
import { __commonJSMin, __export, __toESM, arraify } from "../shared/plugin-context-data-ymCbOD0T.mjs";
|
|
4
|
+
import { rolldown } from "../shared/rolldown-Lp-BFTO_.mjs";
|
|
5
5
|
import { colors, consola, createConsola } from "../shared/consola.36c0034f-VfFiWRgU.mjs";
|
|
6
6
|
import { default as nodePath } from "node:path";
|
|
7
7
|
import { default as process$1, env } from "node:process";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import __node_module__ from 'node:module';
|
|
2
2
|
const require = __node_module__.createRequire(import.meta.url)
|
|
3
|
-
import { __toESM, require_binding } from "../shared/plugin-context-data-
|
|
4
|
-
import { dynamicImportVarsPlugin, experimental_scan, globImportPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, transformPlugin, wasmPlugin } from "../shared/rolldown-
|
|
3
|
+
import { __toESM, require_binding } from "../shared/plugin-context-data-ymCbOD0T.mjs";
|
|
4
|
+
import { dynamicImportVarsPlugin, experimental_scan, globImportPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, transformPlugin, wasmPlugin } from "../shared/rolldown-Lp-BFTO_.mjs";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
|
|
7
7
|
//#region src/plugin/parallel-plugin.ts
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import __node_module__ from 'node:module';
|
|
2
2
|
const require = __node_module__.createRequire(import.meta.url)
|
|
3
|
-
import "../shared/plugin-context-data-
|
|
4
|
-
import { rolldown } from "../shared/rolldown-
|
|
3
|
+
import "../shared/plugin-context-data-ymCbOD0T.mjs";
|
|
4
|
+
import { rolldown } from "../shared/rolldown-Lp-BFTO_.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/define-config.ts
|
|
7
7
|
function defineConfig(config) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import __node_module__ from 'node:module';
|
|
2
2
|
const require = __node_module__.createRequire(import.meta.url)
|
|
3
|
-
import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/plugin-context-data-
|
|
3
|
+
import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/plugin-context-data-ymCbOD0T.mjs";
|
|
4
4
|
import { parentPort, workerData } from "node:worker_threads";
|
|
5
5
|
|
|
6
6
|
//#region src/parallel-plugin-worker.ts
|
|
@@ -418,36 +418,12 @@ var require_binding = __commonJSMin((exports, module) => {
|
|
|
418
418
|
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
|
|
419
419
|
module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
|
|
420
420
|
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
|
|
421
|
+
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
|
|
421
422
|
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
|
|
422
423
|
module.exports.registerPlugins = nativeBinding.registerPlugins;
|
|
423
424
|
module.exports.transform = nativeBinding.transform;
|
|
424
425
|
});
|
|
425
426
|
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region src/utils/normalize-hook.ts
|
|
428
|
-
function normalizeHook(hook) {
|
|
429
|
-
if (typeof hook === "function") {
|
|
430
|
-
return [hook, {}];
|
|
431
|
-
}
|
|
432
|
-
if (typeof hook === "object" && hook !== null) {
|
|
433
|
-
const { handler: handler,...options } = hook;
|
|
434
|
-
return [handler, options];
|
|
435
|
-
}
|
|
436
|
-
return [hook, {}];
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region src/utils/transform-sourcemap.ts
|
|
441
|
-
function isEmptySourcemapFiled(array) {
|
|
442
|
-
if (!array) {
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
if (array.length === 0 || !array[0]) {
|
|
446
|
-
return true;
|
|
447
|
-
}
|
|
448
|
-
return false;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
427
|
//#endregion
|
|
452
428
|
//#region src/utils/misc.ts
|
|
453
429
|
function arraify(value) {
|
|
@@ -462,6 +438,12 @@ function unimplemented(info) {
|
|
|
462
438
|
}
|
|
463
439
|
throw new Error("unimplemented");
|
|
464
440
|
}
|
|
441
|
+
function unreachable(info) {
|
|
442
|
+
if (info) {
|
|
443
|
+
throw new Error(`unreachable: ${info}`);
|
|
444
|
+
}
|
|
445
|
+
throw new Error("unreachable");
|
|
446
|
+
}
|
|
465
447
|
function unsupported(info) {
|
|
466
448
|
return () => {
|
|
467
449
|
throw new Error(`UNSUPPORTED: ${info}`);
|
|
@@ -469,6 +451,38 @@ function unsupported(info) {
|
|
|
469
451
|
}
|
|
470
452
|
function noop(..._args) {}
|
|
471
453
|
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/utils/normalize-hook.ts
|
|
456
|
+
function normalizeHook(hook) {
|
|
457
|
+
if (typeof hook === "function" || typeof hook === "string") {
|
|
458
|
+
return {
|
|
459
|
+
handler: hook,
|
|
460
|
+
options: {},
|
|
461
|
+
meta: {}
|
|
462
|
+
};
|
|
463
|
+
} else if (typeof hook === "object" && hook !== null) {
|
|
464
|
+
const { handler: handler, order: order,...options } = hook;
|
|
465
|
+
return {
|
|
466
|
+
handler,
|
|
467
|
+
options,
|
|
468
|
+
meta: {order}
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
unreachable("Invalid hook type");
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/utils/transform-sourcemap.ts
|
|
476
|
+
function isEmptySourcemapFiled(array) {
|
|
477
|
+
if (!array) {
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
if (array.length === 0 || !array[0]) {
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
|
|
472
486
|
//#endregion
|
|
473
487
|
//#region src/utils/transform-module-info.ts
|
|
474
488
|
function transformModuleInfo(info, option) {
|
|
@@ -770,47 +784,63 @@ class TransformPluginContext extends PluginContext {
|
|
|
770
784
|
|
|
771
785
|
//#endregion
|
|
772
786
|
//#region src/utils/transform-side-effects.ts
|
|
773
|
-
var import_binding = __toESM(require_binding());
|
|
787
|
+
var import_binding$1 = __toESM(require_binding());
|
|
774
788
|
function bindingifySideEffects(sideEffects) {
|
|
775
789
|
switch (sideEffects) {
|
|
776
|
-
case true: return import_binding.BindingHookSideEffects.True;
|
|
777
|
-
case false: return import_binding.BindingHookSideEffects.False;
|
|
778
|
-
case "no-treeshake": return import_binding.BindingHookSideEffects.NoTreeshake;
|
|
790
|
+
case true: return import_binding$1.BindingHookSideEffects.True;
|
|
791
|
+
case false: return import_binding$1.BindingHookSideEffects.False;
|
|
792
|
+
case "no-treeshake": return import_binding$1.BindingHookSideEffects.NoTreeshake;
|
|
779
793
|
case null:
|
|
780
794
|
case undefined: return undefined;
|
|
781
795
|
default: throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
782
796
|
}
|
|
783
797
|
}
|
|
784
798
|
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
801
|
+
var import_binding = __toESM(require_binding());
|
|
802
|
+
function bindingifyPluginHookMeta(options) {
|
|
803
|
+
return {order: bindingPluginOrder(options.order)};
|
|
804
|
+
}
|
|
805
|
+
function bindingPluginOrder(order) {
|
|
806
|
+
switch (order) {
|
|
807
|
+
case "post": return import_binding.BindingPluginOrder.Post;
|
|
808
|
+
case "pre": return import_binding.BindingPluginOrder.Pre;
|
|
809
|
+
case null:
|
|
810
|
+
case undefined: return undefined;
|
|
811
|
+
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
785
815
|
//#endregion
|
|
786
816
|
//#region src/plugin/bindingify-build-hooks.ts
|
|
787
817
|
function bindingifyBuildStart(plugin, options, pluginContextData) {
|
|
788
818
|
const hook = plugin.buildStart;
|
|
789
819
|
if (!hook) {
|
|
790
|
-
return undefined;
|
|
820
|
+
return [undefined, undefined];
|
|
791
821
|
}
|
|
792
|
-
const
|
|
793
|
-
return async (ctx) => {
|
|
822
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
823
|
+
return [async (ctx) => {
|
|
794
824
|
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), options);
|
|
795
|
-
};
|
|
825
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
796
826
|
}
|
|
797
827
|
function bindingifyBuildEnd(plugin, options, pluginContextData) {
|
|
798
828
|
const hook = plugin.buildEnd;
|
|
799
829
|
if (!hook) {
|
|
800
|
-
return undefined;
|
|
830
|
+
return [undefined, undefined];
|
|
801
831
|
}
|
|
802
|
-
const
|
|
803
|
-
return async (ctx, err) => {
|
|
832
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
833
|
+
return [async (ctx, err) => {
|
|
804
834
|
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), err ? new Error(err) : undefined);
|
|
805
|
-
};
|
|
835
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
806
836
|
}
|
|
807
837
|
function bindingifyResolveId(plugin, options, pluginContextData) {
|
|
808
838
|
const hook = plugin.resolveId;
|
|
809
839
|
if (!hook) {
|
|
810
|
-
return undefined;
|
|
840
|
+
return [undefined, undefined];
|
|
811
841
|
}
|
|
812
|
-
const
|
|
813
|
-
return async (ctx, specifier, importer, extraOptions) => {
|
|
842
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
843
|
+
return [async (ctx, specifier, importer, extraOptions) => {
|
|
814
844
|
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), specifier, importer ?? undefined, {
|
|
815
845
|
...extraOptions,
|
|
816
846
|
custom: typeof extraOptions.custom === "number" ? pluginContextData.getResolveCustom(extraOptions.custom) : undefined
|
|
@@ -833,15 +863,15 @@ function bindingifyResolveId(plugin, options, pluginContextData) {
|
|
|
833
863
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
834
864
|
});
|
|
835
865
|
return result;
|
|
836
|
-
};
|
|
866
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
837
867
|
}
|
|
838
868
|
function bindingifyResolveDynamicImport(plugin, options, pluginContextData) {
|
|
839
869
|
const hook = plugin.resolveDynamicImport;
|
|
840
870
|
if (!hook) {
|
|
841
|
-
return undefined;
|
|
871
|
+
return [undefined, undefined];
|
|
842
872
|
}
|
|
843
|
-
const
|
|
844
|
-
return async (ctx, specifier, importer) => {
|
|
873
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
874
|
+
return [async (ctx, specifier, importer) => {
|
|
845
875
|
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), specifier, importer ?? undefined);
|
|
846
876
|
if (ret == false || ret == null) {
|
|
847
877
|
return;
|
|
@@ -861,16 +891,16 @@ function bindingifyResolveDynamicImport(plugin, options, pluginContextData) {
|
|
|
861
891
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
862
892
|
});
|
|
863
893
|
return result;
|
|
864
|
-
};
|
|
894
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
865
895
|
}
|
|
866
896
|
function bindingifyTransform(plugin, options, pluginContextData) {
|
|
867
897
|
const hook = plugin.transform;
|
|
868
898
|
if (!hook) {
|
|
869
|
-
return undefined;
|
|
899
|
+
return [undefined, undefined];
|
|
870
900
|
}
|
|
871
|
-
const
|
|
872
|
-
return async (ctx, code, id, meta) => {
|
|
873
|
-
const ret = await handler.call(new TransformPluginContext(options, ctx.inner(), plugin, pluginContextData, ctx, id, code), code, id, meta);
|
|
901
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
902
|
+
return [async (ctx, code, id, meta$1) => {
|
|
903
|
+
const ret = await handler.call(new TransformPluginContext(options, ctx.inner(), plugin, pluginContextData, ctx, id, code), code, id, meta$1);
|
|
874
904
|
if (ret == null) {
|
|
875
905
|
return undefined;
|
|
876
906
|
}
|
|
@@ -887,15 +917,15 @@ function bindingifyTransform(plugin, options, pluginContextData) {
|
|
|
887
917
|
sideEffects: bindingifySideEffects(ret.moduleSideEffects),
|
|
888
918
|
moduleType: ret.moduleType
|
|
889
919
|
};
|
|
890
|
-
};
|
|
920
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
891
921
|
}
|
|
892
922
|
function bindingifyLoad(plugin, options, pluginContextData) {
|
|
893
923
|
const hook = plugin.load;
|
|
894
924
|
if (!hook) {
|
|
895
|
-
return undefined;
|
|
925
|
+
return [undefined, undefined];
|
|
896
926
|
}
|
|
897
|
-
const
|
|
898
|
-
return async (ctx, id) => {
|
|
927
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
928
|
+
return [async (ctx, id) => {
|
|
899
929
|
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), id);
|
|
900
930
|
if (ret == null) {
|
|
901
931
|
return;
|
|
@@ -924,17 +954,17 @@ function bindingifyLoad(plugin, options, pluginContextData) {
|
|
|
924
954
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
925
955
|
});
|
|
926
956
|
return result;
|
|
927
|
-
};
|
|
957
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
928
958
|
}
|
|
929
959
|
function bindingifyModuleParsed(plugin, options, pluginContextData) {
|
|
930
960
|
const hook = plugin.moduleParsed;
|
|
931
961
|
if (!hook) {
|
|
932
|
-
return undefined;
|
|
962
|
+
return [undefined, undefined];
|
|
933
963
|
}
|
|
934
|
-
const
|
|
935
|
-
return async (ctx, moduleInfo) => {
|
|
964
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
965
|
+
return [async (ctx, moduleInfo) => {
|
|
936
966
|
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), transformModuleInfo(moduleInfo, pluginContextData.moduleOptionMap.get(moduleInfo.id)));
|
|
937
|
-
};
|
|
967
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
938
968
|
}
|
|
939
969
|
|
|
940
970
|
//#endregion
|
|
@@ -942,20 +972,20 @@ function bindingifyModuleParsed(plugin, options, pluginContextData) {
|
|
|
942
972
|
function bindingifyRenderStart(plugin, options, outputOptions, pluginContextData) {
|
|
943
973
|
const hook = plugin.renderStart;
|
|
944
974
|
if (!hook) {
|
|
945
|
-
return undefined;
|
|
975
|
+
return [undefined, undefined];
|
|
946
976
|
}
|
|
947
|
-
const
|
|
948
|
-
return async (ctx) => {
|
|
977
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
978
|
+
return [async (ctx) => {
|
|
949
979
|
handler.call(new PluginContext(options, ctx, plugin, pluginContextData), outputOptions, options);
|
|
950
|
-
};
|
|
980
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
951
981
|
}
|
|
952
982
|
function bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData) {
|
|
953
983
|
const hook = plugin.renderChunk;
|
|
954
984
|
if (!hook) {
|
|
955
|
-
return undefined;
|
|
985
|
+
return [undefined, undefined];
|
|
956
986
|
}
|
|
957
|
-
const
|
|
958
|
-
return async (ctx, code, chunk) => {
|
|
987
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
988
|
+
return [async (ctx, code, chunk) => {
|
|
959
989
|
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), code, chunk, outputOptions);
|
|
960
990
|
if (ret == null) {
|
|
961
991
|
return;
|
|
@@ -970,123 +1000,157 @@ function bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData
|
|
|
970
1000
|
code: ret.code,
|
|
971
1001
|
map: bindingifySourcemap(ret.map)
|
|
972
1002
|
};
|
|
973
|
-
};
|
|
1003
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
974
1004
|
}
|
|
975
1005
|
function bindingifyAugmentChunkHash(plugin, options, pluginContextData) {
|
|
976
1006
|
const hook = plugin.augmentChunkHash;
|
|
977
1007
|
if (!hook) {
|
|
978
|
-
return undefined;
|
|
1008
|
+
return [undefined, undefined];
|
|
979
1009
|
}
|
|
980
|
-
const
|
|
981
|
-
return async (ctx, chunk) => {
|
|
1010
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1011
|
+
return [async (ctx, chunk) => {
|
|
982
1012
|
return await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), chunk);
|
|
983
|
-
};
|
|
1013
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
984
1014
|
}
|
|
985
1015
|
function bindingifyRenderError(plugin, options, pluginContextData) {
|
|
986
1016
|
const hook = plugin.renderError;
|
|
987
1017
|
if (!hook) {
|
|
988
|
-
return undefined;
|
|
1018
|
+
return [undefined, undefined];
|
|
989
1019
|
}
|
|
990
|
-
const
|
|
991
|
-
return async (ctx, err) => {
|
|
1020
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1021
|
+
return [async (ctx, err) => {
|
|
992
1022
|
handler.call(new PluginContext(options, ctx, plugin, pluginContextData), new Error(err));
|
|
993
|
-
};
|
|
1023
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
994
1024
|
}
|
|
995
1025
|
function bindingifyGenerateBundle(plugin, options, outputOptions, pluginContextData) {
|
|
996
1026
|
const hook = plugin.generateBundle;
|
|
997
1027
|
if (!hook) {
|
|
998
|
-
return undefined;
|
|
1028
|
+
return [undefined, undefined];
|
|
999
1029
|
}
|
|
1000
|
-
const
|
|
1001
|
-
return async (ctx, bundle, isWrite) => {
|
|
1030
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1031
|
+
return [async (ctx, bundle, isWrite) => {
|
|
1002
1032
|
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), outputOptions, transformToOutputBundle(bundle), isWrite);
|
|
1003
|
-
};
|
|
1033
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
1004
1034
|
}
|
|
1005
1035
|
function bindingifyWriteBundle(plugin, options, outputOptions, pluginContextData) {
|
|
1006
1036
|
const hook = plugin.writeBundle;
|
|
1007
1037
|
if (!hook) {
|
|
1008
|
-
return undefined;
|
|
1038
|
+
return [undefined, undefined];
|
|
1009
1039
|
}
|
|
1010
|
-
const
|
|
1011
|
-
return async (ctx, bundle) => {
|
|
1040
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1041
|
+
return [async (ctx, bundle) => {
|
|
1012
1042
|
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), outputOptions, transformToOutputBundle(bundle));
|
|
1013
|
-
};
|
|
1043
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
1014
1044
|
}
|
|
1015
1045
|
function bindingifyBanner(plugin, options, pluginContextData) {
|
|
1016
1046
|
const hook = plugin.banner;
|
|
1017
1047
|
if (!hook) {
|
|
1018
|
-
return undefined;
|
|
1048
|
+
return [undefined, undefined];
|
|
1019
1049
|
}
|
|
1020
|
-
const
|
|
1021
|
-
return async (ctx, chunk) => {
|
|
1050
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1051
|
+
return [async (ctx, chunk) => {
|
|
1022
1052
|
if (typeof handler === "string") {
|
|
1023
1053
|
return handler;
|
|
1024
1054
|
}
|
|
1025
1055
|
return handler.call(new PluginContext(options, ctx, plugin, pluginContextData), chunk);
|
|
1026
|
-
};
|
|
1056
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
1027
1057
|
}
|
|
1028
1058
|
function bindingifyFooter(plugin, options, pluginContextData) {
|
|
1029
1059
|
const hook = plugin.footer;
|
|
1030
1060
|
if (!hook) {
|
|
1031
|
-
return undefined;
|
|
1061
|
+
return [undefined, undefined];
|
|
1032
1062
|
}
|
|
1033
|
-
const
|
|
1034
|
-
return async (ctx, chunk) => {
|
|
1063
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1064
|
+
return [async (ctx, chunk) => {
|
|
1035
1065
|
if (typeof handler === "string") {
|
|
1036
1066
|
return handler;
|
|
1037
1067
|
}
|
|
1038
1068
|
return handler.call(new PluginContext(options, ctx, plugin, pluginContextData), chunk);
|
|
1039
|
-
};
|
|
1069
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
1040
1070
|
}
|
|
1041
1071
|
function bindingifyIntro(plugin, options, pluginContextData) {
|
|
1042
1072
|
const hook = plugin.intro;
|
|
1043
1073
|
if (!hook) {
|
|
1044
|
-
return undefined;
|
|
1074
|
+
return [undefined, undefined];
|
|
1045
1075
|
}
|
|
1046
|
-
const
|
|
1047
|
-
return async (ctx, chunk) => {
|
|
1076
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1077
|
+
return [async (ctx, chunk) => {
|
|
1048
1078
|
if (typeof handler === "string") {
|
|
1049
1079
|
return handler;
|
|
1050
1080
|
}
|
|
1051
1081
|
return handler.call(new PluginContext(options, ctx, plugin, pluginContextData), chunk);
|
|
1052
|
-
};
|
|
1082
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
1053
1083
|
}
|
|
1054
1084
|
function bindingifyOutro(plugin, options, pluginContextData) {
|
|
1055
1085
|
const hook = plugin.outro;
|
|
1056
1086
|
if (!hook) {
|
|
1057
|
-
return undefined;
|
|
1087
|
+
return [undefined, undefined];
|
|
1058
1088
|
}
|
|
1059
|
-
const
|
|
1060
|
-
return async (ctx, chunk) => {
|
|
1089
|
+
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1090
|
+
return [async (ctx, chunk) => {
|
|
1061
1091
|
if (typeof handler === "string") {
|
|
1062
1092
|
return handler;
|
|
1063
1093
|
}
|
|
1064
1094
|
return handler.call(new PluginContext(options, ctx, plugin, pluginContextData), chunk);
|
|
1065
|
-
};
|
|
1095
|
+
}, bindingifyPluginHookMeta(meta),];
|
|
1066
1096
|
}
|
|
1067
1097
|
|
|
1068
1098
|
//#endregion
|
|
1069
1099
|
//#region src/plugin/bindingify-plugin.ts
|
|
1070
1100
|
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData) {
|
|
1101
|
+
const [buildStart, buildStartMeta] = bindingifyBuildStart(plugin, options, pluginContextData);
|
|
1102
|
+
const [resolveId, resolveIdMeta] = bindingifyResolveId(plugin, options, pluginContextData);
|
|
1103
|
+
const [resolveDynamicImport, resolveDynamicImportMeta] = bindingifyResolveDynamicImport(plugin, options, pluginContextData);
|
|
1104
|
+
const [buildEnd, buildEndMeta] = bindingifyBuildEnd(plugin, options, pluginContextData);
|
|
1105
|
+
const [transform, transformMeta] = bindingifyTransform(plugin, options, pluginContextData);
|
|
1106
|
+
const [moduleParsed, moduleParsedMeta] = bindingifyModuleParsed(plugin, options, pluginContextData);
|
|
1107
|
+
const [load, loadMeta] = bindingifyLoad(plugin, options, pluginContextData);
|
|
1108
|
+
const [renderChunk, renderChunkMeta] = bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData);
|
|
1109
|
+
const [augmentChunkHash, augmentChunkHashMeta] = bindingifyAugmentChunkHash(plugin, options, pluginContextData);
|
|
1110
|
+
const [renderStart, renderStartMeta] = bindingifyRenderStart(plugin, options, outputOptions, pluginContextData);
|
|
1111
|
+
const [renderError, renderErrorMeta] = bindingifyRenderError(plugin, options, pluginContextData);
|
|
1112
|
+
const [generateBundle, generateBundleMeta] = bindingifyGenerateBundle(plugin, options, outputOptions, pluginContextData);
|
|
1113
|
+
const [writeBundle, writeBundleMeta] = bindingifyWriteBundle(plugin, options, outputOptions, pluginContextData);
|
|
1114
|
+
const [banner, bannerMeta] = bindingifyBanner(plugin, options, pluginContextData);
|
|
1115
|
+
const [footer, footerMeta] = bindingifyFooter(plugin, options, pluginContextData);
|
|
1116
|
+
const [intro, introMeta] = bindingifyIntro(plugin, options, pluginContextData);
|
|
1117
|
+
const [outro, outroMeta] = bindingifyOutro(plugin, options, pluginContextData);
|
|
1071
1118
|
return {
|
|
1072
1119
|
name: plugin.name ?? "unknown",
|
|
1073
|
-
buildStart
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1120
|
+
buildStart,
|
|
1121
|
+
buildStartMeta,
|
|
1122
|
+
resolveId,
|
|
1123
|
+
resolveIdMeta,
|
|
1124
|
+
resolveDynamicImport,
|
|
1125
|
+
resolveDynamicImportMeta,
|
|
1126
|
+
buildEnd,
|
|
1127
|
+
buildEndMeta,
|
|
1128
|
+
transform,
|
|
1129
|
+
transformMeta,
|
|
1130
|
+
moduleParsed,
|
|
1131
|
+
moduleParsedMeta,
|
|
1132
|
+
load,
|
|
1133
|
+
loadMeta,
|
|
1134
|
+
renderChunk,
|
|
1135
|
+
renderChunkMeta,
|
|
1136
|
+
augmentChunkHash,
|
|
1137
|
+
augmentChunkHashMeta,
|
|
1138
|
+
renderStart,
|
|
1139
|
+
renderStartMeta,
|
|
1140
|
+
renderError,
|
|
1141
|
+
renderErrorMeta,
|
|
1142
|
+
generateBundle,
|
|
1143
|
+
generateBundleMeta,
|
|
1144
|
+
writeBundle,
|
|
1145
|
+
writeBundleMeta,
|
|
1146
|
+
banner,
|
|
1147
|
+
bannerMeta,
|
|
1148
|
+
footer,
|
|
1149
|
+
footerMeta,
|
|
1150
|
+
intro,
|
|
1151
|
+
introMeta,
|
|
1152
|
+
outro,
|
|
1153
|
+
outroMeta
|
|
1090
1154
|
};
|
|
1091
1155
|
}
|
|
1092
1156
|
|