renderChunk(code, chunk, opts) {
							if (opts.format === 'umd') {
								// Can swap this out with MagicString.replace() when we bump it:
								// https://github.com/developit/microbundle/blob/f815a01cb63d90b9f847a4dcad2a64e6b2f8596f/src/index.js#L657-L671
								const s = new MagicString(code);

								const minified = code.match(
									/([a-zA-Z$_]+)="undefined"!=typeof globalThis\?globalThis:(\1\|\|self)/,
								);
								if (minified) {
									s.overwrite(
										minified.index,
										minified.index + minified[0].length,
										minified[2],
									);
								}

								const unminified = code.match(
									/(global *= *)typeof +globalThis *!== *['"]undefined['"] *\? *globalThis *: *(global *\|\| *self)/,
								);
								if (unminified) {
									s.overwrite(
										unminified.index,
										unminified.index + unminified[0].length,
										unminified[1] + unminified[2],
									);
								}

								return {
									code: s.toString(),
									map: s.generateMap({ hires: true }),
								};
							}
						}
',
							plugins: [
								[
									require.resolve('babel-plugin-transform-replace-expressions'),
									{ replace: defines },
								],
							],
						}),
					customBabel()({
						babelHelpers: 'bundled',
						extensions: EXTENSIONS,
						// use a regex to make sure to exclude eventual hoisted packages
						exclude: /\/node_modules\//,
						passPerPreset: true, // @see https://babeljs.io/docs/en/options#passperpreset
						custom: {
							defines,
							modern,
							compress: options.compress !== false,
							targets: options.target === 'node' ? { node: '12' } : undefined,
							pragma: options.jsx,
							pragmaFrag: options.jsxFragment,
							typescript: !!useTypescript,
							jsxImportSource: options.jsxImportSource || false,
						},
					}),
					options.compress !== false && [
						terser({
							compress: Object.assign(
								{
									keep_infinity: true,
									pure_getters: true,
									// Ideally we'd just get Terser to respect existing Arrow functions...
									// unsafe_arrows: true,
									passes: 10,
								},
								typeof minifyOptions.compress === 'boolean'
									? minifyOptions.compress
									: minifyOptions.compress || {},
							),
							format: {
								// By default, Terser wraps function arguments in extra parens to trigger eager parsing.
								// Whether this is a good idea is way too specific to guess, so we optimize for size by default:
								wrap_func_args: false,
								comments: /^\s*([@#]__[A-Z]+__\s*$|@cc_on)/,
								preserve_annotations: true,
							},
							module: modern,
							ecma: modern ? 2017 : 5,
							toplevel: modern || format === 'cjs' || format === 'es',
							mangle:
								typeof minifyOptions.mangle === 'boolean'
									? minifyOptions.mangle
									: Object.assign({}, minifyOptions.mangle || {}),
							nameCache,
						}),
						nameCache && {
							// before hook
							options: loadNameCache,
							// after hook
							writeBundle() {
								if (writeMeta && nameCache) {
									let filename = getNameCachePath();
									let json = JSON.stringify(
										nameCache,
										null,
										nameCacheIndentTabs ? '\t' : 2,
									);
									if (endsWithNewLine) json += EOL;
									fs.writeFile(filename, json, () => {});
								}
							},
						},
					],
					options.visualize && visualizer(),
					// NOTE: OMT only works with amd and esm
					// Source: https://github.com/surma/rollup-plugin-off-main-thread#config
					useWorkerLoader && (format === 'es' || modern) && OMT(),
					/** @type {import('rollup').Plugin}