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

Request for minor release of 17.0.3 to support ESM packages #24095

Closed
leebeydoun opened this issue Mar 14, 2022 · 6 comments
Closed

Request for minor release of 17.0.3 to support ESM packages #24095

leebeydoun opened this issue Mar 14, 2022 · 6 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@leebeydoun
Copy link

leebeydoun commented Mar 14, 2022

This was previously requested: Request for Package Release

The package.json of 17.0.2 does not specify the exports field. If a package is of type module and using React it will break when using the automatic JSX runtime, since the import (usually inserted by transpilers like swc) will be:

import {jsx as _jsx} from 'react/jsx-runtime';

But for ESM modules (when not specified in exports) it should be:

import {jsx as _jsx} from 'react/jsx-runtime.js';

May I ask if the React team could release a new minor version of 17.0.3 even if it is just an updated package.json with no other code changes, since it will contain these exports:

Original Source

  "exports": {
    ".": {
      "react-server": "./react.shared-subset.js",
      "default": "./index.js"
    },
    "./package.json": "./package.json",
    "./jsx-runtime": "./jsx-runtime.js",
    "./jsx-dev-runtime": "./jsx-dev-runtime.js",
    "./src/*": "./src/*"
  },

I know React 18 is coming (and does have these fields specified), but without an update to React 17, a native ESM package that uses React will either be forced to not use the automatic runtime or only support React 18.

Edit:
This should also fix this issue and this MUI blocker.

@leebeydoun leebeydoun added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 14, 2022
@ysulyma
Copy link

ysulyma commented Apr 8, 2022

Just encountered this. This causes a major compatibility headache between React 17 and React 18.

@gaearon
Copy link
Collaborator

gaearon commented Apr 8, 2022

I'll add this to our list of topics to discuss. Many libraries are cutting majors for 18+ though since there are often other changes for compatibility that might depend on new APIs.

@gaearon
Copy link
Collaborator

gaearon commented Apr 8, 2022

Is there any situation in which this change would be breaking?

@gaearon
Copy link
Collaborator

gaearon commented Apr 11, 2022

We've had a discussion about this.

React 18 is out, so at least this is out of the way. Classic JSX runtime is supported in both versions (and doesn't warn) so it should not be a blocker per se for libraries wanting to support both 17 and 18.

This originally broke because environments have gotten more restrictive (to follow Node.js). E.g. if I recall correctly, it used to work with webpack 4 but broke with webpack 5. So React didn’t narrow down the compatibility — it’s the tooling upgrade that did. With the amount of churn around ESM resolution and related tooling, we think it is too risky to add exports to 17.x releases at this point. We didn't plan more 17.x releases in the first place, and if something goes wrong, we would be in even more messy state. At least with 18, there is a clear separation between behaviors. I understand the frustration but we don’t think the risk is worth it, and especially with 18 already being out, there is a clear path forward.

@gaearon gaearon closed this as completed Apr 11, 2022
@NMinhNguyen
Copy link
Contributor

NMinhNguyen commented Apr 12, 2022

if something goes wrong, we would be in even more messy state.

I understand the hesitancy and I don't know what it takes to cut a React release for non-main branches (perhaps it is very manual and time-consuming), but to play devil's advocate, there shouldn't be that much harm in cutting 17.0.3 and then 17.0.4 in case there are any issues? If there turn out to be no issues, then a lot of users would be happy.

At least with 18, there is a clear separation between behaviors.

Just curious, what separation of behaviours are you referring to?

@gaearon
Copy link
Collaborator

gaearon commented Apr 12, 2022

there shouldn't be that much harm in cutting 17.0.3 and then 17.0.4 in case there are any issues? If there turn out to be no issues, then a lot of users would be happy.

It is often tempting to do something like this. But it’s hard to predict what will happen. Maybe you release one version and it breaks some people. Some people work around it. Eventually someone reports it. You have to determine how common the issue is. Eventually maybe you decide to revert. But then you can break people who have already fixed their code to work with the previous patch. And people who relied on the original fix have to go back too. By that time people write wrong StackOverflow articles etc. It’s a mess.

We don’t want to teach people that a patch is scary to update to. We’ve been using patches only for critical fixes lately. So this would have to be a minor. And then another minor to undo it. This is too much of a risk and distraction when we already have a release that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants