diff --git a/docs/react/guides/migrating-to-v5.md b/docs/react/guides/migrating-to-v5.md index d418a15dc5..9b3cfae6fb 100644 --- a/docs/react/guides/migrating-to-v5.md +++ b/docs/react/guides/migrating-to-v5.md @@ -177,6 +177,10 @@ Custom loggers were already deprecated in 4 and have been removed in this versio We have updated our browserslist to produce a more modern, performant and smaller bundle. You can read about the requirements [here](../installation#requirements). +### Supported Bundlers + +We have removed the legacy `.esm.js` output, which was used by bundlers which didn't recognise the modern `.mjs` extension such as Webpack v4. If you are still using Webpack v4, you can continue to use TanStack Query v4, or upgrade to Webpack v5 or another bundler. + ### Private class fields and methods TanStack Query has always had private fields and methods on classes, but they weren't really private - they were just private in `TypeScript`. We now use [ECMAScript Private class features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields), which means those fields are now truly private and can't be accessed from the outside at runtime. diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index 177a5b06fd..375744cc77 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index c7f3a61dcb..3e44b55a41 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-core/package.json b/packages/query-core/package.json index 2ff74499c6..729ee5a435 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-persist-client-core/package.json b/packages/query-persist-client-core/package.json index 7cc4ffc308..4af897e36d 100644 --- a/packages/query-persist-client-core/package.json +++ b/packages/query-persist-client-core/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index aa69c504d6..52f43dfb42 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index 2cc85da984..0ab57b6042 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index 1d25f3a196..d15955a204 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 22a8bee011..2981fc752d 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -13,7 +13,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/vue-query/package.json b/packages/vue-query/package.json index 3f5f3d4f70..4ef8c89719 100644 --- a/packages/vue-query/package.json +++ b/packages/vue-query/package.json @@ -17,7 +17,7 @@ "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", - "module": "build/lib/index.esm.js", + "module": "build/lib/index.mjs", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/scripts/getRollupConfig.mjs b/scripts/getRollupConfig.mjs index e4054a79d2..8461b7d507 100644 --- a/scripts/getRollupConfig.mjs +++ b/scripts/getRollupConfig.mjs @@ -75,7 +75,7 @@ export function buildConfigs(opts) { forceBundle: opts.forceBundle || false, } - let builds = [mjs(options), esm(options), cjs(options)] + let builds = [mjs(options), cjs(options)] if (!opts.skipUmdBuild) { builds = builds.concat([ @@ -123,42 +123,6 @@ function mjs({ input, external, outputFile, forceDevEnv, forceBundle }) { } } -/** - * @param {import('./types').Options} options - Options for building configurations. - * @returns {import('rollup').RollupOptions} - */ -function esm({ input, external, outputFile, forceDevEnv, forceBundle }) { - /** @type {import('rollup').OutputOptions} */ - const bundleOutput = { - format: 'esm', - file: `./build/lib/${outputFile}.esm.js`, - sourcemap: true, - } - - /** @type {import('rollup').OutputOptions} */ - const normalOutput = { - format: 'esm', - dir: `./build/lib`, - sourcemap: true, - preserveModules: true, - entryFileNames: '[name].esm.js', - } - - return { - // ESM - external, - input, - output: forceBundle ? bundleOutput : normalOutput, - plugins: [ - babelPlugin('legacy'), - commonJS(), - nodeResolve({ extensions: ['.ts', '.tsx', '.native.ts'] }), - forceDevEnv ? forceEnvPlugin('development') : undefined, - preserveDirectives(), - ], - } -} - /** * @param {import('./types').Options} options - Options for building configurations. * @returns {import('rollup').RollupOptions}