Skip to content

Instantly share code, notes, and snippets.

@huozhi
Last active May 26, 2025 07:44
Show Gist options
  • Save huozhi/9258c1c787c52ba00949c77f3a2d19b3 to your computer and use it in GitHub Desktop.
Save huozhi/9258c1c787c52ba00949c77f3a2d19b3 to your computer and use it in GitHub Desktop.
map rollup config to rolldown config
// rolldown version: 1.0.0-beta.9
//
// Error output example:
// ⨯ Error: Failed validate input options.
// - For the "input.external". Invalid type: Expected string but received Function.
// at validateOption (.../node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-DUvB0HDu.cjs:2116:28)
// at rolldown (.../node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-DUvB0HDu.cjs:4298:2)
// at build (.../node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/src-DUvB0HDu.cjs:4309:25)
// Issue: input.external is not supported
const external = rollupConfig.input.external
rollupConfig.input.external = undefined
// @ts-ignore migrate external
rollupConfig.external = external
delete rollupConfig.input.external
// Issue: input.plugins is not supported
const plugins = rollupConfig.input.plugins
// delete rollupConfig.input.plugins
rollupConfig.input.plugins = undefined
// @ts-ignore migrate plugins
rollupConfig.plugins = plugins
delete rollupConfig.input.plugins
// Issue: input.onwarn is not supported
const onwarn = rollupConfig.input.onwarn
rollupConfig.input.onwarn = undefined
// @ts-ignore migrate onwarn
rollupConfig.onwarn = onwarn
delete rollupConfig.input.onwarn
// Issue: config.input needs to be string
// @ts-ignore migrate input
rollupConfig.input = rollupConfig.input.input.replace(process.cwd() + path.sep, '')
// Issue: those configs are not supported
// migrate output
delete rollupConfig.output.manualChunks
delete rollupConfig.output.interop
delete rollupConfig.output.freeze
delete rollupConfig.output.strict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment