Skip to content

Commit e39b3f6

Browse files
authored
feat(build): Add args and templates to rollup debugger plugin (#5085)
This makes two improvements to the rollup debugging plugin, which allows you to stick a breakpoint into any phase of the build process: - It now collects the arguments passed to the hook function for that phase, so they can be examined in the debugger. - The docstring now includes pre-built copies of the plugin (or, rather, calls to the plugin factory function) for every hook, so you can just copy any that you need over into the helper functions which create the rollup config.
1 parent d9722dc commit e39b3f6

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

rollup/plugins/npmPlugins.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,44 @@ export function makeConstToVarPlugin() {
5050
/**
5151
* Create a plugin which can be used to pause the build process at the given hook.
5252
*
53-
* Hooks can be found here: https://rollupjs.org/guide/en/#build-hooks
53+
* Hooks can be found here: https://rollupjs.org/guide/en/#build-hooks.
5454
*
5555
* @param hookName The name of the hook at which to pause.
5656
* @returns A plugin which inserts a debugger statement in the phase represented by the given hook
57+
*
58+
* For convenience, here are pre-built debuggers for every hook:
59+
*
60+
* makeDebuggerPlugin('buildStart'),
61+
* makeDebuggerPlugin('options'),
62+
* makeDebuggerPlugin('resolveId'),
63+
* makeDebuggerPlugin('resolveDynamicImport'),
64+
* makeDebuggerPlugin('load'),
65+
* makeDebuggerPlugin('transform'),
66+
* makeDebuggerPlugin('shouldTransformCachedModule'),
67+
* makeDebuggerPlugin('moduleParsed'),
68+
* makeDebuggerPlugin('buildEnd'),
69+
* makeDebuggerPlugin('watchChange'),
70+
* makeDebuggerPlugin('closeWatcher'),
71+
* makeDebuggerPlugin('outputOptions'),
72+
* makeDebuggerPlugin('renderStart'),
73+
* makeDebuggerPlugin('banner'),
74+
* makeDebuggerPlugin('footer'),
75+
* makeDebuggerPlugin('intro'),
76+
* makeDebuggerPlugin('outro'),
77+
* makeDebuggerPlugin('augmentChunkHash'),
78+
* makeDebuggerPlugin('renderDynamicImport'),
79+
* makeDebuggerPlugin('resolveFileUrl'),
80+
* makeDebuggerPlugin('resolveImportMeta'),
81+
* makeDebuggerPlugin('renderChunk'),
82+
* makeDebuggerPlugin('renderError'),
83+
* makeDebuggerPlugin('generateBundle'),
84+
* makeDebuggerPlugin('writeBundle'),
85+
* makeDebuggerPlugin('closeBundle'),
5786
*/
5887
export function makeDebuggerPlugin(hookName) {
5988
return {
6089
name: 'debugger-plugin',
61-
[hookName]: () => {
90+
[hookName]: (..._args) => {
6291
// eslint-disable-next-line no-debugger
6392
debugger;
6493
return null;

0 commit comments

Comments
 (0)