rolldown 1.0.0-beta.2-commit.5deb279 → 1.0.0-beta.21
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/bin/cli.mjs +2 -0
- package/dist/{cjs/cli.cjs → cli.cjs} +630 -603
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{esm/cli.mjs → cli.mjs} +605 -575
- package/dist/config.cjs +12 -0
- package/dist/config.d.cts +10 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.cjs +107 -0
- package/dist/experimental-index.d.cts +63 -0
- package/dist/experimental-index.d.mts +63 -0
- package/dist/experimental-index.mjs +82 -0
- package/dist/experimental-runtime-types.d.ts +52 -0
- package/dist/filter-index.cjs +105 -0
- package/dist/filter-index.d.cts +4 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -14
- package/dist/parallel-plugin-worker.d.cts +1 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -12
- package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
- package/dist/parallel-plugin.d.cts +14 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.d.cts +9 -0
- package/dist/parse-ast-index.d.mts +9 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding--Ro_HG7S.d.mts +1246 -0
- package/dist/shared/binding-DBnJxycu.d.cts +1246 -0
- package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
- package/dist/shared/define-config-LuFmoc43.d.cts +1204 -0
- package/dist/shared/define-config-WLh0sQOM.d.mts +1204 -0
- package/dist/shared/load-config-DUa6Uqtc.mjs +119 -0
- package/dist/shared/load-config-juy1xxPU.cjs +125 -0
- package/dist/shared/misc-BKp5iIef.cjs +67 -0
- package/dist/shared/misc-BN0nse6C.mjs +25 -0
- package/dist/shared/parse-ast-index-CVVmsBjK.cjs +738 -0
- package/dist/shared/parse-ast-index-DW8kbzjr.mjs +616 -0
- package/dist/shared/{prompt-Nfm4Xz36.mjs → prompt-C5jz26Zn.mjs} +247 -246
- package/dist/shared/{prompt-B7tq3GL9.cjs → prompt-QNI93ne7.cjs} +250 -250
- package/dist/shared/src-LzfUVOSn.mjs +4647 -0
- package/dist/shared/src-ajsKFM6g.cjs +4851 -0
- package/package.json +65 -67
- package/bin/cli.js +0 -2
- package/dist/cjs/experimental-index.cjs +0 -79
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parse-ast-index.cjs +0 -57
- package/dist/esm/experimental-index.mjs +0 -56
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -55
- package/dist/shared/binding-l7VLSKnB.mjs +0 -610
- package/dist/shared/binding-orkvONpS.cjs +0 -661
- package/dist/shared/src-CV5Vk_cS.cjs +0 -2828
- package/dist/shared/src-CwOjWVUb.mjs +0 -2647
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/build.js +0 -22
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/experimental.js +0 -13
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/index.js +0 -7
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -12
- package/dist/types/api/rolldown/rolldown-build.js +0 -43
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/index.js +0 -8
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watch-emitter.js +0 -69
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/api/watch/watcher.js +0 -66
- package/dist/types/binding.d.ts +0 -1327
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/alias-plugin.js +0 -4
- package/dist/types/builtin-plugin/constructors.d.ts +0 -20
- package/dist/types/builtin-plugin/constructors.js +0 -68
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/replace-plugin.js +0 -29
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/transform-plugin.js +0 -16
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/builtin-plugin/utils.js +0 -19
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/alias.js +0 -63
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/index.js +0 -127
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/normalize.js +0 -48
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/arguments/utils.js +0 -67
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/colors.js +0 -17
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/bundle.js +0 -203
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/commands/help.js +0 -88
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/index.js +0 -27
- package/dist/types/cli/load-config.d.ts +0 -3
- package/dist/types/cli/load-config.js +0 -95
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/cli/logger.js +0 -35
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin-context.js +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/constants/plugin.js +0 -69
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/experimental-index.js +0 -9
- package/dist/types/index.d.ts +0 -28
- package/dist/types/index.js +0 -7
- package/dist/types/log/logHandler.d.ts +0 -4
- package/dist/types/log/logHandler.js +0 -25
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logger.js +0 -107
- package/dist/types/log/logging.d.ts +0 -11
- package/dist/types/log/logging.js +0 -11
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/log/logs.js +0 -86
- package/dist/types/options/input-options.d.ts +0 -170
- package/dist/types/options/input-options.js +0 -1
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-input-options.js +0 -21
- package/dist/types/options/normalized-output-options.d.ts +0 -67
- package/dist/types/options/normalized-output-options.js +0 -99
- package/dist/types/options/output-options.d.ts +0 -86
- package/dist/types/options/output-options.js +0 -1
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/options/watch-options.js +0 -1
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin-worker.js +0 -31
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parallel-plugin.js +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -4
- package/dist/types/parse-ast-index.js +0 -73
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-build-hooks.js +0 -213
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-hook-filter.js +0 -39
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-output-hooks.js +0 -189
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -15
- package/dist/types/plugin/bindingify-plugin.js +0 -124
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/hook-filter.js +0 -1
- package/dist/types/plugin/index.d.ts +0 -126
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -15
- package/dist/types/plugin/minimal-plugin-context.js +0 -25
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/parallel-plugin.js +0 -6
- package/dist/types/plugin/plugin-context-data.d.ts +0 -16
- package/dist/types/plugin/plugin-context-data.js +0 -55
- package/dist/types/plugin/plugin-context.d.ts +0 -52
- package/dist/types/plugin/plugin-context.js +0 -108
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/plugin-driver.js +0 -88
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -17
- package/dist/types/plugin/transform-plugin-context.js +0 -37
- package/dist/types/types/assert.d.ts +0 -13
- package/dist/types/types/assert.js +0 -1
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/config-export.js +0 -1
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/misc.js +0 -1
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-info.js +0 -1
- package/dist/types/types/module-side-effects.d.ts +0 -10
- package/dist/types/types/module-side-effects.js +0 -1
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/output-bundle.js +0 -1
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-options.js +0 -1
- package/dist/types/types/rolldown-output.d.ts +0 -63
- package/dist/types/types/rolldown-output.js +0 -1
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/schema.js +0 -1
- package/dist/types/types/sourcemap.d.ts +0 -13
- package/dist/types/types/sourcemap.js +0 -16
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/types/utils.js +0 -1
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/asset-source.js +0 -8
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/async-flatten.js +0 -7
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-input-options.js +0 -225
- package/dist/types/utils/bindingify-output-options.d.ts +0 -3
- package/dist/types/utils/bindingify-output-options.js +0 -92
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/code-frame.js +0 -46
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/compose-js-plugins.js +0 -400
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler-option.js +0 -53
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/create-bundler.js +0 -15
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/define-config.js +0 -3
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/error.js +0 -65
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/initialize-parallel-plugins.js +0 -54
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/misc.js +0 -22
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-hook.js +0 -21
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-plugin-option.js +0 -35
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/normalize-string-or-regex.js +0 -14
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/plugin/index.js +0 -7
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-module-info.js +0 -19
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.js +0 -43
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-rendered-module.js +0 -10
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.js +0 -16
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.js +0 -29
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/transform-to-rollup-output.js +0 -165
- package/dist/types/utils/validator.d.ts +0 -7
- package/dist/types/utils/validator.js +0 -275
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { normalizeHook } from '../utils/normalize-hook';
|
|
2
|
-
import { collectChangedBundle, transformToOutputBundle, } from '../utils/transform-to-rollup-output';
|
|
3
|
-
import { PluginContext } from './plugin-context';
|
|
4
|
-
import { bindingifySourcemap } from '../types/sourcemap';
|
|
5
|
-
import { bindingifyPluginHookMeta, } from './bindingify-plugin-hook-meta';
|
|
6
|
-
import { NormalizedInputOptionsImpl } from '../options/normalized-input-options';
|
|
7
|
-
import { NormalizedOutputOptionsImpl } from '../options/normalized-output-options';
|
|
8
|
-
import { transformRenderedChunk } from '../utils/transform-rendered-chunk';
|
|
9
|
-
import { normalizeErrors } from '../utils/error';
|
|
10
|
-
export function bindingifyRenderStart(args) {
|
|
11
|
-
const hook = args.plugin.renderStart;
|
|
12
|
-
if (!hook) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
const { handler, meta } = normalizeHook(hook);
|
|
16
|
-
return {
|
|
17
|
-
plugin: async (ctx, opts) => {
|
|
18
|
-
handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedOutputOptionsImpl(opts), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
19
|
-
},
|
|
20
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export function bindingifyRenderChunk(args) {
|
|
24
|
-
const hook = args.plugin.renderChunk;
|
|
25
|
-
if (!hook) {
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
const { handler, meta } = normalizeHook(hook);
|
|
29
|
-
return {
|
|
30
|
-
plugin: async (ctx, code, chunk, opts) => {
|
|
31
|
-
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), code, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts));
|
|
32
|
-
if (ret == null) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (typeof ret === 'string') {
|
|
36
|
-
return { code: ret };
|
|
37
|
-
}
|
|
38
|
-
if (!ret.map) {
|
|
39
|
-
return { code: ret.code };
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
code: ret.code,
|
|
43
|
-
map: bindingifySourcemap(ret.map),
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function bindingifyAugmentChunkHash(args) {
|
|
50
|
-
const hook = args.plugin.augmentChunkHash;
|
|
51
|
-
if (!hook) {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
const { handler, meta } = normalizeHook(hook);
|
|
55
|
-
return {
|
|
56
|
-
plugin: async (ctx, chunk) => {
|
|
57
|
-
return await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformRenderedChunk(chunk));
|
|
58
|
-
},
|
|
59
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export function bindingifyRenderError(args) {
|
|
63
|
-
const hook = args.plugin.renderError;
|
|
64
|
-
if (!hook) {
|
|
65
|
-
return {};
|
|
66
|
-
}
|
|
67
|
-
const { handler, meta } = normalizeHook(hook);
|
|
68
|
-
return {
|
|
69
|
-
plugin: async (ctx, err) => {
|
|
70
|
-
handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), normalizeErrors(err));
|
|
71
|
-
},
|
|
72
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export function bindingifyGenerateBundle(args) {
|
|
76
|
-
const hook = args.plugin.generateBundle;
|
|
77
|
-
if (!hook) {
|
|
78
|
-
return {};
|
|
79
|
-
}
|
|
80
|
-
const { handler, meta } = normalizeHook(hook);
|
|
81
|
-
return {
|
|
82
|
-
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
83
|
-
const changed = {
|
|
84
|
-
updated: new Set(),
|
|
85
|
-
deleted: new Set(),
|
|
86
|
-
};
|
|
87
|
-
const output = transformToOutputBundle(bundle, changed);
|
|
88
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedOutputOptionsImpl(opts), output, isWrite);
|
|
89
|
-
return collectChangedBundle(changed, output);
|
|
90
|
-
},
|
|
91
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function bindingifyWriteBundle(args) {
|
|
95
|
-
const hook = args.plugin.writeBundle;
|
|
96
|
-
if (!hook) {
|
|
97
|
-
return {};
|
|
98
|
-
}
|
|
99
|
-
const { handler, meta } = normalizeHook(hook);
|
|
100
|
-
return {
|
|
101
|
-
plugin: async (ctx, bundle, opts) => {
|
|
102
|
-
const changed = {
|
|
103
|
-
updated: new Set(),
|
|
104
|
-
deleted: new Set(),
|
|
105
|
-
};
|
|
106
|
-
const output = transformToOutputBundle(bundle, changed);
|
|
107
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedOutputOptionsImpl(opts), output);
|
|
108
|
-
return collectChangedBundle(changed, output);
|
|
109
|
-
},
|
|
110
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export function bindingifyCloseBundle(args) {
|
|
114
|
-
const hook = args.plugin.closeBundle;
|
|
115
|
-
if (!hook) {
|
|
116
|
-
return {};
|
|
117
|
-
}
|
|
118
|
-
const { handler, meta } = normalizeHook(hook);
|
|
119
|
-
return {
|
|
120
|
-
plugin: async (ctx) => {
|
|
121
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel));
|
|
122
|
-
},
|
|
123
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
export function bindingifyBanner(args) {
|
|
127
|
-
const hook = args.plugin.banner;
|
|
128
|
-
if (!hook) {
|
|
129
|
-
return {};
|
|
130
|
-
}
|
|
131
|
-
const { handler, meta } = normalizeHook(hook);
|
|
132
|
-
return {
|
|
133
|
-
plugin: async (ctx, chunk) => {
|
|
134
|
-
if (typeof handler === 'string') {
|
|
135
|
-
return handler;
|
|
136
|
-
}
|
|
137
|
-
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformRenderedChunk(chunk));
|
|
138
|
-
},
|
|
139
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
export function bindingifyFooter(args) {
|
|
143
|
-
const hook = args.plugin.footer;
|
|
144
|
-
if (!hook) {
|
|
145
|
-
return {};
|
|
146
|
-
}
|
|
147
|
-
const { handler, meta } = normalizeHook(hook);
|
|
148
|
-
return {
|
|
149
|
-
plugin: async (ctx, chunk) => {
|
|
150
|
-
if (typeof handler === 'string') {
|
|
151
|
-
return handler;
|
|
152
|
-
}
|
|
153
|
-
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformRenderedChunk(chunk));
|
|
154
|
-
},
|
|
155
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
export function bindingifyIntro(args) {
|
|
159
|
-
const hook = args.plugin.intro;
|
|
160
|
-
if (!hook) {
|
|
161
|
-
return {};
|
|
162
|
-
}
|
|
163
|
-
const { handler, meta } = normalizeHook(hook);
|
|
164
|
-
return {
|
|
165
|
-
plugin: async (ctx, chunk) => {
|
|
166
|
-
if (typeof handler === 'string') {
|
|
167
|
-
return handler;
|
|
168
|
-
}
|
|
169
|
-
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformRenderedChunk(chunk));
|
|
170
|
-
},
|
|
171
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
export function bindingifyOutro(args) {
|
|
175
|
-
const hook = args.plugin.outro;
|
|
176
|
-
if (!hook) {
|
|
177
|
-
return {};
|
|
178
|
-
}
|
|
179
|
-
const { handler, meta } = normalizeHook(hook);
|
|
180
|
-
return {
|
|
181
|
-
plugin: async (ctx, chunk) => {
|
|
182
|
-
if (typeof handler === 'string') {
|
|
183
|
-
return handler;
|
|
184
|
-
}
|
|
185
|
-
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformRenderedChunk(chunk));
|
|
186
|
-
},
|
|
187
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
188
|
-
};
|
|
189
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ObjectHookMeta } from '.';
|
|
2
|
-
import { BindingPluginHookMeta } from '../binding';
|
|
3
|
-
export declare function bindingifyPluginHookMeta(options: ObjectHookMeta): BindingPluginHookMeta;
|
|
4
|
-
export type PluginHookWithBindingExt<T, F = undefined> = {
|
|
5
|
-
plugin?: T;
|
|
6
|
-
meta?: BindingPluginHookMeta;
|
|
7
|
-
filter?: F;
|
|
8
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BindingPluginOrder } from '../binding';
|
|
2
|
-
export function bindingifyPluginHookMeta(options) {
|
|
3
|
-
return {
|
|
4
|
-
order: bindingPluginOrder(options.order),
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
function bindingPluginOrder(order) {
|
|
8
|
-
switch (order) {
|
|
9
|
-
case 'post':
|
|
10
|
-
return BindingPluginOrder.Post;
|
|
11
|
-
case 'pre':
|
|
12
|
-
return BindingPluginOrder.Pre;
|
|
13
|
-
case null:
|
|
14
|
-
case undefined:
|
|
15
|
-
return undefined;
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(`Unknown plugin order: ${order}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { BindingPluginOptions } from '../binding';
|
|
2
|
-
import type { Plugin } from './index';
|
|
3
|
-
import type { OutputOptions } from '../options/output-options';
|
|
4
|
-
import { PluginContextData } from './plugin-context-data';
|
|
5
|
-
import type { LogHandler, LogLevelOption } from '../types/misc';
|
|
6
|
-
import type { InputOptions } from '../options/input-options';
|
|
7
|
-
export interface BindingifyPluginArgs {
|
|
8
|
-
plugin: Plugin;
|
|
9
|
-
options: InputOptions;
|
|
10
|
-
outputOptions: OutputOptions;
|
|
11
|
-
pluginContextData: PluginContextData;
|
|
12
|
-
onLog: LogHandler;
|
|
13
|
-
logLevel: LogLevelOption;
|
|
14
|
-
}
|
|
15
|
-
export declare function bindingifyPlugin(plugin: Plugin, options: InputOptions, outputOptions: OutputOptions, pluginContextData: PluginContextData, onLog: LogHandler, logLevel: LogLevelOption): BindingPluginOptions;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { bindingifyBuildEnd, bindingifyBuildStart, bindingifyLoad, bindingifyModuleParsed, bindingifyResolveDynamicImport, bindingifyResolveId, bindingifyTransform, } from './bindingify-build-hooks';
|
|
2
|
-
import { bindingifyRenderStart, bindingifyRenderChunk, bindingifyGenerateBundle, bindingifyWriteBundle, bindingifyRenderError, bindingifyAugmentChunkHash, bindingifyBanner, bindingifyFooter, bindingifyIntro, bindingifyOutro, bindingifyCloseBundle, } from './bindingify-output-hooks';
|
|
3
|
-
import { bindingifyCloseWatcher, bindingifyWatchChange, } from './bindingify-watch-hooks';
|
|
4
|
-
import { error, logPluginError } from '../log/logs';
|
|
5
|
-
// Note: because napi not catch error, so we need to catch error and print error to debugger in adapter.
|
|
6
|
-
export function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, onLog, logLevel) {
|
|
7
|
-
const args = {
|
|
8
|
-
plugin,
|
|
9
|
-
options,
|
|
10
|
-
outputOptions,
|
|
11
|
-
pluginContextData,
|
|
12
|
-
onLog,
|
|
13
|
-
logLevel,
|
|
14
|
-
};
|
|
15
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
16
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter, } = bindingifyResolveId(args);
|
|
17
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
18
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
19
|
-
const { plugin: transform, meta: transformMeta, filter: transformFilter, } = bindingifyTransform(args);
|
|
20
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
21
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter, } = bindingifyLoad(args);
|
|
22
|
-
const { plugin: renderChunk, meta: renderChunkMeta } = bindingifyRenderChunk(args);
|
|
23
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
24
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
25
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
26
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
27
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
28
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
29
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
30
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
31
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
32
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
33
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
34
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
35
|
-
const result = {
|
|
36
|
-
// The plugin name already normalized at `normalizePlugins`, see `packages/rolldown/src/utils/normalize-plugin-option.ts`
|
|
37
|
-
name: plugin.name,
|
|
38
|
-
buildStart,
|
|
39
|
-
buildStartMeta,
|
|
40
|
-
resolveId,
|
|
41
|
-
resolveIdMeta,
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
resolveIdFilter,
|
|
44
|
-
resolveDynamicImport,
|
|
45
|
-
resolveDynamicImportMeta,
|
|
46
|
-
buildEnd,
|
|
47
|
-
buildEndMeta,
|
|
48
|
-
transform,
|
|
49
|
-
transformMeta,
|
|
50
|
-
transformFilter,
|
|
51
|
-
moduleParsed,
|
|
52
|
-
moduleParsedMeta,
|
|
53
|
-
load,
|
|
54
|
-
loadMeta,
|
|
55
|
-
loadFilter,
|
|
56
|
-
renderChunk,
|
|
57
|
-
renderChunkMeta,
|
|
58
|
-
augmentChunkHash,
|
|
59
|
-
augmentChunkHashMeta,
|
|
60
|
-
renderStart,
|
|
61
|
-
renderStartMeta,
|
|
62
|
-
renderError,
|
|
63
|
-
renderErrorMeta,
|
|
64
|
-
generateBundle,
|
|
65
|
-
generateBundleMeta,
|
|
66
|
-
writeBundle,
|
|
67
|
-
writeBundleMeta,
|
|
68
|
-
closeBundle,
|
|
69
|
-
closeBundleMeta,
|
|
70
|
-
banner,
|
|
71
|
-
bannerMeta,
|
|
72
|
-
footer,
|
|
73
|
-
footerMeta,
|
|
74
|
-
intro,
|
|
75
|
-
introMeta,
|
|
76
|
-
outro,
|
|
77
|
-
outroMeta,
|
|
78
|
-
watchChange,
|
|
79
|
-
watchChangeMeta,
|
|
80
|
-
closeWatcher,
|
|
81
|
-
closeWatcherMeta,
|
|
82
|
-
};
|
|
83
|
-
return wrapHandlers(result);
|
|
84
|
-
}
|
|
85
|
-
function wrapHandlers(plugin) {
|
|
86
|
-
for (const hookName of [
|
|
87
|
-
'buildStart',
|
|
88
|
-
'resolveId',
|
|
89
|
-
'resolveDynamicImport',
|
|
90
|
-
'buildEnd',
|
|
91
|
-
'transform',
|
|
92
|
-
'moduleParsed',
|
|
93
|
-
'load',
|
|
94
|
-
'renderChunk',
|
|
95
|
-
'augmentChunkHash',
|
|
96
|
-
'renderStart',
|
|
97
|
-
'renderError',
|
|
98
|
-
'generateBundle',
|
|
99
|
-
'writeBundle',
|
|
100
|
-
'closeBundle',
|
|
101
|
-
'banner',
|
|
102
|
-
'footer',
|
|
103
|
-
'intro',
|
|
104
|
-
'outro',
|
|
105
|
-
'watchChange',
|
|
106
|
-
'closeWatcher',
|
|
107
|
-
]) {
|
|
108
|
-
const handler = plugin[hookName];
|
|
109
|
-
if (handler) {
|
|
110
|
-
plugin[hookName] = async (...args) => {
|
|
111
|
-
try {
|
|
112
|
-
return await handler(...args);
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
return error(logPluginError(e, plugin.name, {
|
|
116
|
-
hook: hookName,
|
|
117
|
-
id: hookName === 'transform' ? args[2] : undefined,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return plugin;
|
|
124
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BindingPluginOptions } from '../binding';
|
|
2
|
-
import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
|
|
3
|
-
import { BindingifyPluginArgs } from './bindingify-plugin';
|
|
4
|
-
export declare function bindingifyWatchChange(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['watchChange']>;
|
|
5
|
-
export declare function bindingifyCloseWatcher(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['closeWatcher']>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { normalizeHook } from '../utils/normalize-hook';
|
|
2
|
-
import { PluginContext } from './plugin-context';
|
|
3
|
-
import { bindingifyPluginHookMeta, } from './bindingify-plugin-hook-meta';
|
|
4
|
-
export function bindingifyWatchChange(args) {
|
|
5
|
-
const hook = args.plugin.watchChange;
|
|
6
|
-
if (!hook) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
const { handler, meta } = normalizeHook(hook);
|
|
10
|
-
return {
|
|
11
|
-
plugin: async (ctx, id, event) => {
|
|
12
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), id, { event: event });
|
|
13
|
-
},
|
|
14
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function bindingifyCloseWatcher(args) {
|
|
18
|
-
const hook = args.plugin.closeWatcher;
|
|
19
|
-
if (!hook) {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
const { handler, meta } = normalizeHook(hook);
|
|
23
|
-
return {
|
|
24
|
-
plugin: async (ctx) => {
|
|
25
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel));
|
|
26
|
-
},
|
|
27
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { MaybeArray } from '../types/utils';
|
|
2
|
-
import type { StringOrRegExp } from '../types/utils';
|
|
3
|
-
import type { ModuleType } from '../index';
|
|
4
|
-
export type StringFilter = MaybeArray<StringOrRegExp> | {
|
|
5
|
-
include?: MaybeArray<StringOrRegExp>;
|
|
6
|
-
exclude?: MaybeArray<StringOrRegExp>;
|
|
7
|
-
};
|
|
8
|
-
interface FormalModuleTypeFilter {
|
|
9
|
-
include?: ModuleType[];
|
|
10
|
-
}
|
|
11
|
-
type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
|
|
12
|
-
export interface HookFilter {
|
|
13
|
-
/**
|
|
14
|
-
* This filter is used to do a pre-test to determine whether the hook should be called.
|
|
15
|
-
* @example
|
|
16
|
-
* // Filter out all `id`s that contain `node_modules` in the path.
|
|
17
|
-
* ```js
|
|
18
|
-
* { id: 'node_modules' }
|
|
19
|
-
* ```
|
|
20
|
-
* @example
|
|
21
|
-
* // Filter out all `id`s that contain `node_modules` or `src` in the path.
|
|
22
|
-
* ```js
|
|
23
|
-
* { id: ['node_modules', 'src'] }
|
|
24
|
-
* ```
|
|
25
|
-
* @example
|
|
26
|
-
* // Filter out all `id`s that start with `http`
|
|
27
|
-
* ```js
|
|
28
|
-
* { id: /^http/ }
|
|
29
|
-
* ```
|
|
30
|
-
* @example
|
|
31
|
-
* // Exclude all `id`s that contain `node_modules` in the path.
|
|
32
|
-
* ```js
|
|
33
|
-
* { id: { exclude: 'node_modules' } }
|
|
34
|
-
* ```
|
|
35
|
-
* @example
|
|
36
|
-
* // Formal pattern
|
|
37
|
-
* ```
|
|
38
|
-
* { id : {
|
|
39
|
-
* include: ["foo", /bar/],
|
|
40
|
-
* exclude: ["baz", /qux/]
|
|
41
|
-
* }}
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
id?: StringFilter;
|
|
45
|
-
moduleType?: ModuleTypeFilter;
|
|
46
|
-
code?: StringFilter;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import type { BindingHookResolveIdExtraArgs, BindingTransformHookExtraArgs } from '../binding';
|
|
2
|
-
import type { NormalizedInputOptions } from '../options/normalized-input-options';
|
|
3
|
-
import type { NullValue, MaybePromise, PartialNull, MakeAsync } from '../types/utils';
|
|
4
|
-
import type { SourceMapInput } from '../types/sourcemap';
|
|
5
|
-
import type { ModuleInfo } from '../types/module-info';
|
|
6
|
-
import type { OutputBundle } from '../types/output-bundle';
|
|
7
|
-
import type { PluginContext } from './plugin-context';
|
|
8
|
-
import type { TransformPluginContext } from './transform-plugin-context';
|
|
9
|
-
import type { NormalizedOutputOptions } from '../options/normalized-output-options';
|
|
10
|
-
import type { LogLevel } from '../log/logging';
|
|
11
|
-
import type { RollupLog } from '../types/misc';
|
|
12
|
-
import type { MinimalPluginContext } from './minimal-plugin-context';
|
|
13
|
-
import type { InputOptions, OutputOptions } from '..';
|
|
14
|
-
import type { BuiltinPlugin } from '../builtin-plugin/constructors';
|
|
15
|
-
import type { ParallelPlugin } from './parallel-plugin';
|
|
16
|
-
import type { DefinedHookNames } from '../constants/plugin';
|
|
17
|
-
import type { DEFINED_HOOK_NAMES } from '../constants/plugin';
|
|
18
|
-
import type { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
|
|
19
|
-
import type { HookFilter } from './hook-filter';
|
|
20
|
-
import { RenderedChunk } from '../types/rolldown-output';
|
|
21
|
-
export type ModuleSideEffects = boolean | 'no-treeshake' | null;
|
|
22
|
-
export type ModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
|
|
23
|
-
export type ImportKind = BindingHookResolveIdExtraArgs['kind'];
|
|
24
|
-
export interface CustomPluginOptions {
|
|
25
|
-
[plugin: string]: any;
|
|
26
|
-
}
|
|
27
|
-
export interface ModuleOptions {
|
|
28
|
-
moduleSideEffects: ModuleSideEffects;
|
|
29
|
-
meta: CustomPluginOptions;
|
|
30
|
-
}
|
|
31
|
-
export interface ResolvedId extends ModuleOptions {
|
|
32
|
-
external: boolean;
|
|
33
|
-
id: string;
|
|
34
|
-
}
|
|
35
|
-
export interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
|
|
36
|
-
external?: boolean;
|
|
37
|
-
id: string;
|
|
38
|
-
}
|
|
39
|
-
export interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
40
|
-
code: string;
|
|
41
|
-
map?: SourceMapInput;
|
|
42
|
-
moduleType?: ModuleType;
|
|
43
|
-
}
|
|
44
|
-
interface ResolveIdExtraOptions {
|
|
45
|
-
custom?: CustomPluginOptions;
|
|
46
|
-
isEntry: boolean;
|
|
47
|
-
kind: 'import' | 'dynamic-import' | 'require-call';
|
|
48
|
-
}
|
|
49
|
-
export interface PrivateResolveIdExtraOptions extends ResolveIdExtraOptions {
|
|
50
|
-
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]?: symbol;
|
|
51
|
-
}
|
|
52
|
-
export type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
53
|
-
export type LoadResult = NullValue | string | SourceDescription;
|
|
54
|
-
export type TransformResult = NullValue | string | Partial<SourceDescription>;
|
|
55
|
-
export interface FunctionPluginHooks {
|
|
56
|
-
[DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
|
|
57
|
-
[DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
|
|
58
|
-
[DEFINED_HOOK_NAMES.outputOptions]: (this: null, options: OutputOptions) => NullValue | OutputOptions;
|
|
59
|
-
[DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
|
|
60
|
-
[DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated
|
|
63
|
-
* This hook is only for rollup plugin compatibility. Please use `resolveId` instead.
|
|
64
|
-
*/
|
|
65
|
-
[DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
|
|
66
|
-
[DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
|
|
67
|
-
[DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
|
|
68
|
-
moduleType: ModuleType;
|
|
69
|
-
}) => TransformResult;
|
|
70
|
-
[DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
|
|
71
|
-
[DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
|
|
72
|
-
[DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
|
|
73
|
-
[DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions) => NullValue | string | {
|
|
74
|
-
code: string;
|
|
75
|
-
map?: SourceMapInput;
|
|
76
|
-
};
|
|
77
|
-
[DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
|
|
78
|
-
[DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
|
|
79
|
-
[DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
|
|
80
|
-
[DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
|
|
81
|
-
[DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
|
|
82
|
-
[DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
|
|
83
|
-
event: ChangeEvent;
|
|
84
|
-
}) => void;
|
|
85
|
-
[DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
|
|
86
|
-
}
|
|
87
|
-
export type ChangeEvent = 'create' | 'update' | 'delete';
|
|
88
|
-
export type PluginOrder = 'pre' | 'post' | null;
|
|
89
|
-
export type ObjectHookMeta = {
|
|
90
|
-
order?: PluginOrder;
|
|
91
|
-
};
|
|
92
|
-
export type ObjectHook<T, O = {}> = T | ({
|
|
93
|
-
handler: T;
|
|
94
|
-
} & ObjectHookMeta & O);
|
|
95
|
-
export type SyncPluginHooks = DefinedHookNames['augmentChunkHash' | 'onLog' | 'outputOptions'];
|
|
96
|
-
export type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
|
|
97
|
-
export type FirstPluginHooks = DefinedHookNames['load' | 'resolveDynamicImport' | 'resolveId'];
|
|
98
|
-
export type SequentialPluginHooks = DefinedHookNames['augmentChunkHash' | 'generateBundle' | 'onLog' | 'options' | 'outputOptions' | 'renderChunk' | 'transform'];
|
|
99
|
-
export type AddonHooks = DefinedHookNames['banner' | 'footer' | 'intro' | 'outro'];
|
|
100
|
-
export type OutputPluginHooks = DefinedHookNames['augmentChunkHash' | 'generateBundle' | 'outputOptions' | 'renderChunk' | 'renderError' | 'renderStart' | 'writeBundle'];
|
|
101
|
-
export type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
102
|
-
export type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends 'transform' ? {
|
|
103
|
-
filter?: HookFilter;
|
|
104
|
-
} : K extends 'load' | 'resolveId' ? {
|
|
105
|
-
filter?: Pick<HookFilter, 'id'>;
|
|
106
|
-
} : {};
|
|
107
|
-
export type PluginHooks = {
|
|
108
|
-
[K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K>>;
|
|
109
|
-
};
|
|
110
|
-
export type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
|
|
111
|
-
export type AddonHook = string | AddonHookFunction;
|
|
112
|
-
export interface OutputPlugin extends Partial<{
|
|
113
|
-
[K in OutputPluginHooks]: PluginHooks[K];
|
|
114
|
-
}>, Partial<{
|
|
115
|
-
[K in AddonHooks]: ObjectHook<AddonHook>;
|
|
116
|
-
}> {
|
|
117
|
-
name: string;
|
|
118
|
-
}
|
|
119
|
-
export interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
|
|
120
|
-
api?: A;
|
|
121
|
-
}
|
|
122
|
-
export type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
|
|
123
|
-
export type RolldownPluginOption<A = any> = MaybePromise<NullValue<RolldownPlugin<A>> | false | RolldownPluginOption[]>;
|
|
124
|
-
export type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
|
|
125
|
-
export type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | false | RolldownOutputPluginOption[]>;
|
|
126
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LoggingFunction, LogHandler, LogLevelOption, RollupError } from '../types/misc';
|
|
2
|
-
export interface PluginContextMeta {
|
|
3
|
-
rollupVersion: string;
|
|
4
|
-
rolldownVersion: string;
|
|
5
|
-
watchMode: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare class MinimalPluginContext {
|
|
8
|
-
readonly pluginName: string;
|
|
9
|
-
info: LoggingFunction;
|
|
10
|
-
warn: LoggingFunction;
|
|
11
|
-
debug: LoggingFunction;
|
|
12
|
-
meta: PluginContextMeta;
|
|
13
|
-
constructor(onLog: LogHandler, logLevel: LogLevelOption, pluginName: string);
|
|
14
|
-
error(e: RollupError | string): never;
|
|
15
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN } from '../log/logging';
|
|
2
|
-
import { error, logPluginError } from '../log/logs';
|
|
3
|
-
import { getLogHandler, normalizeLog } from '../log/logHandler';
|
|
4
|
-
import { VERSION } from '..';
|
|
5
|
-
export class MinimalPluginContext {
|
|
6
|
-
pluginName;
|
|
7
|
-
info;
|
|
8
|
-
warn;
|
|
9
|
-
debug;
|
|
10
|
-
meta;
|
|
11
|
-
constructor(onLog, logLevel, pluginName) {
|
|
12
|
-
this.pluginName = pluginName;
|
|
13
|
-
this.debug = getLogHandler(LOG_LEVEL_DEBUG, 'PLUGIN_LOG', onLog, pluginName, logLevel);
|
|
14
|
-
this.info = getLogHandler(LOG_LEVEL_INFO, 'PLUGIN_LOG', onLog, pluginName, logLevel);
|
|
15
|
-
this.warn = getLogHandler(LOG_LEVEL_WARN, 'PLUGIN_WARNING', onLog, pluginName, logLevel);
|
|
16
|
-
this.meta = {
|
|
17
|
-
rollupVersion: '4.23.0',
|
|
18
|
-
rolldownVersion: VERSION,
|
|
19
|
-
watchMode: false,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
error(e) {
|
|
23
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { MaybePromise } from '../types/utils';
|
|
2
|
-
import type { Plugin } from './index';
|
|
3
|
-
export type ParallelPluginImplementation = Plugin;
|
|
4
|
-
export type Context = {
|
|
5
|
-
/**
|
|
6
|
-
* Thread number
|
|
7
|
-
*/
|
|
8
|
-
threadNumber: number;
|
|
9
|
-
};
|
|
10
|
-
export declare function defineParallelPluginImplementation<Options>(plugin: (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>): (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type ParallelPlugin = {
|
|
2
|
-
/** @internal */
|
|
3
|
-
_parallel: {
|
|
4
|
-
fileUrl: string;
|
|
5
|
-
options: unknown;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
|
|
9
|
-
export declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
|