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

Support NextJS 11  #3579

@marklawlor

Description

@marklawlor
Original issue

@expo/next-adapter only supports NextJS 9.x. which is now two major versions behind. The Next adapter is broken for two reasons

I'm creating this issue to discuss just updating just @expo/next-adapter (not Expo web) to the latest NextJS version with webpack 5 support.

Here is a working proof of concept https://github.com/marklawlor/expo-nextjs-webpack-5.

@EvanBacon Whats the best way to PR these patches without breaking Expo web?

In #2881 you indicated that you wished to wait for Create React App to update, but @expo/next-adapter only uses the withUnimodules addon which requires minimal changes which could be added in a non-breaking manner behind flags.

PRs

Known issues / workarounds

My app doesn't compile when enabling webpack5

Note: If your app doesn't not compile under webpack 4 then you have a different issue

The Expo's babel loader automatically transpiles some dependencies, however there seems to be some edge cases where it doesn't work under webpack5.

The workaround is to explicitly list these modules via next-transpile-modules. See this comment for more info #3579 (comment)

My app doesn't compile under webpack 4 or 5, but previously worked

Check your console output, you probably have an error complaining about es6 syntax, maybe a message like SyntaxError: ./node_modules/<modules>/<path>.js: Missing class properties transform.

NextJS have updated their compile targets and removed some babel transforms that were previously needed for react-native modules. You will need to add these as babel overrides in your babel.config.js #3579 (comment)

My monorepo doesn't compile

See this comment #3579 (comment)

My expo app has a JSX transform error

NextJS 11 w/ React 17 uses the new JSX transform. You should enable useTransformReactJsxExperimental for all platforms.

"React.createElement is not a function"

The JSX transform does not require you to import React, so it may have been removed from a shared component. Consider switching to useTransformReactJsxExperimental for all platforms.

I'm getting Postcss errors from NextJS

Run npm list postcss. NextJS has a peerDependancy on PostCSS 8 and you may have to install this peerDependancy yourself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions