Skip to content

Commit

Permalink
Fix packageConfigs defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Nov 6, 2021
1 parent a695127 commit 0ecbd1c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-planets-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'bob-esbuild': patch
---

Fix packageConfigs defaults
8 changes: 3 additions & 5 deletions packages/bob/src/config/rollup.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { bobEsbuildPlugin } from 'bob-esbuild-plugin';
import path from 'path';
import type { InputOptions, OutputOptions, Plugin, RollupBuild } from 'rollup';
import del from 'rollup-plugin-delete';
import externals from 'rollup-plugin-node-externals';

import { debug } from '../log/debug';
import { cleanObject } from '../utils/object';
import { copyToDist } from './copyToDist';
import { globalConfig } from './cosmiconfig';
import { GetPackageBuildConfig } from './packageBuildConfig';
import { generatePackageJson } from './packageJson';
import { rollupBin } from './rollupBin';

import type { RollupBuild } from 'rollup';
import type { OutputOptions, InputOptions, Plugin } from 'rollup';

export interface ConfigOptions {
/**
* @default process.cwd()
Expand Down Expand Up @@ -53,7 +51,7 @@ export async function getRollupConfig(optionsArg: ConfigOptions = {}) {

const [buildConfig, { config: globalOptions }] = await Promise.all([GetPackageBuildConfig(cwd), globalConfig]);

const options = { ...globalOptions.packageConfigs?.[buildConfig.pkg.name], ...optionsArg };
const options = { ...globalOptions.packageConfigs?.[buildConfig.pkg.name], ...cleanObject(optionsArg) };

const clean = options.clean ?? globalOptions.clean;

Expand Down
5 changes: 5 additions & 0 deletions packages/bob/src/utils/object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function cleanObject<T extends object>(obj: Partial<T> = {}): Partial<T> {
const clean = { ...obj };
for (const key in clean) clean[key] === undefined && delete clean[key];
return clean;
}

0 comments on commit 0ecbd1c

Please sign in to comment.