rolldown 0.11.0 → 0.11.1
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 +5 -6
- package/dist/cjs/index.cjs +12 -14
- package/dist/cjs/parallel-plugin-worker.cjs +2 -3
- package/dist/cjs/parallel-plugin.cjs +2 -7
- package/dist/esm/cli.mjs +4 -4
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{chunk-IY9XHjk1.cjs → chunk-1xb6WR3y.cjs} +0 -2
- package/dist/shared/{consola_36c0034f-5LhwiLE2.mjs → consola.36c0034f-QyAKDJpW.mjs} +1 -1
- package/dist/shared/{consola_36c0034f-WXb1k8ME.cjs → consola.36c0034f-p4CNcyTx.cjs} +2 -2
- package/dist/shared/{prompt-qKiYiowG.mjs → prompt-LYk41n1z.mjs} +1 -1
- package/dist/shared/{prompt-v8IJTptZ.cjs → prompt-vP5sHLso.cjs} +4 -5
- package/dist/shared/{rolldown-Jq_CbZp4.cjs → rolldown-Umx4sUze.cjs} +1 -1
- package/dist/shared/rolldown-binding.wasi.cjs +49 -36
- package/dist/shared/{rolldown-RjvHfXoR.mjs → rolldown-dJWM6yRj.mjs} +1 -1
- package/dist/shared/{utils_index-PYoHCZRc.cjs → utils_index-CMJWXDsM.cjs} +117 -89
- package/dist/shared/{utils_index-DAvBTBzR.mjs → utils_index-Xz4uA-99.mjs} +116 -88
- package/dist/types/binding.d.ts +25 -18
- package/dist/types/options/input-options.d.ts +3 -3
- package/dist/types/options/normalized-input-options.d.ts +1 -1
- package/dist/types/plugin/bindingify-build-hooks.d.ts +8 -7
- package/dist/types/plugin/bindingify-output-hooks.d.ts +7 -6
- package/dist/types/plugin/index.d.ts +2 -1
- package/dist/types/plugin/plugin-context-data.d.ts +10 -0
- package/dist/types/plugin/plugin-context.d.ts +2 -3
- package/dist/types/plugin/transfrom-plugin-context.d.ts +7 -11
- package/dist/types/treeshake/index.d.ts +5 -6
- package/dist/types/types/module-info.d.ts +2 -1
- package/dist/types/utils/transform-module-info.d.ts +2 -1
- package/package.json +14 -14
|
@@ -512,7 +512,7 @@ function noop(..._args) {}
|
|
|
512
512
|
|
|
513
513
|
//#endregion
|
|
514
514
|
//#region src/utils/transform-module-info.ts
|
|
515
|
-
function transformModuleInfo(info) {
|
|
515
|
+
function transformModuleInfo(info, option) {
|
|
516
516
|
return {
|
|
517
517
|
get ast() {
|
|
518
518
|
return unsupported('ModuleInfo#ast');
|
|
@@ -525,7 +525,8 @@ function transformModuleInfo(info) {
|
|
|
525
525
|
dynamicImporters: info.dynamicImporters,
|
|
526
526
|
importedIds: info.importedIds,
|
|
527
527
|
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
528
|
-
isEntry: info.isEntry
|
|
528
|
+
isEntry: info.isEntry,
|
|
529
|
+
...option
|
|
529
530
|
};
|
|
530
531
|
}
|
|
531
532
|
|
|
@@ -742,9 +743,7 @@ class PluginContext {
|
|
|
742
743
|
getModuleInfo;
|
|
743
744
|
getModuleIds;
|
|
744
745
|
parse;
|
|
745
|
-
|
|
746
|
-
moduleIds = null;
|
|
747
|
-
constructor(options, context, plugin) {
|
|
746
|
+
constructor(options, context, plugin, data) {
|
|
748
747
|
const onLog = options.onLog;
|
|
749
748
|
const pluginName = plugin.name || 'unknown';
|
|
750
749
|
const logLevel = options.logLevel;
|
|
@@ -765,45 +764,18 @@ class PluginContext {
|
|
|
765
764
|
});
|
|
766
765
|
};
|
|
767
766
|
this.getFileName = context.getFileName.bind(context);
|
|
768
|
-
this.getModuleInfo = (id) =>
|
|
769
|
-
|
|
770
|
-
return this.modules.get(id) ?? null;
|
|
771
|
-
}
|
|
772
|
-
const bindingInfo = context.getModuleInfo(id);
|
|
773
|
-
if (bindingInfo) {
|
|
774
|
-
const info = transformModuleInfo(bindingInfo);
|
|
775
|
-
this.modules.set(id, info);
|
|
776
|
-
return info;
|
|
777
|
-
}
|
|
778
|
-
return null;
|
|
779
|
-
};
|
|
780
|
-
this.getModuleIds = () => {
|
|
781
|
-
if (this.moduleIds) {
|
|
782
|
-
return this.moduleIds.values();
|
|
783
|
-
}
|
|
784
|
-
const moduleIds = context.getModuleIds();
|
|
785
|
-
if (moduleIds) {
|
|
786
|
-
this.moduleIds = moduleIds;
|
|
787
|
-
return moduleIds.values();
|
|
788
|
-
}
|
|
789
|
-
return [].values();
|
|
790
|
-
};
|
|
767
|
+
this.getModuleInfo = (id) => data.getModuleInfo(id, context);
|
|
768
|
+
this.getModuleIds = () => data.getModuleIds(context);
|
|
791
769
|
this.parse = unsupported('`PluginContext#parse` is not supported by rolldown.');
|
|
792
770
|
}
|
|
793
771
|
}
|
|
794
772
|
|
|
795
773
|
//#endregion
|
|
796
774
|
//#region src/plugin/transfrom-plugin-context.ts
|
|
797
|
-
class TransformPluginContext {
|
|
798
|
-
debug;
|
|
799
|
-
info;
|
|
800
|
-
warn;
|
|
775
|
+
class TransformPluginContext extends PluginContext {
|
|
801
776
|
error;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
getFileName;
|
|
805
|
-
parse;
|
|
806
|
-
constructor(inner, context, moduleId, moduleSource) {
|
|
777
|
+
constructor(options, context, plugin, data, inner, moduleId, moduleSource) {
|
|
778
|
+
super(options, context, plugin, data);
|
|
807
779
|
const getLogHandler$1 = (handler) => (log, pos) => {
|
|
808
780
|
log = normalizeLog(log);
|
|
809
781
|
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
@@ -811,20 +783,16 @@ class TransformPluginContext {
|
|
|
811
783
|
log.hook = 'transform';
|
|
812
784
|
handler(log);
|
|
813
785
|
};
|
|
814
|
-
this.debug = getLogHandler$1(
|
|
815
|
-
this.warn = getLogHandler$1(
|
|
816
|
-
this.info = getLogHandler$1(
|
|
786
|
+
this.debug = getLogHandler$1(this.debug);
|
|
787
|
+
this.warn = getLogHandler$1(this.warn);
|
|
788
|
+
this.info = getLogHandler$1(this.info);
|
|
817
789
|
this.error = (error$1, pos) => {
|
|
818
790
|
if (typeof error$1 === 'string') error$1 = {message: error$1};
|
|
819
791
|
if (pos) augmentCodeLocation(error$1, pos, moduleSource, moduleId);
|
|
820
792
|
error$1.id = moduleId;
|
|
821
793
|
error$1.hook = 'transform';
|
|
822
|
-
return
|
|
794
|
+
return this.error(error$1);
|
|
823
795
|
};
|
|
824
|
-
this.resolve = context.resolve;
|
|
825
|
-
this.parse = context.parse;
|
|
826
|
-
this.emitFile = context.emitFile;
|
|
827
|
-
this.getFileName = context.getFileName;
|
|
828
796
|
}
|
|
829
797
|
}
|
|
830
798
|
|
|
@@ -844,34 +812,34 @@ function bindingifySideEffects(sideEffects) {
|
|
|
844
812
|
|
|
845
813
|
//#endregion
|
|
846
814
|
//#region src/plugin/bindingify-build-hooks.ts
|
|
847
|
-
function bindingifyBuildStart(plugin, options) {
|
|
815
|
+
function bindingifyBuildStart(plugin, options, pluginContextData) {
|
|
848
816
|
const hook = plugin.buildStart;
|
|
849
817
|
if (!hook) {
|
|
850
818
|
return undefined;
|
|
851
819
|
}
|
|
852
820
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
853
821
|
return async (ctx) => {
|
|
854
|
-
await handler.call(new PluginContext(options, ctx, plugin), options);
|
|
822
|
+
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), options);
|
|
855
823
|
};
|
|
856
824
|
}
|
|
857
|
-
function bindingifyBuildEnd(plugin, options) {
|
|
825
|
+
function bindingifyBuildEnd(plugin, options, pluginContextData) {
|
|
858
826
|
const hook = plugin.buildEnd;
|
|
859
827
|
if (!hook) {
|
|
860
828
|
return undefined;
|
|
861
829
|
}
|
|
862
830
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
863
831
|
return async (ctx, err) => {
|
|
864
|
-
await handler.call(new PluginContext(options, ctx, plugin), err ? new Error(err) : undefined);
|
|
832
|
+
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), err ? new Error(err) : undefined);
|
|
865
833
|
};
|
|
866
834
|
}
|
|
867
|
-
function bindingifyResolveId(plugin, options) {
|
|
835
|
+
function bindingifyResolveId(plugin, options, pluginContextData) {
|
|
868
836
|
const hook = plugin.resolveId;
|
|
869
837
|
if (!hook) {
|
|
870
838
|
return undefined;
|
|
871
839
|
}
|
|
872
840
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
873
841
|
return async (ctx, specifier, importer, extraOptions) => {
|
|
874
|
-
const ret = await handler.call(new PluginContext(options, ctx, plugin), specifier, importer ?? undefined, extraOptions);
|
|
842
|
+
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), specifier, importer ?? undefined, extraOptions);
|
|
875
843
|
if (ret == false || ret == null) {
|
|
876
844
|
return;
|
|
877
845
|
}
|
|
@@ -885,17 +853,21 @@ function bindingifyResolveId(plugin, options) {
|
|
|
885
853
|
if (ret.moduleSideEffects !== null) {
|
|
886
854
|
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
887
855
|
}
|
|
856
|
+
pluginContextData.updateModuleOption(ret.id, {
|
|
857
|
+
meta: ret.meta || {},
|
|
858
|
+
moduleSideEffects: ret.moduleSideEffects || null
|
|
859
|
+
});
|
|
888
860
|
return result;
|
|
889
861
|
};
|
|
890
862
|
}
|
|
891
|
-
function bindingifyResolveDynamicImport(plugin, options) {
|
|
863
|
+
function bindingifyResolveDynamicImport(plugin, options, pluginContextData) {
|
|
892
864
|
const hook = plugin.resolveDynamicImport;
|
|
893
865
|
if (!hook) {
|
|
894
866
|
return undefined;
|
|
895
867
|
}
|
|
896
868
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
897
869
|
return async (ctx, specifier, importer) => {
|
|
898
|
-
const ret = await handler.call(new PluginContext(options, ctx, plugin), specifier, importer ?? undefined);
|
|
870
|
+
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), specifier, importer ?? undefined);
|
|
899
871
|
if (ret == false || ret == null) {
|
|
900
872
|
return;
|
|
901
873
|
}
|
|
@@ -909,23 +881,31 @@ function bindingifyResolveDynamicImport(plugin, options) {
|
|
|
909
881
|
if (ret.moduleSideEffects !== null) {
|
|
910
882
|
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
911
883
|
}
|
|
884
|
+
pluginContextData.updateModuleOption(ret.id, {
|
|
885
|
+
meta: ret.meta || {},
|
|
886
|
+
moduleSideEffects: ret.moduleSideEffects || null
|
|
887
|
+
});
|
|
912
888
|
return result;
|
|
913
889
|
};
|
|
914
890
|
}
|
|
915
|
-
function bindingifyTransform(plugin, options) {
|
|
891
|
+
function bindingifyTransform(plugin, options, pluginContextData) {
|
|
916
892
|
const hook = plugin.transform;
|
|
917
893
|
if (!hook) {
|
|
918
894
|
return undefined;
|
|
919
895
|
}
|
|
920
896
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
921
897
|
return async (ctx, code, id) => {
|
|
922
|
-
const ret = await handler.call(new TransformPluginContext(
|
|
898
|
+
const ret = await handler.call(new TransformPluginContext(options, ctx.inner(), plugin, pluginContextData, ctx, id, code), code, id);
|
|
923
899
|
if (ret == null) {
|
|
924
900
|
return undefined;
|
|
925
901
|
}
|
|
926
902
|
if (typeof ret === 'string') {
|
|
927
903
|
return {code: ret};
|
|
928
904
|
}
|
|
905
|
+
pluginContextData.updateModuleOption(id, {
|
|
906
|
+
meta: ret.meta || {},
|
|
907
|
+
moduleSideEffects: ret.moduleSideEffects || null
|
|
908
|
+
});
|
|
929
909
|
return {
|
|
930
910
|
code: ret.code,
|
|
931
911
|
map: bindingifySourcemap$1(ret.map),
|
|
@@ -933,14 +913,14 @@ function bindingifyTransform(plugin, options) {
|
|
|
933
913
|
};
|
|
934
914
|
};
|
|
935
915
|
}
|
|
936
|
-
function bindingifyLoad(plugin, options) {
|
|
916
|
+
function bindingifyLoad(plugin, options, pluginContextData) {
|
|
937
917
|
const hook = plugin.load;
|
|
938
918
|
if (!hook) {
|
|
939
919
|
return undefined;
|
|
940
920
|
}
|
|
941
921
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
942
922
|
return async (ctx, id) => {
|
|
943
|
-
const ret = await handler.call(new PluginContext(options, ctx, plugin), id);
|
|
923
|
+
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), id);
|
|
944
924
|
if (ret == null) {
|
|
945
925
|
return;
|
|
946
926
|
}
|
|
@@ -963,40 +943,44 @@ function bindingifyLoad(plugin, options) {
|
|
|
963
943
|
if (ret.moduleSideEffects !== null) {
|
|
964
944
|
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
965
945
|
}
|
|
946
|
+
pluginContextData.updateModuleOption(id, {
|
|
947
|
+
meta: ret.meta || {},
|
|
948
|
+
moduleSideEffects: ret.moduleSideEffects || null
|
|
949
|
+
});
|
|
966
950
|
return result;
|
|
967
951
|
};
|
|
968
952
|
}
|
|
969
|
-
function bindingifyModuleParsed(plugin, options) {
|
|
953
|
+
function bindingifyModuleParsed(plugin, options, pluginContextData) {
|
|
970
954
|
const hook = plugin.moduleParsed;
|
|
971
955
|
if (!hook) {
|
|
972
956
|
return undefined;
|
|
973
957
|
}
|
|
974
958
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
975
959
|
return async (ctx, moduleInfo) => {
|
|
976
|
-
await handler.call(new PluginContext(options, ctx, plugin), transformModuleInfo(moduleInfo));
|
|
960
|
+
await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), transformModuleInfo(moduleInfo, pluginContextData.moduleOptionMap.get(moduleInfo.id)));
|
|
977
961
|
};
|
|
978
962
|
}
|
|
979
963
|
|
|
980
964
|
//#endregion
|
|
981
965
|
//#region src/plugin/bindingify-output-hooks.ts
|
|
982
|
-
function bindingifyRenderStart(plugin, options, outputOptions) {
|
|
966
|
+
function bindingifyRenderStart(plugin, options, outputOptions, pluginContextData) {
|
|
983
967
|
const hook = plugin.renderStart;
|
|
984
968
|
if (!hook) {
|
|
985
969
|
return undefined;
|
|
986
970
|
}
|
|
987
971
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
988
972
|
return async (ctx) => {
|
|
989
|
-
handler.call(new PluginContext(options, ctx, plugin), outputOptions, options);
|
|
973
|
+
handler.call(new PluginContext(options, ctx, plugin, pluginContextData), outputOptions, options);
|
|
990
974
|
};
|
|
991
975
|
}
|
|
992
|
-
function bindingifyRenderChunk(plugin, options, outputOptions) {
|
|
976
|
+
function bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData) {
|
|
993
977
|
const hook = plugin.renderChunk;
|
|
994
978
|
if (!hook) {
|
|
995
979
|
return undefined;
|
|
996
980
|
}
|
|
997
981
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
998
982
|
return async (ctx, code, chunk) => {
|
|
999
|
-
const ret = await handler.call(new PluginContext(options, ctx, plugin), code, chunk, outputOptions);
|
|
983
|
+
const ret = await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), code, chunk, outputOptions);
|
|
1000
984
|
if (ret == null) {
|
|
1001
985
|
return;
|
|
1002
986
|
}
|
|
@@ -1012,65 +996,108 @@ function bindingifyRenderChunk(plugin, options, outputOptions) {
|
|
|
1012
996
|
};
|
|
1013
997
|
};
|
|
1014
998
|
}
|
|
1015
|
-
function bindingifyAugmentChunkHash(plugin, options) {
|
|
999
|
+
function bindingifyAugmentChunkHash(plugin, options, pluginContextData) {
|
|
1016
1000
|
const hook = plugin.augmentChunkHash;
|
|
1017
1001
|
if (!hook) {
|
|
1018
1002
|
return undefined;
|
|
1019
1003
|
}
|
|
1020
1004
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
1021
1005
|
return async (ctx, chunk) => {
|
|
1022
|
-
return await handler.call(new PluginContext(options, ctx, plugin), chunk);
|
|
1006
|
+
return await handler.call(new PluginContext(options, ctx, plugin, pluginContextData), chunk);
|
|
1023
1007
|
};
|
|
1024
1008
|
}
|
|
1025
|
-
function bindingifyRenderError(plugin, options) {
|
|
1009
|
+
function bindingifyRenderError(plugin, options, pluginContextData) {
|
|
1026
1010
|
const hook = plugin.renderError;
|
|
1027
1011
|
if (!hook) {
|
|
1028
1012
|
return undefined;
|
|
1029
1013
|
}
|
|
1030
1014
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
1031
1015
|
return async (ctx, err) => {
|
|
1032
|
-
handler.call(new PluginContext(options, ctx, plugin), new Error(err));
|
|
1016
|
+
handler.call(new PluginContext(options, ctx, plugin, pluginContextData), new Error(err));
|
|
1033
1017
|
};
|
|
1034
1018
|
}
|
|
1035
|
-
function bindingifyGenerateBundle(plugin, options, outputOptions) {
|
|
1019
|
+
function bindingifyGenerateBundle(plugin, options, outputOptions, pluginContextData) {
|
|
1036
1020
|
const hook = plugin.generateBundle;
|
|
1037
1021
|
if (!hook) {
|
|
1038
1022
|
return undefined;
|
|
1039
1023
|
}
|
|
1040
1024
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
1041
1025
|
return async (ctx, bundle, isWrite) => {
|
|
1042
|
-
handler.call(new PluginContext(options, ctx, plugin), outputOptions, transformToOutputBundle(bundle), isWrite);
|
|
1026
|
+
handler.call(new PluginContext(options, ctx, plugin, pluginContextData), outputOptions, transformToOutputBundle(bundle), isWrite);
|
|
1043
1027
|
};
|
|
1044
1028
|
}
|
|
1045
|
-
function bindingifyWriteBundle(plugin, options, outputOptions) {
|
|
1029
|
+
function bindingifyWriteBundle(plugin, options, outputOptions, pluginContextData) {
|
|
1046
1030
|
const hook = plugin.writeBundle;
|
|
1047
1031
|
if (!hook) {
|
|
1048
1032
|
return undefined;
|
|
1049
1033
|
}
|
|
1050
1034
|
const [handler, _optionsIgnoredSofar] = normalizeHook(hook);
|
|
1051
1035
|
return async (ctx, bundle) => {
|
|
1052
|
-
handler.call(new PluginContext(options, ctx, plugin), outputOptions, transformToOutputBundle(bundle));
|
|
1036
|
+
handler.call(new PluginContext(options, ctx, plugin, pluginContextData), outputOptions, transformToOutputBundle(bundle));
|
|
1053
1037
|
};
|
|
1054
1038
|
}
|
|
1055
1039
|
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/plugin/plugin-context-data.ts
|
|
1042
|
+
class PluginContextData {
|
|
1043
|
+
modules = new Map();
|
|
1044
|
+
moduleIds = null;
|
|
1045
|
+
moduleOptionMap = new Map();
|
|
1046
|
+
updateModuleOption(id, option) {
|
|
1047
|
+
const existing = this.moduleOptionMap.get(id);
|
|
1048
|
+
if (existing) {
|
|
1049
|
+
Object.assign(existing, option);
|
|
1050
|
+
if (option.meta != null) {
|
|
1051
|
+
Object.assign(existing.meta, option.meta);
|
|
1052
|
+
}
|
|
1053
|
+
} else {
|
|
1054
|
+
this.moduleOptionMap.set(id, option);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
getModuleInfo(id, context) {
|
|
1058
|
+
if (this.modules.has(id)) {
|
|
1059
|
+
return this.modules.get(id) ?? null;
|
|
1060
|
+
}
|
|
1061
|
+
const bindingInfo = context.getModuleInfo(id);
|
|
1062
|
+
if (bindingInfo) {
|
|
1063
|
+
const info = transformModuleInfo(bindingInfo, this.moduleOptionMap.get(id));
|
|
1064
|
+
this.modules.set(id, info);
|
|
1065
|
+
return info;
|
|
1066
|
+
}
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
getModuleIds(context) {
|
|
1070
|
+
if (this.moduleIds) {
|
|
1071
|
+
return this.moduleIds.values();
|
|
1072
|
+
}
|
|
1073
|
+
const moduleIds = context.getModuleIds();
|
|
1074
|
+
if (moduleIds) {
|
|
1075
|
+
this.moduleIds = moduleIds;
|
|
1076
|
+
return moduleIds.values();
|
|
1077
|
+
}
|
|
1078
|
+
return [].values();
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1056
1082
|
//#endregion
|
|
1057
1083
|
//#region src/plugin/bindingify-plugin.ts
|
|
1058
1084
|
function bindingifyPlugin(plugin, options, outputOptions) {
|
|
1085
|
+
const pluginContextData = new PluginContextData();
|
|
1059
1086
|
return {
|
|
1060
1087
|
name: plugin.name ?? 'unknown',
|
|
1061
|
-
buildStart: bindingifyBuildStart(plugin, options),
|
|
1062
|
-
resolveId: bindingifyResolveId(plugin, options),
|
|
1063
|
-
resolveDynamicImport: bindingifyResolveDynamicImport(plugin, options),
|
|
1064
|
-
buildEnd: bindingifyBuildEnd(plugin, options),
|
|
1065
|
-
transform: bindingifyTransform(plugin, options),
|
|
1066
|
-
moduleParsed: bindingifyModuleParsed(plugin, options),
|
|
1067
|
-
load: bindingifyLoad(plugin, options),
|
|
1068
|
-
renderChunk: bindingifyRenderChunk(plugin, options, outputOptions),
|
|
1069
|
-
augmentChunkHash: bindingifyAugmentChunkHash(plugin, options),
|
|
1070
|
-
renderStart: bindingifyRenderStart(plugin, options, outputOptions),
|
|
1071
|
-
renderError: bindingifyRenderError(plugin, options),
|
|
1072
|
-
generateBundle: bindingifyGenerateBundle(plugin, options, outputOptions),
|
|
1073
|
-
writeBundle: bindingifyWriteBundle(plugin, options, outputOptions)
|
|
1088
|
+
buildStart: bindingifyBuildStart(plugin, options, pluginContextData),
|
|
1089
|
+
resolveId: bindingifyResolveId(plugin, options, pluginContextData),
|
|
1090
|
+
resolveDynamicImport: bindingifyResolveDynamicImport(plugin, options, pluginContextData),
|
|
1091
|
+
buildEnd: bindingifyBuildEnd(plugin, options, pluginContextData),
|
|
1092
|
+
transform: bindingifyTransform(plugin, options, pluginContextData),
|
|
1093
|
+
moduleParsed: bindingifyModuleParsed(plugin, options, pluginContextData),
|
|
1094
|
+
load: bindingifyLoad(plugin, options, pluginContextData),
|
|
1095
|
+
renderChunk: bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData),
|
|
1096
|
+
augmentChunkHash: bindingifyAugmentChunkHash(plugin, options, pluginContextData),
|
|
1097
|
+
renderStart: bindingifyRenderStart(plugin, options, outputOptions, pluginContextData),
|
|
1098
|
+
renderError: bindingifyRenderError(plugin, options, pluginContextData),
|
|
1099
|
+
generateBundle: bindingifyGenerateBundle(plugin, options, outputOptions, pluginContextData),
|
|
1100
|
+
writeBundle: bindingifyWriteBundle(plugin, options, outputOptions, pluginContextData)
|
|
1074
1101
|
};
|
|
1075
1102
|
}
|
|
1076
1103
|
|
|
@@ -1401,14 +1428,15 @@ function normalizeTreeshakeOptions(config) {
|
|
|
1401
1428
|
if (config === true || config === undefined) {
|
|
1402
1429
|
return {moduleSideEffects: 'true'};
|
|
1403
1430
|
}
|
|
1431
|
+
let normalizedConfig = {moduleSideEffects: ''};
|
|
1404
1432
|
if (config.moduleSideEffects === undefined) {
|
|
1405
|
-
|
|
1433
|
+
normalizedConfig.moduleSideEffects = 'true';
|
|
1406
1434
|
} else if (isRegExp(config.moduleSideEffects)) {
|
|
1407
|
-
|
|
1435
|
+
normalizedConfig.moduleSideEffects = config.moduleSideEffects.source;
|
|
1408
1436
|
} else {
|
|
1409
|
-
|
|
1437
|
+
normalizedConfig.moduleSideEffects = config.moduleSideEffects.toString();
|
|
1410
1438
|
}
|
|
1411
|
-
return
|
|
1439
|
+
return normalizedConfig;
|
|
1412
1440
|
}
|
|
1413
1441
|
|
|
1414
1442
|
//#endregion
|
package/dist/types/binding.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
type MaybePromise<T> = T | Promise<T>
|
|
2
2
|
type Nullable<T> = T | null | undefined
|
|
3
3
|
type VoidNullable<T = void> = T | null | undefined | void
|
|
4
|
-
export class BindingLog {
|
|
4
|
+
export declare class BindingLog {
|
|
5
5
|
code: string
|
|
6
6
|
message: string
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export class BindingModuleInfo {
|
|
9
|
+
export declare class BindingModuleInfo {
|
|
10
10
|
id: string
|
|
11
11
|
importers: Array<string>
|
|
12
12
|
dynamicImporters: Array<string>
|
|
@@ -16,13 +16,13 @@ export class BindingModuleInfo {
|
|
|
16
16
|
get code(): string | null
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export class BindingOutputAsset {
|
|
19
|
+
export declare class BindingOutputAsset {
|
|
20
20
|
get fileName(): string
|
|
21
21
|
get source(): BindingAssetSource
|
|
22
22
|
set source(source: BindingAssetSource)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export class BindingOutputChunk {
|
|
25
|
+
export declare class BindingOutputChunk {
|
|
26
26
|
get isEntry(): boolean
|
|
27
27
|
get isDynamicEntry(): boolean
|
|
28
28
|
get facadeModuleId(): string | null
|
|
@@ -43,13 +43,13 @@ export class BindingOutputChunk {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** The `BindingOutputs` owner `Vec<Output>` the mutable reference, it avoid `Clone` at call `writeBundle/generateBundle` hook, and make it mutable. */
|
|
46
|
-
export class BindingOutputs {
|
|
46
|
+
export declare class BindingOutputs {
|
|
47
47
|
get chunks(): Array<BindingOutputChunk>
|
|
48
48
|
get assets(): Array<BindingOutputAsset>
|
|
49
49
|
delete(fileName: string): void
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export class BindingPluginContext {
|
|
52
|
+
export declare class BindingPluginContext {
|
|
53
53
|
resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>
|
|
54
54
|
emitFile(file: BindingEmittedAsset): string
|
|
55
55
|
getFileName(referenceId: string): string
|
|
@@ -57,11 +57,11 @@ export class BindingPluginContext {
|
|
|
57
57
|
getModuleIds(): Array<string> | null
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export class BindingTransformPluginContext {
|
|
60
|
+
export declare class BindingTransformPluginContext {
|
|
61
61
|
inner(): BindingPluginContext
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export class Bundler {
|
|
64
|
+
export declare class Bundler {
|
|
65
65
|
constructor(inputOptions: BindingInputOptions, outputOptions: BindingOutputOptions, parallelPluginsRegistry?: ParallelJsPluginRegistry | undefined | null)
|
|
66
66
|
write(): Promise<FinalBindingOutputs>
|
|
67
67
|
generate(): Promise<FinalBindingOutputs>
|
|
@@ -72,12 +72,12 @@ export class Bundler {
|
|
|
72
72
|
* The `FinalBindingOutputs` is used at `write()` or `generate()`, it is similar to `BindingOutputs`, if using `BindingOutputs` has unexpected behavior.
|
|
73
73
|
* TODO find a way to export it gracefully.
|
|
74
74
|
*/
|
|
75
|
-
export class FinalBindingOutputs {
|
|
75
|
+
export declare class FinalBindingOutputs {
|
|
76
76
|
get chunks(): Array<BindingOutputChunk>
|
|
77
77
|
get assets(): Array<BindingOutputAsset>
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export class ParallelJsPluginRegistry {
|
|
80
|
+
export declare class ParallelJsPluginRegistry {
|
|
81
81
|
id: number
|
|
82
82
|
workerCount: number
|
|
83
83
|
constructor(workerCount: number)
|
|
@@ -101,7 +101,7 @@ export interface BindingBuiltinPlugin {
|
|
|
101
101
|
options?: unknown
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export enum BindingBuiltinPluginName {
|
|
104
|
+
export declare enum BindingBuiltinPluginName {
|
|
105
105
|
WasmPlugin = 0,
|
|
106
106
|
GlobImportPlugin = 1
|
|
107
107
|
}
|
|
@@ -134,12 +134,18 @@ export interface BindingHookResolveIdOutput {
|
|
|
134
134
|
sideEffects?: BindingHookSideEffects
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
export enum BindingHookSideEffects {
|
|
137
|
+
export declare enum BindingHookSideEffects {
|
|
138
138
|
True = 0,
|
|
139
139
|
False = 1,
|
|
140
140
|
NoTreeshake = 2
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
export interface BindingHookTransformOutput {
|
|
144
|
+
code?: string
|
|
145
|
+
sideEffects?: BindingHookSideEffects
|
|
146
|
+
map?: BindingSourcemap
|
|
147
|
+
}
|
|
148
|
+
|
|
143
149
|
export interface BindingInputItem {
|
|
144
150
|
name?: string
|
|
145
151
|
import: string
|
|
@@ -168,7 +174,7 @@ export interface BindingJsonSourcemap {
|
|
|
168
174
|
names?: Array<string>
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
export enum BindingLogLevel {
|
|
177
|
+
export declare enum BindingLogLevel {
|
|
172
178
|
Silent = 0,
|
|
173
179
|
Warn = 1,
|
|
174
180
|
Info = 2,
|
|
@@ -205,7 +211,7 @@ export interface BindingPluginOptions {
|
|
|
205
211
|
resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraOptions) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
|
|
206
212
|
resolveDynamicImport?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
|
|
207
213
|
load?: (ctx: BindingPluginContext, id: string) => MaybePromise<VoidNullable<BindingHookLoadOutput>>
|
|
208
|
-
transform?: (ctx: BindingTransformPluginContext, id: string, code: string) => MaybePromise<VoidNullable<
|
|
214
|
+
transform?: (ctx: BindingTransformPluginContext, id: string, code: string) => MaybePromise<VoidNullable<BindingHookTransformOutput>>
|
|
209
215
|
moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>
|
|
210
216
|
buildEnd?: (ctx: BindingPluginContext, error: Nullable<string>) => MaybePromise<VoidNullable>
|
|
211
217
|
renderChunk?: (ctx: BindingPluginContext, code: string, chunk: RenderedChunk) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>
|
|
@@ -251,7 +257,7 @@ export interface Es2015BindingOptions {
|
|
|
251
257
|
}
|
|
252
258
|
|
|
253
259
|
/** TypeScript Isolated Declarations for Standalone DTS Emit */
|
|
254
|
-
function isolatedDeclaration(filename: string, sourceText: string): IsolatedDeclarationsResult
|
|
260
|
+
export declare function isolatedDeclaration(filename: string, sourceText: string): IsolatedDeclarationsResult
|
|
255
261
|
|
|
256
262
|
export interface IsolatedDeclarationsResult {
|
|
257
263
|
sourceText: string
|
|
@@ -270,7 +276,7 @@ export interface ReactBindingOptions {
|
|
|
270
276
|
useSpread?: boolean
|
|
271
277
|
}
|
|
272
278
|
|
|
273
|
-
function registerPlugins(id: number, plugins: Array<BindingPluginWithIndex>): void
|
|
279
|
+
export declare function registerPlugins(id: number, plugins: Array<BindingPluginWithIndex>): void
|
|
274
280
|
|
|
275
281
|
export interface RenderedChunk {
|
|
276
282
|
name: string
|
|
@@ -294,9 +300,10 @@ export interface Sourcemap {
|
|
|
294
300
|
names?: Array<string>
|
|
295
301
|
}
|
|
296
302
|
|
|
297
|
-
function transform(filename: string, sourceText: string, options?:
|
|
303
|
+
export declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult
|
|
298
304
|
|
|
299
|
-
export interface
|
|
305
|
+
export interface TransformOptions {
|
|
306
|
+
sourceType?: 'script' | 'module' | 'unambiguous' | undefined
|
|
300
307
|
typescript?: TypeScriptBindingOptions
|
|
301
308
|
react?: ReactBindingOptions
|
|
302
309
|
es2015?: Es2015BindingOptions
|
|
@@ -56,7 +56,7 @@ declare const inputOptionsSchema: z.ZodObject<{
|
|
|
56
56
|
logLevel: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"info">, z.ZodLiteral<"debug">]>, z.ZodLiteral<"warn">]>, z.ZodLiteral<"silent">]>>;
|
|
57
57
|
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
58
|
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>>;
|
|
59
|
-
moduleTypes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"js">, z.ZodLiteral<"jsx">]>, z.ZodLiteral<"ts">]>, z.ZodLiteral<"tsx">]>, z.ZodLiteral<"
|
|
59
|
+
moduleTypes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"js">, z.ZodLiteral<"jsx">]>, z.ZodLiteral<"ts">]>, z.ZodLiteral<"tsx">]>, z.ZodLiteral<"json">]>, z.ZodLiteral<"text">]>, z.ZodLiteral<"base64">]>, z.ZodLiteral<"dataurl">]>, z.ZodLiteral<"binary">]>, z.ZodLiteral<"empty">]>>>;
|
|
60
60
|
}, "strict", z.ZodTypeAny, {
|
|
61
61
|
input?: string | string[] | Record<string, string> | undefined;
|
|
62
62
|
plugins?: RolldownPlugin[] | undefined;
|
|
@@ -82,7 +82,7 @@ declare const inputOptionsSchema: z.ZodObject<{
|
|
|
82
82
|
logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
|
|
83
83
|
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;
|
|
84
84
|
onwarn?: ((args_0: any, args_1: (args_0: any, ...args_1: unknown[]) => unknown, ...args_2: unknown[]) => unknown) | undefined;
|
|
85
|
-
moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "
|
|
85
|
+
moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
|
|
86
86
|
}, {
|
|
87
87
|
input?: string | string[] | Record<string, string> | undefined;
|
|
88
88
|
plugins?: RolldownPlugin[] | undefined;
|
|
@@ -108,7 +108,7 @@ declare const inputOptionsSchema: z.ZodObject<{
|
|
|
108
108
|
logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
|
|
109
109
|
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;
|
|
110
110
|
onwarn?: ((args_0: any, args_1: (args_0: any, ...args_1: unknown[]) => unknown, ...args_2: unknown[]) => unknown) | undefined;
|
|
111
|
-
moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "
|
|
111
|
+
moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
|
|
112
112
|
}>;
|
|
113
113
|
export type InputOption = z.infer<typeof inputOptionSchema>;
|
|
114
114
|
export type ExternalOption = z.infer<typeof externalSchema>;
|
|
@@ -3,7 +3,7 @@ import type { InputOptions } from './input-options';
|
|
|
3
3
|
import type { RolldownPlugin } from '../plugin';
|
|
4
4
|
import type { LogLevel } from '../log/logging';
|
|
5
5
|
import { NormalizedTreeshakingOptions } from '../../src/treeshake';
|
|
6
|
-
export interface NormalizedInputOptions extends InputOptions {
|
|
6
|
+
export interface NormalizedInputOptions extends Omit<InputOptions, 'treeshake'> {
|
|
7
7
|
input: RollupNormalizedInputOptions['input'];
|
|
8
8
|
plugins: RolldownPlugin[];
|
|
9
9
|
onLog: (level: LogLevel, log: RollupLog) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { BindingPluginOptions } from '../binding';
|
|
2
2
|
import type { Plugin } from './index';
|
|
3
3
|
import { NormalizedInputOptions } from '../options/normalized-input-options';
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
4
|
+
import { PluginContextData } from './plugin-context-data';
|
|
5
|
+
export declare function bindingifyBuildStart(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['buildStart'];
|
|
6
|
+
export declare function bindingifyBuildEnd(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['buildEnd'];
|
|
7
|
+
export declare function bindingifyResolveId(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['resolveId'];
|
|
8
|
+
export declare function bindingifyResolveDynamicImport(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['resolveDynamicImport'];
|
|
9
|
+
export declare function bindingifyTransform(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['transform'];
|
|
10
|
+
export declare function bindingifyLoad(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['load'];
|
|
11
|
+
export declare function bindingifyModuleParsed(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['moduleParsed'];
|
|
@@ -2,9 +2,10 @@ import type { BindingPluginOptions } from '../binding';
|
|
|
2
2
|
import type { NormalizedInputOptions } from '../options/normalized-input-options';
|
|
3
3
|
import type { Plugin } from './index';
|
|
4
4
|
import { NormalizedOutputOptions } from '../options/normalized-output-options';
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
5
|
+
import { PluginContextData } from './plugin-context-data';
|
|
6
|
+
export declare function bindingifyRenderStart(plugin: Plugin, options: NormalizedInputOptions, outputOptions: NormalizedOutputOptions, pluginContextData: PluginContextData): BindingPluginOptions['renderStart'];
|
|
7
|
+
export declare function bindingifyRenderChunk(plugin: Plugin, options: NormalizedInputOptions, outputOptions: NormalizedOutputOptions, pluginContextData: PluginContextData): BindingPluginOptions['renderChunk'];
|
|
8
|
+
export declare function bindingifyAugmentChunkHash(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['augmentChunkHash'];
|
|
9
|
+
export declare function bindingifyRenderError(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): BindingPluginOptions['renderError'];
|
|
10
|
+
export declare function bindingifyGenerateBundle(plugin: Plugin, options: NormalizedInputOptions, outputOptions: NormalizedOutputOptions, pluginContextData: PluginContextData): BindingPluginOptions['generateBundle'];
|
|
11
|
+
export declare function bindingifyWriteBundle(plugin: Plugin, options: NormalizedInputOptions, outputOptions: NormalizedOutputOptions, pluginContextData: PluginContextData): BindingPluginOptions['writeBundle'];
|