Skip to content

Commit

Permalink
chore: Let the different tsconfig share the paths (#1980)
Browse files Browse the repository at this point in the history
Except for reflect-server which cannot reference replicache because then
we end up pulling in DOM types that are not present on the server.
  • Loading branch information
arv authored Jun 6, 2024
1 parent 8777782 commit e98f00d
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 61 deletions.
10 changes: 1 addition & 9 deletions apps/zeppliear/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"@rocicorp/zql": ["../../packages/zql/src/mod.ts"],
"@rocicorp/zql/src/*": ["../../packages/zql/src/*"],
"shared/src/*": ["../../packages/shared/src/*"],
"zero-client": ["../../packages/zero-client/src/mod.ts"],
"replicache": ["../../packages/replicache/src/mod.ts"],
"replicache/src/*": ["../../packages/replicache/src/*"]
}
"jsx": "react-jsx"
},
"references": [{"path": "./tsconfig.node.json"}],
"include": ["src"]
Expand Down
5 changes: 3 additions & 2 deletions apps/zeppliear/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {defineConfig} from 'vite';
import react from '@vitejs/plugin-react';
import {defineConfig} from 'vite';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [svgr(), react()],
plugins: [tsconfigPaths(), svgr(), react()],
build: {
target: 'esnext',
},
Expand Down
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions packages/datadog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"check-types": "tsc --noEmit",
"format": "prettier --write *",
"check-format": "prettier --check *",
"lint": "eslint --ext .ts,.tsx,.js,.jsx src/",
"build": "tsc"
},
"exports": {
".": "./out/mod.js",
"./src/mod.js": "./out/mod.js"
"lint": "eslint --ext .ts,.tsx,.js,.jsx src/"
},
"eslintConfig": {
"extends": "@rocicorp/eslint-config"
Expand Down
13 changes: 1 addition & 12 deletions packages/reflect-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["dom", "es2022"],
"paths": {
"replicache": ["../replicache/src/mod.ts"],
"replicache/src/*": ["../replicache/src/*"],
"shared/src/*": ["../shared/src/*"],
"reflect-shared": ["../reflect-shared/src/mod.ts"],
"reflect-shared/src/*": ["../reflect-shared/src/*"],
"datadog": ["../datadog/src/mod.ts"],
"datadog/src/*": ["../datadog/src/*"],
"reflect-protocol": ["../reflect-protocol/src/mod.ts"],
"reflect-protocol/src/*": ["../reflect-protocol/src/*"]
}
"lib": ["dom", "es2022"]
},
"include": ["src/**/*.ts"]
}
5 changes: 4 additions & 1 deletion packages/reflect-react/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {makeInputOptions} from 'shared/src/tool/rollup-dts.js';

export default makeInputOptions('out/.dts/mod.d.ts', 'out/reflect-react.d.ts');
export default makeInputOptions(
'out/.dts/reflect-react/src/mod.d.ts',
'out/reflect-react.d.ts',
);
2 changes: 1 addition & 1 deletion packages/reflect-server/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeInputOptions} from 'shared/src/tool/rollup-dts.js';

export default makeInputOptions(
'out/.dts/src/mod.d.ts',
'out/.dts/reflect-server/src/mod.d.ts',
'out/reflect-server.d.ts',
);
11 changes: 10 additions & 1 deletion packages/reflect-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["es2022"],
"types": ["@cloudflare/workers-types"]
"types": ["@cloudflare/workers-types"],
"baseUrl": "../",
"paths": {
"cf-shared/src/*": ["cf-shared/src/*"],
"datadog": ["datadog/src/mod.ts"],
"reflect-shared/src/*": ["reflect-shared/src/*"],
"reflect-protocol": ["reflect-protocol/src/mod.ts"],
"reflect-protocol/src/*": ["reflect-protocol/src/*"],
"shared/src/*": ["shared/src/*"]
}
},
"include": ["**/*.ts"]
}
6 changes: 0 additions & 6 deletions packages/reflect-shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"paths": {
"replicache": ["../replicache/src/mod.ts"],
"replicache/src/*": ["../replicache/src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.js"]
}
5 changes: 1 addition & 4 deletions packages/replicache/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["dom", "es2022"],
"paths": {
"shared/src/*": ["../shared/src/*"]
}
"lib": ["dom", "es2022"]
},
"include": ["src/**/*.ts"]
}
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@vitest/browser": "^1.5.2",
"fast-check": "^3.18.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-tsconfig-paths": "^1.5.2",
"typescript": "^5.4.2",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.5.2"
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/tool/jest-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const jestConfig = {
},
moduleNameMapper: {
'^cf-shared/(.*)\\.js$': '<rootDir>/../../packages/cf-shared/$1',
'^datadog$': '<rootDir>/../../packages/datadog/src/mod.ts',
'^datadog/(.*)\\.js$': '<rootDir>/../../packages/datadog/$1',
'^shared/(.*)\\.js$': '<rootDir>/../../packages/shared/$1',
'^reflect-shared/(.*)\\.js$': '<rootDir>/../../packages/reflect-shared/$1',
'^reflect-protocol/(.*)\\.js$':
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/tool/rollup-dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {nodeResolve} from '@rollup/plugin-node-resolve';
import dts from 'rollup-plugin-dts';
import tsConfigPaths from 'rollup-plugin-tsconfig-paths';

// We only use rollup for creating a bundled d.ts file.
// We use esbuild for building the actual code.
Expand All @@ -20,6 +21,7 @@ export function makeInputOptions(input, outputFile) {
},
external: ['@rocicorp/lock', '@rocicorp/logger', '@rocicorp/resolver'],
plugins: [
tsConfigPaths(),
nodeResolve(),
dts({
respectExternal: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/zero-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"out"
],
"exports": {
".": "./out/zero-client.js"
".": "./src/mod.ts"
},
"eslintConfig": {
"extends": "@rocicorp/eslint-config"
Expand Down
12 changes: 1 addition & 11 deletions packages/zero-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["dom", "esnext"],
"paths": {
"@rocicorp/zql": ["../zql/src/mod.ts"],
"@rocicorp/zql/src/*": ["../zql/src/*"],
"datadog": ["../datadog/src/mod.ts"],
"replicache": ["../replicache/src/mod.ts"],
"replicache/src/*": ["../replicache/src/*"],
"shared/src/*": ["../shared/src/*"],
"zero-protocol": ["../zero-protocol/src/mod.ts"],
"zero-protocol/src/*": ["../zero-protocol/src/*"]
}
"lib": ["dom", "esnext"]
},
"include": ["src/**/*.ts"]
}
7 changes: 1 addition & 6 deletions packages/zql/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["ESNext.Array", "ESNext", "DOM"],
"paths": {
"zero-client/src/*": ["../zero-client/src/*"],
"replicache": ["../replicache/src/mod.ts"],
"replicache/src/*": ["../replicache/src/*"]
}
"lib": ["ESNext.Array", "ESNext", "DOM"]
},
"include": ["src/**/*.ts"]
}
22 changes: 21 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@
"resolveJsonModule": true,
"incremental": true,
"ignoreDeprecations": "5.0",
"skipLibCheck": true
"skipLibCheck": true,
"baseUrl": "./packages/",
"paths": {
"@rocicorp/zql": ["zql/src/mod.ts"],
"@rocicorp/zql/src/*": ["zql/src/*"],
"cf-shared/src/*": ["../cf-shared/src/*"],
"datadog": ["datadog/src/mod.ts"],
"datadog/src/*": ["datadog/src/*"],
"reflect-protocol": ["reflect-protocol/src/mod.ts"],
"reflect-protocol/src/*": ["reflect-protocol/src/*"],
"reflect-react": ["reflect-react/src/mod.ts"],
"reflect-shared": ["reflect-shared/src/mod.ts"],
"reflect-shared/src/*": ["reflect-shared/src/*"],
"replicache": ["replicache/src/mod.ts"],
"replicache/src/*": ["replicache/src/*"],
"shared/src/*": ["shared/src/*"],
"zero-client": ["zero-client/src/mod.ts"],
"zero-client/src/*": ["zero-client/src/*"],
"zero-protocol": ["zero-protocol/src/mod.ts"],
"zero-protocol/src/*": ["zero-protocol/src/*"]
}
}
}

0 comments on commit e98f00d

Please sign in to comment.