Skip to content

Commit e4c7610

Browse files
committed
chore: hypothetical ideal external pacakge with internal client boundary
1 parent d01eb84 commit e4c7610

File tree

5 files changed

+79
-9
lines changed

5 files changed

+79
-9
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
"react-is": "19.0.0-rc-c21bcd627b-20240624",
3939
"@types/react": "18.3.1",
4040
"@types/react-dom": "18.3.0"
41+
},
42+
"patchedDependencies": {
43+
4144
}
4245
}
4346
}

packages/react-server/examples/basic/vite.config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export default defineConfig({
6161
// is not recognized by NodeJS. See:
6262
// node -e 'import("react-wrap-balancer").then(console.log)'
6363
// https://publint.dev/[email protected]
64-
noExternal: ["react-wrap-balancer"],
64+
noExternal: [
65+
"react-wrap-balancer",
66+
// also need to inline react-tweet since obviously nodejs cannot import .module.css
67+
"react-tweet",
68+
],
6569
},
6670
});
6771

packages/react-server/src/features/client-component/plugin.ts

-6
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ export function vitePluginServerUseClient({
129129
const useClientPlugin: Plugin = {
130130
name: vitePluginServerUseClient.name,
131131
async transform(code, id, _options) {
132-
// when using external library's server component includes client reference,
133-
// it will end up here with deps optimization hash `?v=` resolved by server module graph.
134-
if (!manager.buildType && id.includes("?v=")) {
135-
console.error("[useClientPlugin]", { id });
136-
id = id.split("?v=")[0]!;
137-
}
138132
manager.serverIds.add(id);
139133
manager.clientReferenceIds.delete(id);
140134
if (!code.includes(USE_CLIENT)) {

patches/[email protected]

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff --git a/dist/index.js b/dist/index.js
2+
index aad14841e0954a753d6b5a0fb7e4aa5a68f83041..05febf2377e5accfe71f4de8d4b87052b79b5569 100644
3+
--- a/dist/index.js
4+
+++ b/dist/index.js
5+
@@ -1,6 +1,6 @@
6+
// Export every other component that's part of our default theme (the Twitter theme) as that
7+
// can be useful for anyone that wans to do more deep edits in the default theme.
8+
-export * from './twitter-theme/components.js';
9+
+// export * from './twitter-theme/components.js';
10+
export * from './tweet.js';
11+
-export * from './utils.js';
12+
-export * from './hooks.js';
13+
+// export * from './utils.js';
14+
+// export * from './hooks.js';
15+
diff --git a/dist/twitter-theme/quoted-tweet/quoted-tweet.js b/dist/twitter-theme/quoted-tweet/quoted-tweet.js
16+
index 75c3f63fc0747dba24ffe8ea482c82472444dc3f..59c39a7237d0e5cc7f8acb51d71cef138c1e4002 100644
17+
--- a/dist/twitter-theme/quoted-tweet/quoted-tweet.js
18+
+++ b/dist/twitter-theme/quoted-tweet/quoted-tweet.js
19+
@@ -1,5 +1,5 @@
20+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21+
-import { QuotedTweetContainer } from './quoted-tweet-container.js';
22+
+import { QuotedTweetContainer } from 'react-tweet/dist/twitter-theme/quoted-tweet/quoted-tweet-container.js';
23+
import { QuotedTweetHeader } from './quoted-tweet-header.js';
24+
import { QuotedTweetBody } from './quoted-tweet-body.js';
25+
import { TweetMedia } from '../tweet-media.js';
26+
diff --git a/dist/twitter-theme/tweet-actions.js b/dist/twitter-theme/tweet-actions.js
27+
index 5487cddd7cf05de0ed3cc59d222939b7cbc0eaba..1ec537c02a5c3ef49b5a09e58ffad950459dee4f 100644
28+
--- a/dist/twitter-theme/tweet-actions.js
29+
+++ b/dist/twitter-theme/tweet-actions.js
30+
@@ -1,6 +1,6 @@
31+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
32+
import { formatNumber } from '../utils.js';
33+
-import { TweetActionsCopy } from './tweet-actions-copy.js';
34+
+import { TweetActionsCopy } from 'react-tweet/dist/twitter-theme/tweet-actions-copy.js';
35+
import s from './tweet-actions.module.css';
36+
export const TweetActions = ({ tweet })=>{
37+
const favoriteCount = formatNumber(tweet.favorite_count);
38+
diff --git a/dist/twitter-theme/tweet-media.js b/dist/twitter-theme/tweet-media.js
39+
index 9ca911465c726c3c6c94268fc06b24581669e26f..0aafea7be31cc6d36ef29c0a37a2c9498be5fafd 100644
40+
--- a/dist/twitter-theme/tweet-media.js
41+
+++ b/dist/twitter-theme/tweet-media.js
42+
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
43+
import { Fragment } from 'react';
44+
import clsx from 'clsx';
45+
import { getMediaUrl } from '../utils.js';
46+
-import { TweetMediaVideo } from './tweet-media-video.js';
47+
+import { TweetMediaVideo } from 'react-tweet/dist/twitter-theme/tweet-media-video.js';
48+
import { MediaImg } from './media-img.js';
49+
import s from './tweet-media.module.css';
50+
const getSkeletonStyle = (media, itemCount)=>{
51+
diff --git a/package.json b/package.json
52+
index 0d2260f6cf4e40164c0f41972ac469c5e9d23739..109ff1b629f329076777a40aa921d4f80a6326b8 100644
53+
--- a/package.json
54+
+++ b/package.json
55+
@@ -17,7 +17,8 @@
56+
"default": "./dist/index.client.js"
57+
},
58+
"./api": "./dist/api/index.js",
59+
- "./theme.css": "./dist/twitter-theme/theme.css"
60+
+ "./theme.css": "./dist/twitter-theme/theme.css",
61+
+ "./dist/*": "./dist/*"
62+
},
63+
"files": [
64+
"dist/**/*.{js,d.ts,css}"

pnpm-lock.yaml

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)