Skip to content

Commit

Permalink
fix(node): webpack executor doesn't respect option outputFileName (#9740
Browse files Browse the repository at this point in the history
)

Co-authored-by: zhaoyunfeng <zhaoyunfeng@worktile.com>
  • Loading branch information
zyf0330 and zyf0330 committed Apr 8, 2022
1 parent 5b105b1 commit 0e68c61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/node/src/executors/webpack/webpack.impl.spec.ts
Expand Up @@ -72,6 +72,9 @@ describe('Node Build Executor', () => {

expect(runWebpack).toHaveBeenCalledWith(
expect.objectContaining({
entry: expect.objectContaining({
index: ['/root/apps/wibble/src/main.ts'],
}),
output: expect.objectContaining({
filename: 'index.js',
libraryTarget: 'commonjs',
Expand Down
6 changes: 5 additions & 1 deletion packages/node/src/utils/config.ts
Expand Up @@ -8,6 +8,7 @@ import { loadTsTransformers } from './load-ts-transformers';
import { BuildBuilderOptions } from './types';
import CopyWebpackPlugin = require('copy-webpack-plugin');
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
import { removeExt } from '@nrwl/workspace/src/utils/runtime-lint-utils';

export const OUT_FILENAME_TEMPLATE = '[name].js';

Expand All @@ -33,9 +34,12 @@ export function getBaseWebpackPartial(
}),
{} as { [entryName: string]: string }
) ?? {};
const mainEntry = options.outputFileName
? removeExt(options.outputFileName)
: 'main';
const webpackConfig: Configuration = {
entry: {
main: [options.main],
[mainEntry]: [options.main],
...additionalEntryPoints,
},
devtool: options.sourceMap ? 'source-map' : false,
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/utils/runtime-lint-utils.ts
Expand Up @@ -76,7 +76,7 @@ function hasTag(proj: ProjectGraphProjectNode, tag: string) {
return tag === '*' || (proj.data.tags || []).indexOf(tag) > -1;
}

function removeExt(file: string): string {
export function removeExt(file: string): string {
return file.replace(/(?<!(^|\/))\.[^/.]+$/, '');
}

Expand Down

0 comments on commit 0e68c61

Please sign in to comment.