Skip to content

Commit

Permalink
fix(js): remove thirdParty default so that package.json will be gener…
Browse files Browse the repository at this point in the history
…ated by default (#16015)
  • Loading branch information
ndcunningham authored Apr 4, 2023
1 parent 3636756 commit c02ec9f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docs/generated/packages/esbuild/executors/esbuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@
},
"thirdParty": {
"type": "boolean",
"description": "Includes third-party packages in the bundle (i.e. npm packages).",
"default": true
"description": "Includes third-party packages in the bundle (i.e. npm packages)."
},
"dependenciesFieldType": {
"type": "string",
Expand Down
22 changes: 22 additions & 0 deletions packages/esbuild/src/executors/esbuild/lib/normalize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('normalizeOptions', () => {
outputFileName: 'index.js',
singleEntry: true,
external: [],
thirdParty: false,
});
});

Expand All @@ -69,6 +70,7 @@ describe('normalizeOptions', () => {
additionalEntryPoints: ['apps/myapp/src/extra-entry.ts'],
singleEntry: false,
external: [],
thirdParty: false,
});
});

Expand All @@ -94,6 +96,7 @@ describe('normalizeOptions', () => {
outputFileName: 'test.js',
singleEntry: true,
external: [],
thirdParty: false,
});
});

Expand All @@ -108,6 +111,7 @@ describe('normalizeOptions', () => {
generatePackageJson: true,
additionalEntryPoints: ['apps/myapp/src/extra-entry.ts'],
outputFileName: 'test.js',
thirdParty: false,
},
context
)
Expand Down Expand Up @@ -135,6 +139,24 @@ describe('normalizeOptions', () => {
outputFileName: 'index.js',
singleEntry: true,
external: [],
thirdParty: false,
});
});

it('should override thirdParty if bundle:false', () => {
expect(
normalizeOptions(
{
main: 'apps/myapp/src/index.ts',
outputPath: 'dist/apps/myapp',
tsConfig: 'apps/myapp/tsconfig.app.json',
generatePackageJson: true,
bundle: false,
thirdParty: true,
assets: [],
},
context
)
).toEqual(expect.objectContaining({ thirdParty: false }));
});
});
20 changes: 19 additions & 1 deletion packages/esbuild/src/executors/esbuild/lib/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
EsBuildExecutorOptions,
NormalizedEsBuildExecutorOptions,
} from '../schema';
import { ExecutorContext, joinPathFragments } from '@nrwl/devkit';
import { ExecutorContext, joinPathFragments, logger } from '@nrwl/devkit';
import chalk = require('chalk');

export function normalizeOptions(
options: EsBuildExecutorOptions,
Expand All @@ -20,6 +21,21 @@ export function normalizeOptions(
),
];

if (!options.bundle && options.thirdParty) {
logger.info(
chalk.yellow(
`Your build has conflicting options, ${chalk.bold(
'bundle:false'
)} and ${chalk.bold(
'thirdParty:true'
)}. Your package.json depedencies might not be generated correctly so we added an update ${chalk.bold(
'thirdParty:false'
)}`
)
);
}

const thirdParty = !options.bundle ? false : options.thirdParty;
if (options.additionalEntryPoints?.length > 0) {
const { outputFileName, ...rest } = options;
if (outputFileName) {
Expand All @@ -29,6 +45,7 @@ export function normalizeOptions(
}
return {
...rest,
thirdParty,
assets,
external: options.external ?? [],
singleEntry: false,
Expand All @@ -40,6 +57,7 @@ export function normalizeOptions(
} else {
return {
...options,
thirdParty,
assets,
external: options.external ?? [],
singleEntry: true,
Expand Down
3 changes: 1 addition & 2 deletions packages/esbuild/src/executors/esbuild/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@
},
"thirdParty": {
"type": "boolean",
"description": "Includes third-party packages in the bundle (i.e. npm packages).",
"default": true
"description": "Includes third-party packages in the bundle (i.e. npm packages)."
},
"dependenciesFieldType": {
"type": "string",
Expand Down

1 comment on commit c02ec9f

@vercel
Copy link

@vercel vercel bot commented on c02ec9f Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.