Skip to content

Commit e667998

Browse files
committed
Remove deprecated folder mapping
Node v16 deprecated the use of trailing "/" to define subpath folder mappings in the "exports" field of package.json. The recommendation is to explicitly list all our exports. We already do that for all our public modules. I believe the only reason we have a wildcard pattern is because our package.json files are also used at build time (by Rollup) to resolve internal source modules that don't appear in the final npm artifact. Changing trailing "/" to "/*" fixes the warnings. See https://nodejs.org/api/packages.html#subpath-patterns for more info. Since the wildcard pattern only exists so our build script has access to internal at build time, I've scoped the wildcard to "/src*". Because our public modules are located outside the "src" directory, this means deep imports of our modules will no longer work: only packages that are listed in the "exports" field. The only two affected packages are react-dom and react. We need to be sure that all our public modules are still reachable. I audited the exports by comparing the entries to the "files" field in package.json, which represents a complete list of the files that are included in the final release artifact. At some point, we should add an e2e packaging test to prevent regressions; for now, we should have decent coverage because in CI we run our Jest test suite against the release artifacts.
1 parent d283f4a commit e667998

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

packages/react-dom/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@
4848
},
4949
"./profiling": "./profiling.js",
5050
"./test-utils": "./test-utils.js",
51-
"./package.json": "./package.json",
52-
"./": "./"
51+
"./unstable_testing": "./unstable_testing.js",
52+
"./testing": "./testing.js",
53+
"./umd/*": "./umd/*",
54+
"./src/*": "./src/*",
55+
"./package.json": "./package.json"
5356
},
5457
"browser": {
5558
"./server.js": "./server.browser.js"

packages/react-server-dom-webpack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"./writer.browser.server": "./writer.browser.server.js",
3737
"./node-loader": "./esm/react-server-dom-webpack-node-loader.js",
3838
"./node-register": "./node-register.js",
39+
"./src/*": "./src/*",
3940
"./package.json": "./package.json"
4041
},
4142
"main": "index.js",

packages/react/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"./package.json": "./package.json",
3232
"./jsx-runtime": "./jsx-runtime.js",
3333
"./jsx-dev-runtime": "./jsx-dev-runtime.js",
34-
"./": "./"
34+
"./umd/*": "./umd/*",
35+
"./unstable-shared-subset": "./unstable-shared-subset.js"
36+
3537
},
3638
"repository": {
3739
"type": "git",

0 commit comments

Comments
 (0)