Skip to content

Commit

Permalink
feat!: update rollup to v3 (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 13, 2022
1 parent 813cdb6 commit da197ec
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 86 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -28,11 +28,11 @@
"unbuild": "jiti ./src/cli"
},
"dependencies": {
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-alias": "^4.0.0",
"@rollup/plugin-commonjs": "^23.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-json": "^5.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-replace": "^5.0.0",
"@rollup/pluginutils": "^5.0.1",
"chalk": "^5.1.2",
"consola": "^2.15.3",
Expand All @@ -50,7 +50,7 @@
"pkg-types": "^0.3.5",
"pretty-bytes": "^6.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.79.1",
"rollup": "^3.1.0",
"rollup-plugin-dts": "^4.2.3",
"rollup-plugin-esbuild": "^4.10.1",
"scule": "^0.3.2",
Expand All @@ -61,7 +61,7 @@
"@nuxtjs/eslint-config-typescript": "^11.0.0",
"@types/mkdirp": "^1.0.2",
"@types/mri": "^1.1.1",
"@types/node": "^18.7.14",
"@types/node": "^18.8.5",
"@types/rimraf": "^3.0.2",
"@vitest/coverage-c8": "^0.24.1",
"changelogen": "^0.3.2",
Expand Down
139 changes: 62 additions & 77 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions src/builder/rollup.ts
Expand Up @@ -116,7 +116,20 @@ export async function rollupBuild (ctx: BuildContext) {
// TODO: Use fresh rollup options
const shebangPlugin: any = rollupOptions.plugins.find(p => p && p.name === 'unbuild-shebang')
shebangPlugin._options.preserve = false
rollupOptions.plugins.push(dts(ctx.options.rollup.dts))

// TODO: https://github.com/Swatinem/rollup-plugin-dts/issues/226
const dtsPlugin = dts(ctx.options.rollup.dts)
rollupOptions.plugins.push({
...dtsPlugin,
outputOptions (...args) {
const opts = dtsPlugin.outputOptions(...args)
opts.interop = 'esModule'
delete opts.namespaceToStringTag
opts.generatedCode = { symbols: false, ...opts.generatedCode }
return opts
}
})

await ctx.hooks.callHook('rollup:dts:options', ctx, rollupOptions)
const typesBuild = await rollup(rollupOptions)
await ctx.hooks.callHook('rollup:dts:build', ctx, typesBuild)
Expand All @@ -138,7 +151,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
return `shared/${ctx.options.name}.[hash].${ext}`
}

return {
return <RollupOptions>{
input: Object.fromEntries(ctx.options.entries
.filter(entry => entry.builder === 'rollup')
.map(entry => [entry.name, resolve(ctx.options.rootDir, entry.input)])
Expand All @@ -151,7 +164,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
chunkFileNames: (chunk: PreRenderedChunk) => getChunkFilename(chunk, 'cjs'),
format: 'cjs',
exports: 'auto',
preferConst: true,
generatedCode: { constBindings: true },
externalLiveBindings: false,
freeze: false
},
Expand All @@ -161,7 +174,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
chunkFileNames: (chunk: PreRenderedChunk) => getChunkFilename(chunk, 'mjs'),
format: 'esm',
exports: 'auto',
preferConst: true,
generatedCode: { constBindings: true },
externalLiveBindings: false,
freeze: false
}
Expand Down

0 comments on commit da197ec

Please sign in to comment.