Skip to content

Commit e6a1444

Browse files
committed
build fixes
1 parent 1aeea49 commit e6a1444

File tree

7 files changed

+36
-11
lines changed

7 files changed

+36
-11
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", "no-resolution"]
2+
"ignoreRules": ["cjs-resolves-to-esm"]
33
}

packages/angular-query-experimental/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"test:types:tscurrent": "tsc --build",
4343
"test:lib": "vitest",
4444
"test:lib:dev": "pnpm run test:lib --watch",
45-
"test:build": "publint --strict && attw --pack",
45+
"test:build": "pnpm pack && publint *.tgz --strict && attw *.tgz; premove *.tgz",
4646
"build": "vite build",
4747
"prepack": "node scripts/prepack.js",
4848
"postpack": "node scripts/postpack.js"
@@ -52,8 +52,8 @@
5252
"module": "dist/index.mjs",
5353
"exports": {
5454
".": {
55-
"@tanstack/custom-condition": "./src/index.ts",
5655
"types": "./dist/types/index.d.ts",
56+
"@tanstack/custom-condition": "./src/index.ts",
5757
"default": "./dist/index.mjs"
5858
},
5959
"./package.json": {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ to exactly match the subpath export as in the example above.
3333
},
3434
```
3535
36-
It's important to support `"moduleResolution": "node"` as many Angular applications are configured this way.
37-
Also, NX adds it to the out of box `tsconfig`
36+
It's important to support `"moduleResolution": "node"` as many Angular applications are still configured this way.
3837
3938
In the `postpack` lifecycle script these links are removed to keep a clean development environment
4039
*/

packages/angular-query-experimental/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"compilerOptions": {
44
"outDir": "./dist-ts",
55
"rootDir": ".",
6-
"jsx": "preserve",
7-
"jsxImportSource": "solid-js",
86
"noFallthroughCasesInSwitch": true,
97
"useDefineForClassFields": false,
108
"target": "ES2022"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"incremental": false,
55
"composite": false,
6-
"rootDir": "../../"
6+
"rootDir": "../../",
7+
"customConditions": null
78
}
89
}

packages/angular-query-experimental/vite.config.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ import dts from 'vite-plugin-dts'
55
import packageJson from './package.json'
66
import type { Options } from '@tanstack/config/vite'
77

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+
)
20+
21+
// replace e.g. `import('./foo')` with `import('./foo.js')`
22+
content = content.replace(
23+
/import\(['"](?:\.\.?\/)+?[^.'"]+(?=['"];?)/gm,
24+
`$&.${extension}`,
25+
)
26+
return content
27+
}
28+
829
const config = defineConfig({
930
// fix from https://github.com/vitest-dev/vitest/issues/6992#issuecomment-2509408660
1031
resolve: {
@@ -31,8 +52,6 @@ const config = defineConfig({
3152
})
3253

3354
// copy from @tanstack/config/vite with changes:
34-
// - dts removed ensureImportFileExtension
35-
// - dts removed dts beforeWriteFile
3655
// - dts outDir: dist/types
3756
// - build - lib - fileName: [name.mjs]
3857
// - rollup - output - preserveModulesRoot: src
@@ -56,6 +75,14 @@ export const tanstackViteConfig = (options: Options) => {
5675
module: 99, // ESNext
5776
declarationMap: false,
5877
},
78+
beforeWriteFile: (filePath, content) => {
79+
// content =
80+
// options.beforeWriteDeclarationFile?.(filePath, content) || content
81+
return {
82+
filePath,
83+
content: ensureImportFileExtension({ content, extension: 'js' }),
84+
}
85+
},
5986
afterDiagnostic: (diagnostics) => {
6087
if (diagnostics.length > 0) {
6188
console.error('Please fix the above type errors')
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", "no-resolution"]
2+
"ignoreRules": ["cjs-resolves-to-esm"]
33
}

0 commit comments

Comments
 (0)