build: update packages to use more modern moduleresolution options #1770
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following: #1760 (comment)
This change updates tsconfigs across all packages to use more up to date
module
andmoduleResolution
options. For all packages that were being built ascommonjs
modules withnode
moduleResolution
, they've been updated to usenodenext
.I also took the opportunity to re-organize the tsconfigs at the packages level to make their names more accurate. Previously the main
packages/tsconfig.json
, which is what thebuild:esm
command targeted, referenced all package's tsconfigs, while apackages/tsconfig.cjs.json
only referenced the cjs tsconfig from the react package. However, all packages' tsconfigs except for the react tsconfig are building cjs. So having a command that's calledbuild:esm
run all cjs builds and one esm build didn't really do what the name would suggest. So I reversed that construct. Nowpackages/tsconfig.json
still references all of the packages tsconfig, except for the react package, it references thetsconfig.cjs
, and I renamed thepackages/tsconfig.cjs.json
topackages/tsconfig.esm.json
and have it only referencing the main react package tsconfig (which is the only esm config).The net / net is that
build:esm
is only building esm output andbuild:cjs
is only building cjs output.Similarly, all package level tsconfigs are inheriting from packages/tsconfig.options.json, but that config had
module
andmoduleResolution
corresponding to the tsconfig in react (the ESM one), and all of the other package tsconfigs were overriding themodule
andmoduleResolution
. So I swapped that, so that the base config has the module and moduleResolution that all but on of the packages are using, and had the react tsconfig override that to what it needed to be for esm output. This means fewer tsconfigs are needing to override those options.Lastly, I've done build comparisons for all packages and targets, and all result in the exact same build output as they did before these changes, except for one file.
utils/with-plugin
which has a dynamic import. The old schoolcommonjs
module didn't support dynamic imports so it transpiled it down to a require and a bunch of additional wiring to give a similar behavior. Innodenext
it just uses the dynamic import directly.(left is before, right is after)
All this extra cruft:
Just to support this one
import
So, I'm not sure how you'd like to represent this in the
utils
changelog. All the rest are exactly the same output.