Skip to content

Commit

Permalink
fix(node): add default build configuration (#15542)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo authored Mar 8, 2023
1 parent f7367ff commit a69f8ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
1 change: 0 additions & 1 deletion e2e/node/src/node-esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('Node Applications + esbuild', () => {
await runCLIAsync(`build ${app}`);

checkFilesExist(`dist/apps/${app}/main.js`);
checkFilesExist(`dist/apps/${app}/main.js.map`);
const result = execSync(`node dist/apps/${app}/main.js`, {
cwd: tmpProjPath(),
}).toString();
Expand Down
12 changes: 7 additions & 5 deletions packages/node/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('app', () => {
build: {
executor: '@nrwl/webpack:webpack',
outputs: ['{options.outputPath}'],
defaultConfiguration: 'production',
options: {
target: 'node',
compiler: 'tsc',
Expand All @@ -60,19 +61,20 @@ describe('app', () => {
assets: ['my-node-app/src/assets'],
},
configurations: {
production: {
optimization: true,
extractLicenses: true,
inspect: false,
},
development: {},
production: {},
},
},
serve: {
executor: '@nrwl/js:node',
defaultConfiguration: 'development',
options: {
buildTarget: 'my-node-app:build',
},
configurations: {
development: {
buildTarget: 'my-node-app:build:development',
},
production: {
buildTarget: 'my-node-app:build:production',
},
Expand Down
17 changes: 13 additions & 4 deletions packages/node/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function getWebpackBuildConfig(
return {
executor: `@nrwl/webpack:webpack`,
outputs: ['{options.outputPath}'],
defaultConfiguration: 'production',
options: {
target: 'node',
compiler: 'tsc',
Expand All @@ -78,11 +79,9 @@ function getWebpackBuildConfig(
),
},
configurations: {
development: {},
production: {
...(options.docker && { generateLockfile: true }),
optimization: true,
extractLicenses: true,
inspect: false,
},
},
};
Expand All @@ -95,6 +94,7 @@ function getEsBuildConfig(
return {
executor: '@nrwl/esbuild:esbuild',
outputs: ['{options.outputPath}'],
defaultConfiguration: 'production',
options: {
platform: 'node',
outputPath: joinPathFragments(
Expand All @@ -117,9 +117,14 @@ function getEsBuildConfig(
},
},
configurations: {
development: {},
production: {
...(options.docker && { generateLockfile: true }),
esbuildOptions: { sourcemap: false },
esbuildOptions: {
sourcemap: false,
// Generate CJS files as .js so imports can be './foo' rather than './foo.cjs'.
outExtension: { '.js': '.js' },
},
},
},
};
Expand All @@ -128,10 +133,14 @@ function getEsBuildConfig(
function getServeConfig(options: NormalizedSchema): TargetConfiguration {
return {
executor: '@nrwl/js:node',
defaultConfiguration: 'development',
options: {
buildTarget: `${options.name}:build`,
},
configurations: {
development: {
buildTarget: `${options.name}:build:development`,
},
production: {
buildTarget: `${options.name}:build:production`,
},
Expand Down

0 comments on commit a69f8ab

Please sign in to comment.