From 7b541a980dbebc3b44b6c3b0c2806add79786222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Tue, 8 Feb 2022 17:19:52 -0500 Subject: [PATCH] Add exports field to react-dom (#23252) This configures the exports field for react-dom. Notably there are some conditions for the /server entry point where we pick the export based on environments. Most environments now support Web Streams which is preferred in those environments. We already do this using the "browser" field so the "browser" condition applies here too. I don't think it's necessary, but I also specified "worker" explicitly since this is for Service Workers and those are often targeted with Web Pack's "webworker" target, which is also what Cloudflare currently recommends. I also added "deno" but deno is a bit special because this only works if you run with the node compatibility since otherwise you have to specify absolute URLs for the imports. --- packages/react-dom/package.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/react-dom/package.json b/packages/react-dom/package.json index c60f4950dd6ca..6125002eb82a1 100644 --- a/packages/react-dom/package.json +++ b/packages/react-dom/package.json @@ -38,6 +38,19 @@ "cjs/", "umd/" ], + "exports": { + ".": "./index.js", + "./server": { + "deno": "./server.browser.js", + "worker": "./server.browser.js", + "browser": "./server.browser.js", + "default": "./server.node.js" + }, + "./profiling": "./profiling.js", + "./test-utils": "./test-utils.js", + "./package.json": "./package.json", + "./": "./" + }, "browser": { "./server.js": "./server.browser.js" },