Skip to content

Commit

Permalink
fix(webpack): support webworker (#17136) (#17137)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Sagan - Yieldbroker <[email protected]>
  • Loading branch information
MaximSagan and Max Sagan - Yieldbroker authored May 31, 2023
1 parent 21f642a commit 8251906
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/generated/packages/webpack/executors/webpack.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"type": "string",
"alias": "platform",
"description": "Target platform for the build, same as the Webpack target option.",
"enum": ["node", "web"],
"enum": ["node", "web", "webworker"],
"default": "web"
},
"deleteOutputPath": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"target": {
"type": "string",
"description": "Target platform for the build, same as the Webpack config option.",
"enum": ["node", "web"],
"enum": ["node", "web", "webworker"],
"default": "web"
},
"skipFormat": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function getWebpackConfig(
): Configuration {
const config: Configuration = {};
const configure =
options.target === 'node'
? withNx()
: composePluginsSync(withNx(), withWeb());
options.target === 'web'
? composePluginsSync(withNx(), withWeb())
: withNx();
return configure(config, { options, context });
}
2 changes: 1 addition & 1 deletion packages/webpack/src/executors/webpack/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface WebpackExecutorOptions {
runtimeChunk?: boolean;
sourceMap?: boolean | 'hidden';
statsJson?: boolean;
target?: 'node' | 'web';
target?: 'node' | 'web' | 'webworker';
transformers?: TransformerEntry[];
tsConfig: string;
vendorChunk?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/src/executors/webpack/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"type": "string",
"alias": "platform",
"description": "Target platform for the build, same as the Webpack target option.",
"enum": ["node", "web"],
"enum": ["node", "web", "webworker"],
"default": "web"
},
"deleteOutputPath": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface WebpackProjectGeneratorSchema {
skipFormat?: boolean;
skipPackageJson?: boolean;
skipValidation?: boolean;
target?: 'node' | 'web';
target?: 'node' | 'web' | 'webworker';
webpackConfig?: string;
babelConfig?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"target": {
"type": "string",
"description": "Target platform for the build, same as the Webpack config option.",
"enum": ["node", "web"],
"enum": ["node", "web", "webworker"],
"default": "web"
},
"skipFormat": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ function addBuildTarget(tree: Tree, options: WebpackProjectGeneratorSchema) {
buildOptions.babelUpwardRootMode = true;
}

if (options.target === 'node') {
if (options.target === 'web') {
tree.write(
joinPathFragments(project.root, 'webpack.config.js'),
`
const { composePlugins, withNx } = require('@nx/webpack');
const { composePlugins, withNx, withWeb } = require('@nx/webpack');
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
module.exports = composePlugins(withNx(), withWeb(), (config) => {
// Update the webpack config as needed here.
// e.g. \`config.plugins.push(new MyPlugin())\`
return config;
Expand All @@ -93,10 +93,10 @@ module.exports = composePlugins(withNx(), (config) => {
tree.write(
joinPathFragments(project.root, 'webpack.config.js'),
`
const { composePlugins, withNx, withWeb } = require('@nx/webpack');
const { composePlugins, withNx } = require('@nx/webpack');
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), withWeb(), (config) => {
module.exports = composePlugins(withNx(), (config) => {
// Update the webpack config as needed here.
// e.g. \`config.plugins.push(new MyPlugin())\`
return config;
Expand Down

1 comment on commit 8251906

@vercel
Copy link

@vercel vercel bot commented on 8251906 May 31, 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-nrwl.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app

Please sign in to comment.