Skip to content

Commit c251358

Browse files
authored
Revert "refactor(angular-query): migrate from tsup to vite (#9281)" (#9282)
This reverts commit 1c7c276.
1 parent 6f51997 commit c251358

File tree

10 files changed

+37
-404
lines changed

10 files changed

+37
-404
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ignoreRules": ["cjs-resolves-to-esm"]
2+
"ignoreRules": ["cjs-resolves-to-esm", "no-resolution"]
33
}

packages/angular-query-experimental/package.json

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"tanstack"
2828
],
2929
"scripts": {
30-
"clean": "premove ./build ./coverage ./dist-ts ./**.d.ts",
30+
"clean": "premove ./build ./coverage ./dist-ts",
3131
"compile": "tsc --build",
3232
"test:eslint": "eslint ./src",
3333
"test:types": "npm-run-all --serial test:types:*",
@@ -42,29 +42,28 @@
4242
"test:types:tscurrent": "tsc --build",
4343
"test:lib": "vitest",
4444
"test:lib:dev": "pnpm run test:lib --watch",
45-
"test:build": "pnpm pack && publint *.tgz --strict && attw *.tgz; premove *.tgz",
46-
"build": "vite build",
47-
"prepack": "node scripts/prepack.js",
48-
"postpack": "node scripts/postpack.js"
45+
"test:build": "publint --strict && attw --pack",
46+
"build": "pnpm build:tsup",
47+
"build:tsup": "tsup --tsconfig tsconfig.prod.json"
4948
},
5049
"type": "module",
51-
"types": "dist/types/index.d.ts",
52-
"module": "dist/index.mjs",
50+
"types": "build/index.d.ts",
51+
"module": "build/index.mjs",
5352
"exports": {
5453
".": {
55-
"types": "./dist/types/index.d.ts",
5654
"@tanstack/custom-condition": "./src/index.ts",
57-
"default": "./dist/index.mjs"
55+
"types": "./build/index.d.ts",
56+
"default": "./build/index.mjs"
5857
},
5958
"./package.json": {
6059
"default": "./package.json"
6160
}
6261
},
6362
"sideEffects": false,
6463
"files": [
65-
"**/*.d.ts",
66-
"dist",
67-
"!dist/types/**"
64+
"build",
65+
"src",
66+
"!src/__tests__"
6867
],
6968
"dependencies": {
7069
"@tanstack/query-core": "workspace:*",
@@ -78,25 +77,10 @@
7877
"@angular/platform-browser-dynamic": "^20.0.0",
7978
"@tanstack/query-test-utils": "workspace:*",
8079
"eslint-plugin-jsdoc": "^50.5.0",
81-
"npm-run-all2": "^5.0.0",
82-
"vite-plugin-dts": "4.2.3",
83-
"vite-plugin-externalize-deps": "^0.9.0",
84-
"vite-tsconfig-paths": "^5.1.4"
80+
"npm-run-all2": "^5.0.0"
8581
},
8682
"peerDependencies": {
8783
"@angular/common": ">=16.0.0",
8884
"@angular/core": ">=16.0.0"
89-
},
90-
"publishConfig": {
91-
"types": "index.d.ts",
92-
"exports": {
93-
".": {
94-
"types": "./index.d.ts",
95-
"default": "./dist/index.mjs"
96-
},
97-
"./package.json": {
98-
"default": "./package.json"
99-
}
100-
}
10185
}
10286
}

packages/angular-query-experimental/scripts/postpack.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

packages/angular-query-experimental/scripts/prepack.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

packages/angular-query-experimental/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"compilerOptions": {
44
"outDir": "./dist-ts",
55
"rootDir": ".",
6+
"noImplicitOverride": true,
7+
"noPropertyAccessFromIndexSignature": true,
68
"noFallthroughCasesInSwitch": true,
79
"useDefineForClassFields": false,
810
"target": "ES2022"

packages/angular-query-experimental/tsconfig.prod.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"compilerOptions": {
44
"incremental": false,
55
"composite": false,
6-
"rootDir": "../../",
7-
"customConditions": null
6+
"rootDir": "../../"
87
}
98
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'tsup'
2+
3+
export default defineConfig({
4+
entry: ['src/index.ts'],
5+
sourcemap: true,
6+
clean: true,
7+
format: ['esm'],
8+
dts: true,
9+
outDir: 'build',
10+
outExtension({ format }) {
11+
return format === 'esm' ? { js: '.mjs' } : { js: '.js' }
12+
},
13+
})
Lines changed: 3 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,8 @@
1-
import { defineConfig, mergeConfig } from 'vitest/config'
2-
import { externalizeDeps } from 'vite-plugin-externalize-deps'
3-
import tsconfigPaths from 'vite-tsconfig-paths'
4-
import dts from 'vite-plugin-dts'
5-
import packageJson from './package.json'
6-
import type { Options } from '@tanstack/config/vite'
7-
8-
function ensureImportFileExtension({
9-
content,
10-
extension,
11-
}: {
12-
content: string
13-
extension: string
14-
}) {
15-
// replace e.g. `import { foo } from './foo'` with `import { foo } from './foo.js'`
16-
content = content.replace(
17-
/(im|ex)port\s[\w{}/*\s,]+from\s['"](?:\.\.?\/)+?[^.'"]+(?=['"];?)/gm,
18-
`$&.${extension}`,
19-
)
1+
import { defineConfig } from 'vitest/config'
202

21-
// replace e.g. `import('./foo')` with `import('./foo.js')`
22-
content = content.replace(
23-
/import\(['"](?:\.\.?\/)+?[^.'"]+(?=['"];?)/gm,
24-
`$&.${extension}`,
25-
)
26-
return content
27-
}
3+
import packageJson from './package.json'
284

29-
const config = defineConfig({
5+
export default defineConfig({
306
// fix from https://github.com/vitest-dev/vitest/issues/6992#issuecomment-2509408660
317
resolve: {
328
conditions: ['@tanstack/custom-condition'],
@@ -50,73 +26,3 @@ const config = defineConfig({
5026
restoreMocks: true,
5127
},
5228
})
53-
54-
// copy from @tanstack/config/vite with changes:
55-
// - dts outDir: dist/types
56-
// - build - lib - fileName: [name.mjs]
57-
// - rollup - output - preserveModulesRoot: src
58-
export const tanstackViteConfig = (options: Options) => {
59-
const outDir = options.outDir ?? 'dist'
60-
const cjs = options.cjs ?? true
61-
62-
return defineConfig({
63-
plugins: [
64-
externalizeDeps({ include: options.externalDeps ?? [] }),
65-
tsconfigPaths({
66-
projects: options.tsconfigPath ? [options.tsconfigPath] : undefined,
67-
}),
68-
dts({
69-
outDir: `dist/types`,
70-
entryRoot: options.srcDir,
71-
include: options.srcDir,
72-
exclude: options.exclude,
73-
tsconfigPath: options.tsconfigPath,
74-
compilerOptions: {
75-
module: 99, // ESNext
76-
declarationMap: false,
77-
},
78-
beforeWriteFile: (filePath, content) => {
79-
// content =
80-
// options.beforeWriteDeclarationFile?.(filePath, content) || content
81-
return {
82-
filePath,
83-
content: ensureImportFileExtension({ content, extension: 'js' }),
84-
}
85-
},
86-
afterDiagnostic: (diagnostics) => {
87-
if (diagnostics.length > 0) {
88-
console.error('Please fix the above type errors')
89-
process.exit(1)
90-
}
91-
},
92-
}),
93-
],
94-
build: {
95-
outDir,
96-
minify: false,
97-
sourcemap: true,
98-
lib: {
99-
entry: options.entry,
100-
formats: cjs ? ['es', 'cjs'] : ['es'],
101-
fileName: () => '[name].mjs',
102-
},
103-
rollupOptions: {
104-
output: {
105-
preserveModules: true,
106-
preserveModulesRoot: 'src',
107-
},
108-
},
109-
},
110-
})
111-
}
112-
113-
export default mergeConfig(
114-
config,
115-
tanstackViteConfig({
116-
cjs: false,
117-
entry: ['./src/index.ts'],
118-
exclude: ['src/__tests__'],
119-
srcDir: './src',
120-
tsconfigPath: 'tsconfig.prod.json',
121-
}),
122-
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ignoreRules": ["cjs-resolves-to-esm"]
2+
"ignoreRules": ["cjs-resolves-to-esm", "no-resolution"]
33
}

0 commit comments

Comments
 (0)