Skip to content

Commit

Permalink
skipValidate
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Nov 6, 2021
1 parent 0ecbd1c commit afd2edb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/brave-mugs-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'bob-esbuild': patch
'bob-esbuild-cli': patch
---

add skipValidate option
4 changes: 3 additions & 1 deletion packages/bob-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const BuildCommand = new Command('build')
.option('--skipTsc', 'Skip TSC build')
.option('--onlyCJS', 'Only build for CJS')
.option('--onlyESM', 'Only build for ESM')
.action(async ({ cwd, inputFiles, bundle, clean, onlyCJS, onlyESM, skipTsc }) => {
.option('--skipValidate', 'Skip package.json validation')
.action(async ({ cwd, inputFiles, bundle, clean, onlyCJS, onlyESM, skipTsc, skipValidate }) => {
await startBuild({
rollup: {
cwd,
Expand All @@ -20,6 +21,7 @@ export const BuildCommand = new Command('build')
clean,
onlyCJS,
onlyESM,
skipValidate,
},
tsc: skipTsc ? false : {},
});
Expand Down
3 changes: 2 additions & 1 deletion packages/bob/src/config/packageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export interface GeneratePackageJsonOptions {
packageJson: PackageJSON;
distDir: string;
cwd?: string;
skipValidate?: boolean;
}

export const generatePackageJson = (options: GeneratePackageJsonOptions, config: ResolvedBobConfig): Plugin | null => {
Expand Down Expand Up @@ -193,7 +194,7 @@ export const generatePackageJson = (options: GeneratePackageJsonOptions, config:
return {
name: 'GeneratePackageJson',
async buildStart() {
if (!manualRewrite) validatePackageJson(options.packageJson, options.distDir);
if (!manualRewrite && !options.skipValidate) validatePackageJson(options.packageJson, options.distDir);

this[GenPackageJson] = Promise.allSettled([
writePackageJson(manualRewrite ? { ...options, packageJson: await manualRewrite(options.packageJson) } : options),
Expand Down
12 changes: 11 additions & 1 deletion packages/bob/src/config/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export interface ConfigOptions {
* @default false
*/
onlyESM?: boolean;

/**
* Skip package.json validate
*
* @default false
*/
skipValidate?: boolean;
}

export async function getRollupConfig(optionsArg: ConfigOptions = {}) {
Expand Down Expand Up @@ -114,7 +121,10 @@ export async function getRollupConfig(optionsArg: ConfigOptions = {}) {

if (buildConfig.copy?.length) debug(`Copying ${buildConfig.copy.join(' | ')} to ${absoluteDistDir}`);

const genPackageJson = generatePackageJson({ packageJson: buildConfig.pkg, distDir, cwd }, globalOptions);
const genPackageJson = generatePackageJson(
{ packageJson: buildConfig.pkg, distDir, cwd, skipValidate: options.skipValidate },
globalOptions
);

const plugins: Plugin[] = [
externals({
Expand Down

0 comments on commit afd2edb

Please sign in to comment.