From c837f02418b44009cc3b9176f30455df87856b38 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:45:15 +1000 Subject: [PATCH 1/2] feat: Add explicit package.json type field --- package.json | 1 + packages/codemods/package.json | 1 + packages/eslint-plugin-query/package.json | 1 + packages/query-async-storage-persister/package.json | 1 + packages/query-broadcast-client-experimental/package.json | 1 + packages/query-core/package.json | 1 + packages/query-devtools/package.json | 1 + packages/query-persist-client-core/package.json | 1 + packages/query-sync-storage-persister/package.json | 1 + packages/react-query-devtools/package.json | 1 + packages/react-query-persist-client/package.json | 1 + packages/react-query/package.json | 1 + packages/solid-query/package.json | 1 + packages/svelte-query-devtools/package.json | 2 ++ packages/svelte-query/package.json | 2 ++ packages/vue-query/package.json | 1 + scripts/config.mjs | 4 ++-- scripts/types.d.ts | 2 +- 18 files changed, 21 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b3442be3b9..cb17bf74d8 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "query", "repository": "https://github.com/tanstack/query.git", "packageManager": "pnpm@8.5.1", + "type": "module", "scripts": { "clean": "pnpm --filter \"./packages/**\" run clean", "preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm", diff --git a/packages/codemods/package.json b/packages/codemods/package.json index 8b6ddf2962..bdb1ecc906 100644 --- a/packages/codemods/package.json +++ b/packages/codemods/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "exports": { "./package.json": "./package.json" }, diff --git a/packages/eslint-plugin-query/package.json b/packages/eslint-plugin-query/package.json index c5e8641b2e..a561e86d40 100644 --- a/packages/eslint-plugin-query/package.json +++ b/packages/eslint-plugin-query/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "main": "build/lib/index.js", "exports": { ".": { diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index b7c09f83ae..73e50de584 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index 23539e10fe..0a3e40f0db 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/query-core/package.json b/packages/query-core/package.json index d25de1d0d6..67f3b221e1 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/query-devtools/package.json b/packages/query-devtools/package.json index 712ffdffcd..6ad47e2bb0 100644 --- a/packages/query-devtools/package.json +++ b/packages/query-devtools/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/types/index.d.ts", "main": "build/umd/index.js", "module": "build/esm/index.mjs", diff --git a/packages/query-persist-client-core/package.json b/packages/query-persist-client-core/package.json index 9dc408502a..2443966168 100644 --- a/packages/query-persist-client-core/package.json +++ b/packages/query-persist-client-core/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index ef976d3312..24470852a4 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index 76ee68dcf9..74467c33c1 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index c2b85b8e44..b829570cb8 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 31ed4069b0..2504665b9c 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/packages/solid-query/package.json b/packages/solid-query/package.json index f47d03c092..d480a77fb1 100644 --- a/packages/solid-query/package.json +++ b/packages/solid-query/package.json @@ -10,6 +10,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/types/index.d.ts", "main": "build/cjs/index.js", "module": "build/esm/index.js", diff --git a/packages/svelte-query-devtools/package.json b/packages/svelte-query-devtools/package.json index 9a362fe8c4..81b0431433 100644 --- a/packages/svelte-query-devtools/package.json +++ b/packages/svelte-query-devtools/package.json @@ -13,10 +13,12 @@ "type": "module", "types": "build/lib/index.d.ts", "module": "build/lib/index.js", + "svelte": "./build/lib/index.js", "exports": { ".": { "types": "./build/lib/index.d.ts", "import": "./build/lib/index.js", + "svelte": "./build/lib/index.js", "default": "./build/lib/index.js" }, "./package.json": "./package.json" diff --git a/packages/svelte-query/package.json b/packages/svelte-query/package.json index 715c522ab4..f325cf043a 100644 --- a/packages/svelte-query/package.json +++ b/packages/svelte-query/package.json @@ -13,10 +13,12 @@ "type": "module", "types": "build/lib/index.d.ts", "module": "build/lib/index.js", + "svelte": "./build/lib/index.js", "exports": { ".": { "types": "./build/lib/index.d.ts", "import": "./build/lib/index.js", + "svelte": "./build/lib/index.js", "default": "./build/lib/index.js" }, "./package.json": "./package.json" diff --git a/packages/vue-query/package.json b/packages/vue-query/package.json index 68fcd5cb07..85f48cee92 100644 --- a/packages/vue-query/package.json +++ b/packages/vue-query/package.json @@ -14,6 +14,7 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "type": "commonjs", "types": "build/lib/index.d.ts", "main": "build/lib/index.js", "module": "build/lib/index.esm.js", diff --git a/scripts/config.mjs b/scripts/config.mjs index f42b2b7f1c..6c66aaac7c 100644 --- a/scripts/config.mjs +++ b/scripts/config.mjs @@ -61,12 +61,12 @@ export const packages = [ { name: '@tanstack/svelte-query', packageDir: 'packages/svelte-query', - entries: ['module', 'types'], + entries: ['module', 'svelte', 'types'], }, { name: '@tanstack/svelte-query-devtools', packageDir: 'packages/svelte-query-devtools', - entries: ['module', 'types'], + entries: ['module', 'svelte', 'types'], }, { name: '@tanstack/vue-query', diff --git a/scripts/types.d.ts b/scripts/types.d.ts index 371f375f9d..46e51dc10a 100644 --- a/scripts/types.d.ts +++ b/scripts/types.d.ts @@ -39,7 +39,7 @@ export type Parsed = { export type Package = { name: string packageDir: string - entries: Array<'main' | 'module' | 'types'> + entries: Array<'main' | 'module' | 'svelte' | 'types'> } export type BranchConfig = { From 5d6376e11fb336cc405a5cc7195ac4b0232c26ff Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:51:23 +1000 Subject: [PATCH 2/2] Rename to babel.config.cjs --- babel.config.js => babel.config.cjs | 0 nx.json | 2 +- scripts/getRollupConfig.mjs | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename babel.config.js => babel.config.cjs (100%) diff --git a/babel.config.js b/babel.config.cjs similarity index 100% rename from babel.config.js rename to babel.config.cjs diff --git a/nx.json b/nx.json index 4897461535..254ab0adce 100644 --- a/nx.json +++ b/nx.json @@ -28,7 +28,7 @@ "namedInputs": { "globalBuildAffectingConfig": [ "{workspaceRoot}/.browserslistrc", - "{workspaceRoot}/babel.config.js", + "{workspaceRoot}/babel.config.cjs", "{workspaceRoot}/package.json", "{workspaceRoot}/scripts/getRollupConfig.mjs", "{workspaceRoot}/tsconfig.json" diff --git a/scripts/getRollupConfig.mjs b/scripts/getRollupConfig.mjs index 2bba0b8c71..e4054a79d2 100644 --- a/scripts/getRollupConfig.mjs +++ b/scripts/getRollupConfig.mjs @@ -23,7 +23,7 @@ const forceEnvPlugin = (type) => /** @param {'legacy' | 'modern'} type */ const babelPlugin = (type) => babel({ - configFile: resolve(rootDir, 'babel.config.js'), + configFile: resolve(rootDir, 'babel.config.cjs'), browserslistConfigFile: type === 'modern' ? true : false, targets: type === 'modern'