Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webpack): remove support for legacy browsers (#14190) #14257

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Jan 10, 2023

This PR is a preparatory refactoring / cleanup of the webpack setup.

Previously, the config is overly convoluted, where common vs web vs node concerns were mixed, and multiple options were configured then reconfigured or deleted later on.

The main change is to provide two new Nx plugins for webpack:

  • withNx - Adds base webpack configuration for things like tsconfig paths, tsc/babel/swc, and type checking.
  • withWeb - Adds web-only concerns, such as stylesheets, images, etc.

There is also a composePlugins function from @nrwl/webpack that helps combine more than one configuration together. All three functions need to be documented later.

Note: Behaviorally there is no change from current stable release. Both build, serve, storybook, componen-test targets should work exactly as they do currently.

What's Next

In a follow-up PR, the plugins will be manually be configured for Node, Web, and React plugins inside webpack.config.ts.

// node
const { withNx } = require('@nrwl/webpack');
module.exports = withNx();

// web
const { composePlugins, withNx, withWeb } = require('@nrwl/webpack');
module.exports = composePlugins(withNx(), withWeb());

// react
const { composePlugins } = require('@nrwl/webpack');
const { withReact } = require('@nrwl/react');
module.exports = composePlugins(withNx(), withReact());

React-only and Web-only options can be deprecated from the @nrwl/webpack:webpack executor and be options on either withWeb or withReact plugins. We may also want to update Module Federation support to compose MF with React as follows:

const { composePlugins } = require('@nrwl/webpack');
const { withReact, withModuleFederation } = require('@nrwl/react');
module.exports = composePlugins(withNx(), withReact(), withModuleFederation({...}));

We can also cleanup Cypress and Storybook integration by invoking the correct plugin (through webpack.config.ts), and not have to rely on the current workarounds.

@vercel
Copy link

vercel bot commented Jan 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
nx-dev ⬜️ Ignored (Inspect) Jan 11, 2023 at 5:03AM (UTC)

@jaysoo jaysoo force-pushed the feat/webpack-cleanup branch from b6ebc1c to 5b69c18 Compare January 10, 2023 18:48
@jaysoo jaysoo force-pushed the feat/webpack-cleanup branch 4 times, most recently from fd478b0 to e8a6c38 Compare January 10, 2023 20:02
@jaysoo jaysoo requested a review from mandarini January 10, 2023 20:03
@jaysoo jaysoo force-pushed the feat/webpack-cleanup branch 11 times, most recently from 01e2487 to e165198 Compare January 11, 2023 04:29
@jaysoo jaysoo force-pushed the feat/webpack-cleanup branch from e165198 to 5f47804 Compare January 11, 2023 05:03
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants