Skip to content

Commit

Permalink
fix(vite-node): build spliting chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 18, 2022
1 parent bb77e4f commit b04dd8f
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions packages/vite-node/rollup.config.js
Expand Up @@ -6,13 +6,14 @@ import json from '@rollup/plugin-json'
import alias from '@rollup/plugin-alias'
import pkg from './package.json'

const entries = [
'src/index.ts',
'src/server.ts',
'src/client.ts',
'src/utils.ts',
'src/cli.ts',
]
const entries = {
index: 'src/index.ts',
server: 'src/server.ts',
types: 'src/types.ts',
client: 'src/client.ts',
utils: 'src/utils.ts',
cli: 'src/cli.ts',
}

const external = [
...Object.keys(pkg.dependencies || {}),
Expand All @@ -38,30 +39,38 @@ const plugins = [
]

export default () => [
...entries.map(input => ({
input,
output: [
{
file: input.replace('src/', 'dist/').replace('.ts', '.js'),
format: 'esm',
},
{
file: input.replace('src/', 'dist/').replace('.ts', '.cjs'),
format: 'cjs',
},
],
{
input: entries,
output: {
dir: 'dist',
format: 'esm',
sourcemap: 'inline',
entryFileNames: '[name].js',
},
external,
plugins,
},
{
input: entries,
output: {
dir: 'dist',
format: 'cjs',
sourcemap: 'inline',
entryFileNames: '[name].cjs',
},
external,
plugins,
})),
...entries.map(input => ({
input,
},
{
input: entries,
output: {
file: input.replace('src/', '').replace('.ts', '.d.ts'),
dir: process.cwd(),
entryFileNames: '[name].d.ts',
format: 'esm',
},
external,
plugins: [
dts({ respectExternal: true }),
],
})),
},
]

0 comments on commit b04dd8f

Please sign in to comment.