Skip to content

Commit

Permalink
chore: remove unused dts from dist (#8346)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed May 26, 2022
1 parent 86b0a56 commit de9f556
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions packages/vite/rollup.config.ts
Expand Up @@ -86,7 +86,11 @@ const sharedNodeOptions = defineConfig({
}
})

function createNodePlugins(isProduction: boolean, sourceMap = true): Plugin[] {
function createNodePlugins(
isProduction: boolean,
sourceMap: boolean,
declarationDir: string | false
): Plugin[] {
return [
alias({
// packages with "module" field that doesn't play well with cjs bundles
Expand All @@ -105,17 +109,8 @@ function createNodePlugins(isProduction: boolean, sourceMap = true): Plugin[] {
exclude: ['src/**/__tests__/**'],
esModuleInterop: true,
sourceMap,
// in production we use api-extractor for dts generation
// in development we need to rely on the rollup ts plugin
...(isProduction
? {
declaration: false,
sourceMap: false
}
: {
declaration: true,
declarationDir: path.resolve(__dirname, 'dist/node')
})
declaration: declarationDir !== false,
declarationDir: declarationDir !== false ? declarationDir : undefined
}),

// Some deps have try...catch require of optional deps, but rollup will
Expand Down Expand Up @@ -186,7 +181,13 @@ function createNodeConfig(isProduction: boolean) {
...Object.keys(pkg.dependencies),
...(isProduction ? [] : Object.keys(pkg.devDependencies))
],
plugins: createNodePlugins(isProduction)
plugins: createNodePlugins(
isProduction,
false,
// in production we use api-extractor for dts generation
// in development we need to rely on the rollup ts plugin
isProduction ? false : path.resolve(__dirname, 'dist/node')
)
})
}

Expand Down Expand Up @@ -232,7 +233,7 @@ function createCjsConfig(isProduction: boolean) {
...Object.keys(pkg.dependencies),
...(isProduction ? [] : Object.keys(pkg.devDependencies))
],
plugins: [...createNodePlugins(false, false), bundleSizeLimit(55)]
plugins: [...createNodePlugins(false, false, false), bundleSizeLimit(55)]
})
}

Expand Down

0 comments on commit de9f556

Please sign in to comment.