Skip to content

[labs/nextjs] Support Next.js 14 #4410

Closed

Description

@augustjk

Which package(s) are affected?

Other/unknown (please mention in description)

Description

The plugin still should work with the Page router even in Next.js 14.

We could include it in our peer dependency sem ver to allow installs. We should still clearly document limitation with App router.

Activity

  1. foadtkf commented on Feb 16, 2024

    @foadtkf

    what about the app router?
    image

  2. augustjk commented on Feb 28, 2024

    @augustjk
    MemberAuthor

    @foadtkf support for app router is tracked in a separate issue #3657

  3. augustjk commented on Feb 28, 2024

    @augustjk
    MemberAuthor

    Supporting v14 seems a bit more complicated as they're now bundling react/jsx-dev-runtime and react/jsx-runtime rather than it being external for us to use the normal module replacement plugin. See vercel/next.js#46470 (comment) and vercel/next.js#55362

    We may need to make users specify jsxImportSource instead and also forego with wrapping the webpack externals config. This means we no longer have the ability to touch any jsx-runtime imports within node_modules code, e.g. npm installed react components that use bare Lit components within them. This was considered a pretty niche use case to support but nonetheless disappointing to have to give up. Ergonomically it also defeats a large purpose for the plugin which is meant to be a one step config for enabling Lit SSR and also preserve the composability when already using an alternate runtime jsx.

    Monkey-patching of React.createElement still seems to work. It used to be problematic in early v14 perhaps related to the esm loader approach they were doing for React to support using react canary with app router.

  4. augustjk commented on Mar 9, 2024

    @augustjk
    MemberAuthor

    Found a way to monkey-patch everything without resorting to module replacement in above linked PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions