Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[webpack] Upgrade to Webpack 5 #3763

Merged
merged 75 commits into from
Jan 27, 2023
Merged

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Aug 12, 2021

Why

CRA (the base config) has just merged support for Webpack v5 (facebook/create-react-app#11201), meaning we can start upgrading.

How

  • Upgraded packages in expo/webpack-config and xdl to webpack v5.
  • Upgraded plugins to use new syntax.
  • Upgraded config and dev server schema.
  • Removed unused features.

Prerequisites

I added a few features that should be split out and merged separately:

Test Plan

  • expo start -w
  • expo start:web
    • Error overlay should show and work (currently doesn't, seems related to CRA) -- Pending V5 fix react error overlay build facebook/create-react-app#11799 Never merged.
    • Babel caching should work
    • Font loading and expo/vector-icons should work
    • Video and image loading / importing like metro (interop) Moved to Metro for web.
    • NCL should bundle
    • Debug logging should work
    • Auto resize observer adding
    • HTML loading
    • Eslint
    • TypeScript
    • AVIF support
    • Packages with CSS
  • expo build:web
    • EXPO_WEB_DEBUG web debugging optimizations
    • WEB_HOST, WEB_PORT
    • No icons should warn
    • PWA Asset generation
    • PWA overrides

@EvanBacon EvanBacon changed the title [webpack config] Upgrade to Webpack 5 [webpack] Upgrade to Webpack 5 Aug 12, 2021
@kilbot
Copy link

kilbot commented Jul 27, 2022

Just curious if webpack5 is still on the timeline. I know there have been some changes recently and maybe @EvanBacon is looking at using Metro as a single bundler for native and web?

I am seeing some weirdness using SDK 46 and webpack4 devServer, ie:

ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'mimeTypes'. These properties are valid:
   object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }

UPDATE:
The problem wasn't due to SDK 46, it was a resolution issue in my monorepo, I needed to pin webpack-dev-server to 3.11.0.

But this is still an issue. Expo is the only thing holding me back from using the new features of webpack5 elsewhere in my monorepo.

@matallui
Copy link

matallui commented Nov 3, 2022

Is this still in the plans?

@joshuapare
Copy link

@EvanBacon I managed to fix the remaining items on this branch, with the only final issue being the instanceof check not passing in Webpack core when it's being passed the DevServer instance. Commenting out the check in Webpack core fixes the issue and linking the local build of the expo-cli, and I can run the expo app across all targets (I'm not sure why it doesn't pass, considering the constructor name and object shape are identical, and I can see the constructor in the passed object).

We would love to be able to get Module Federation working in Expo for the mobile builds (I got it working for the web build, but mobile builds are failing - I am digging). If there's anything I can do to help, please let me know - would love to see Webpack 5 (and specifically Module Federation) hit Expo!

@EvanBacon EvanBacon force-pushed the @evanbacon/webpack-config/webpack-5 branch from 7ab953e to 8cc4764 Compare January 26, 2023 21:02
Update ManifestHandler.ts

Update .eslintrc.js

Update parseStartOptions.ts

fix types

Update yarn.lock

Delete more unused code and fix types

fix types

drop unimodules helper (no longer used in Next.js adapter)

update tests

drop more native support

wip -- drop native

update deps

Update basic-test.js

updated tests

Update startAsync.ts

drop / revert

Update package.json
@EvanBacon EvanBacon force-pushed the @evanbacon/webpack-config/webpack-5 branch from 69bf55c to 6e9469d Compare January 26, 2023 21:47
@EvanBacon EvanBacon marked this pull request as ready for review January 26, 2023 22:12
@EvanBacon
Copy link
Contributor Author

@sbhrule15 I'll be dropping the experimental native support in Webpack because I've been running into a lot of issues (mostly memory related) which I can't seem to track down.

Webpack support in Expo will be sunset later this year in favor of universal Metro (sometime after we add a number of critical features like bundle splitting). Repack should still be capable of running in Expo, iirc the team is also focused on module federation support.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants