Skip to content

Commit faf29d3

Browse files
committed
refactor: cleanup
1 parent a08b955 commit faf29d3

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,24 +2128,19 @@ function validateImportPlugin(): Plugin {
21282128
function vendorUseSyncExternalStorePlugin(): Plugin[] {
21292129
// vendor and optimize use-sync-external-store out of the box
21302130
// since this is a commonly used cjs dep (e.g. swr, @tanstack/react-store)
2131+
const DEP_NAME = 'use-sync-external-store'
2132+
const VENDOR_DEP_NAME = `${PKG_NAME}/vendor/use-sync-external-store`
21312133

2132-
const vendorDeps = [
2133-
`${PKG_NAME}/vendor/use-sync-external-store/index`,
2134-
`${PKG_NAME}/vendor/use-sync-external-store/with-selector`,
2135-
`${PKG_NAME}/vendor/use-sync-external-store/shim/index`,
2136-
`${PKG_NAME}/vendor/use-sync-external-store/shim/with-selector`,
2137-
]
2138-
2139-
// map exports to vendor deps
2134+
// map exports
21402135
// cf. https://github.com/facebook/react/blob/c499adf8c89bbfd884f4d3a58c4e510001383525/packages/use-sync-external-store/package.json#L5-L20
21412136
const alias: Record<string, string> = {
2142-
'use-sync-external-store': `${PKG_NAME}/vendor/use-sync-external-store/index`,
2143-
'use-sync-external-store/with-selector': `${PKG_NAME}/vendor/use-sync-external-store/with-selector`,
2144-
'use-sync-external-store/with-selector.js': `${PKG_NAME}/vendor/use-sync-external-store/with-selector`,
2145-
'use-sync-external-store/shim': `${PKG_NAME}/vendor/use-sync-external-store/shim/index`,
2146-
'use-sync-external-store/shim/index.js': `${PKG_NAME}/vendor/use-sync-external-store/shim/index`,
2147-
'use-sync-external-store/shim/with-selector': `${PKG_NAME}/vendor/use-sync-external-store/shim/with-selector`,
2148-
'use-sync-external-store/shim/with-selector.js': `${PKG_NAME}/vendor/use-sync-external-store/shim/with-selector`,
2137+
[DEP_NAME]: `${VENDOR_DEP_NAME}/index`,
2138+
[`${DEP_NAME}/with-selector`]: `${VENDOR_DEP_NAME}/with-selector`,
2139+
[`${DEP_NAME}/with-selector.js`]: `${VENDOR_DEP_NAME}/with-selector`,
2140+
[`${DEP_NAME}/shim`]: `${VENDOR_DEP_NAME}/shim/index`,
2141+
[`${DEP_NAME}/shim/index.js`]: `${VENDOR_DEP_NAME}/shim/index`,
2142+
[`${DEP_NAME}/shim/with-selector`]: `${VENDOR_DEP_NAME}/shim/with-selector`,
2143+
[`${DEP_NAME}/shim/with-selector.js`]: `${VENDOR_DEP_NAME}/shim/with-selector`,
21492144
}
21502145

21512146
return [
@@ -2157,7 +2152,7 @@ function vendorUseSyncExternalStorePlugin(): Plugin[] {
21572152
environments: {
21582153
ssr: {
21592154
optimizeDeps: {
2160-
include: vendorDeps,
2155+
include: [...new Set(Object.values(alias))],
21612156
},
21622157
},
21632158
},

0 commit comments

Comments
 (0)