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: do not bundle type definitions for packages which have only one .d.ts file #12718

Merged
merged 1 commit into from
Apr 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions scripts/bundleTs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ const copyrightSnippet = `
(async () => {
const packages = getPackages();

const packagesWithTs = packages.filter(p =>
fs.existsSync(path.resolve(p.packageDir, 'tsconfig.json')),
const isTsPackage = p =>
fs.existsSync(path.resolve(p.packageDir, 'tsconfig.json'));

const hasMoreThanOneDefinitionFile = p =>
fs
.readdirSync(path.resolve(p.packageDir, 'build'))
.filter(f => f.endsWith('.d.ts')).length > 1;

const packagesToBundle = packages.filter(
p => isTsPackage(p) && hasMoreThanOneDefinitionFile(p),
);

const typesNodeReferenceDirective = '/// <reference types="node" />';
Expand Down Expand Up @@ -115,7 +123,7 @@ const copyrightSnippet = `
let compilerState;

await Promise.all(
packagesWithTs.map(async ({packageDir, pkg}) => {
packagesToBundle.map(async ({packageDir, pkg}) => {
const configFile = path.resolve(packageDir, 'api-extractor.json');

await fs.promises.writeFile(
Expand All @@ -134,7 +142,7 @@ const copyrightSnippet = `

if (!compilerState) {
compilerState = CompilerState.create(extractorConfig, {
additionalEntryPoints: packagesWithTs.map(({pkg, packageDir}) =>
additionalEntryPoints: packagesToBundle.map(({pkg, packageDir}) =>
path.resolve(packageDir, pkg.types),
),
typescriptCompilerFolder,
Expand Down