Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused dts from dist #8346

Merged
merged 1 commit into from May 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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