Skip to content

Commit

Permalink
Ensure that react and react-dom are externalized (#1041)
Browse files Browse the repository at this point in the history
* Ensure that `react` and `react-dom` are externalized

Had some trouble at work with `@rsc-parser/embedded` that may have come from there potentially being two copies `react-dom`.

* Run yarn install
  • Loading branch information
alvarlagerlof authored Jun 8, 2024
1 parent 2885321 commit 095e40e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 37 deletions.
10 changes: 10 additions & 0 deletions .changeset/mighty-badgers-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@rsc-parser/embedded": patch
"@rsc-parser/core": patch
"@rsc-parser/embedded-example": patch
"@rsc-parser/chrome-extension": patch
"@rsc-parser/storybook": patch
"@rsc-parser/website": patch
---

Ensure that `react` and `react-dom` are externalized
44 changes: 23 additions & 21 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
"package.json",
"dist"
],
"type": "module",
"style": "./dist/style.css",
"exports": {
".": {
"import": "./dist/js/main.js",
"types": "./dist/js/src/main.d.ts"
},
"./style.css": {
"import": "./dist/style.css"
},
"./fetchPatcher": {
"import": "./dist/js/fetchPatcher.js",
"types": "./dist/js/src/fetchPatcher.d.ts"
}
},
"dependencies": {
"d3": "7.9.0",
"react-error-boundary": "4.0.13",
"react-resizable-panels": "2.0.19"
},
"devDependencies": {
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.4.0",
Expand All @@ -41,33 +61,15 @@
"jest-environment-jsdom": "29.7.0",
"postcss": "8.4.38",
"prettier": "3.3.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"tailwindcss": "3.4.4",
"ts-jest": "29.1.4",
"typescript": "5.4.5",
"typescript-eslint": "7.12.0",
"vite": "5.2.13",
"vite-plugin-dts": "3.9.1"
},
"type": "module",
"exports": {
".": {
"import": "./dist/js/main.js",
"types": "./dist/js/src/main.d.ts"
},
"./style.css": {
"import": "./dist/style.css"
},
"./fetchPatcher": {
"import": "./dist/js/fetchPatcher.js",
"types": "./dist/js/src/fetchPatcher.d.ts"
}
},
"style": "./dist/style.css",
"dependencies": {
"d3": "7.9.0",
"react-error-boundary": "4.0.13",
"react-resizable-panels": "2.0.19"
"peerDependencies": {
"react": "18.3.1",
"react-dom": "18.3.1"
}
}
2 changes: 1 addition & 1 deletion packages/core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig({
},
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["react"],
external: ["react", "react-dom"],
output: {
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
Expand Down
14 changes: 4 additions & 10 deletions packages/embedded/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,22 @@
"typecheck": "tsc --noEmit",
"clean": "rm -rf dist"
},
"files": [
"package.json",
"dist"
],
"types": "./dist/js/RscDevtoolsPanel.d.ts",
"exports": {
".": {
"import": "./dist/js/embedded.js"
},
"./style.css": "./dist/style.css"
},
"files": [
"package.json",
"dist"
],
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@eslint/js": "9.4.0",
"@rsc-parser/core": "workspace:^",
"@vitejs/plugin-react": "4.3.0",
"eslint": "9.4.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"rollup-plugin-preserve-directives": "0.4.0",
"typescript": "5.4.5",
"vite": "5.2.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/embedded/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineConfig({
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["react"],
external: ["react", "react-dom"],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
Expand Down
7 changes: 3 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3901,8 +3901,6 @@ __metadata:
jest-environment-jsdom: "npm:29.7.0"
postcss: "npm:8.4.38"
prettier: "npm:3.3.1"
react: "npm:18.3.1"
react-dom: "npm:18.3.1"
react-error-boundary: "npm:4.0.13"
react-resizable-panels: "npm:2.0.19"
tailwindcss: "npm:3.4.4"
Expand All @@ -3911,6 +3909,9 @@ __metadata:
typescript-eslint: "npm:7.12.0"
vite: "npm:5.2.13"
vite-plugin-dts: "npm:3.9.1"
peerDependencies:
react: 18.3.1
react-dom: 18.3.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -3946,8 +3947,6 @@ __metadata:
"@rsc-parser/core": "workspace:^"
"@vitejs/plugin-react": "npm:4.3.0"
eslint: "npm:9.4.0"
react: "npm:18.3.1"
react-dom: "npm:18.3.1"
rollup-plugin-preserve-directives: "npm:0.4.0"
typescript: "npm:5.4.5"
vite: "npm:5.2.13"
Expand Down

0 comments on commit 095e40e

Please sign in to comment.