Skip to content

Commit 7948407

Browse files
chore: Rework rollup externals (#5519)
1 parent e3e1e82 commit 7948407

File tree

12 files changed

+20
-48
lines changed

12 files changed

+20
-48
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"react-dom": "^18.2.0",
8282
"rimraf": "^5.0.1",
8383
"rollup": "^3.23.0",
84+
"rollup-plugin-node-externals": "^6.1.0",
8485
"rollup-plugin-preserve-directives": "^0.2.0",
8586
"rollup-plugin-visualizer": "^5.9.0",
8687
"rollup-preset-solid": "^2.0.1",

packages/query-async-storage-persister/rollup.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ export default defineConfig(
99
jsName: 'QueryAsyncStoragePersister',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
'@tanstack/query-persist-client-core': 'QueryPersistClientCore',
14-
},
1512
}),
1613
)

packages/query-broadcast-client-experimental/rollup.config.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@ export default defineConfig(
99
jsName: 'QueryBroadcastClient',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
'@tanstack/query-core': 'QueryCore',
14-
'broadcast-channel': 'BroadcastChannel',
15-
},
1612
}),
1713
)

packages/query-core/rollup.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ export default defineConfig(
99
jsName: 'QueryCore',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {},
1312
}),
1413
)

packages/query-persist-client-core/rollup.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ export default defineConfig(
99
jsName: 'QueryPersistClientCore',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
'@tanstack/query-core': 'QueryCore',
14-
},
1512
}),
1613
)

packages/query-sync-storage-persister/rollup.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ export default defineConfig(
99
jsName: 'QuerySyncStoragePersister',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
'@tanstack/query-persist-client-core': 'QueryPersistClientCore',
14-
},
1512
}),
1613
)

packages/react-query-devtools/rollup.config.mjs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,12 @@ export default defineConfig([
99
jsName: 'ReactQueryDevtools',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
react: 'React',
14-
'react-dom': 'ReactDOM',
15-
'@tanstack/react-query': 'ReactQuery',
16-
'@tanstack/query-devtools': 'TanstackQueryDevtools',
17-
},
1812
}),
1913
buildConfigs({
2014
name: 'react-query-devtools-prod',
2115
jsName: 'ReactQueryDevtools',
2216
outputFile: 'index.prod',
2317
entryFile: './src/index.ts',
24-
globals: {
25-
react: 'React',
26-
'react-dom': 'ReactDOM',
27-
'@tanstack/react-query': 'ReactQuery',
28-
'@tanstack/match-sorter-utils': 'MatchSorterUtils',
29-
superjson: 'SuperJson',
30-
},
3118
forceDevEnv: true,
3219
forceBundle: true,
3320
}),

packages/react-query-persist-client/rollup.config.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ export default defineConfig(
99
jsName: 'ReactQueryPersistClient',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
react: 'React',
14-
'@tanstack/query-persist-client-core': 'QueryPersistClientCore',
15-
'@tanstack/react-query': 'ReactQuery',
16-
},
1712
}),
1813
)

packages/react-query/rollup.config.mjs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,5 @@ export default defineConfig(
99
jsName: 'ReactQuery',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
react: 'React',
14-
'react-dom': 'ReactDOM',
15-
'@tanstack/query-core': 'QueryCore',
16-
'react-native': 'ReactNative',
17-
},
1812
}),
1913
)

packages/vue-query/rollup.config.mjs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,5 @@ export default defineConfig(
99
jsName: 'VueQuery',
1010
outputFile: 'index',
1111
entryFile: './src/index.ts',
12-
globals: {
13-
'@tanstack/query-core': 'QueryCore',
14-
vue: 'Vue',
15-
'vue-demi': 'Vue',
16-
'@tanstack/match-sorter-utils': 'MatchSorter',
17-
'@vue/devtools-api': 'DevtoolsApi',
18-
},
1912
}),
2013
)

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/getRollupConfig.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { visualizer } from 'rollup-plugin-visualizer'
66
import replace from '@rollup/plugin-replace'
77
import { nodeResolve } from '@rollup/plugin-node-resolve'
88
import commonJS from '@rollup/plugin-commonjs'
9+
import externals from 'rollup-plugin-node-externals'
910
import withSolid from 'rollup-preset-solid'
1011
import preserveDirectives from 'rollup-plugin-preserve-directives'
1112
import { rootDir } from './config.mjs'
@@ -33,14 +34,12 @@ const babelPlugin = () =>
3334
* @param {string} opts.jsName - The JavaScript name.
3435
* @param {string} opts.outputFile - The output file.
3536
* @param {string} opts.entryFile - The entry file.
36-
* @param {Record<string, string>} opts.globals - The globals record.
3737
* @param {boolean} [opts.forceDevEnv] - Flag indicating whether to force development environment.
3838
* @param {boolean} [opts.forceBundle] - Flag indicating whether to force bundling.
3939
* @returns {import('rollup').RollupOptions}
4040
*/
4141
export function buildConfigs(opts) {
4242
const input = [opts.entryFile]
43-
const externalDeps = Object.keys(opts.globals)
4443
const forceDevEnv = opts.forceDevEnv || false
4544
const forceBundle = opts.forceBundle || false
4645

@@ -81,12 +80,17 @@ export function buildConfigs(opts) {
8180
return {
8281
input,
8382
output: forceBundle ? bundleOutput : normalOutput,
84-
external: (moduleName) => externalDeps.includes(moduleName),
8583
plugins: [
8684
commonJS(),
8785
babelPlugin(),
8886
nodeResolve({ extensions: ['.ts', '.tsx', '.native.ts'] }),
8987
forceDevEnv ? forceEnvPlugin('development') : undefined,
88+
externals({
89+
packagePath: './package.json',
90+
deps: true,
91+
devDeps: true,
92+
peerDeps: true,
93+
}),
9094
preserveDirectives(),
9195
visualizer({
9296
filename: `./build/stats-html.html`,

0 commit comments

Comments
 (0)