diff --git a/.eslintignore b/.eslintignore index 826561b4..5e6de95f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,7 +1,9 @@ node_modules **/dist +@app/*/types /data/schema.graphql /data/schema.sql /@app/graphql/index.* +/@app/graphql/src /@app/client/.next .next diff --git a/.gitignore b/.gitignore index 81b889d4..61942f4b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,13 @@ .next node_modules dist +@app/*/types/** /heroku-setup /yarn-error.log /@app/e2e/cypress/videos /@app/e2e/cypress/screenshots /@app/graphql/index.* +/@app/graphql/src/index.* .agignore *.tsbuildinfo .ethereal diff --git a/@app/client/src/next.config.js b/@app/client/src/next.config.js index 55531301..af1966f8 100644 --- a/@app/client/src/next.config.js +++ b/@app/client/src/next.config.js @@ -21,6 +21,9 @@ if (!process.env.ROOT_URL) { // config bloat in next.js 15 // https://nextjs.org/docs/15/pages/api-reference/config/next-config-js/bundlePagesRouterDependencies transpilePackages: [ + "@app/components", + "@app/graphql", + "@app/lib", "@ant-design/icons", "@ant-design/icons-svg", "rc-cascader", diff --git a/@app/client/src/tsconfig.json b/@app/client/src/tsconfig.json index d8042ff9..e7379d52 100644 --- a/@app/client/src/tsconfig.json +++ b/@app/client/src/tsconfig.json @@ -3,28 +3,18 @@ "compilerOptions": { "composite": false, "incremental": false, - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "target": "es2024", + "lib": ["es2024", "dom", "dom.iterable"], "noEmit": true, "esModuleInterop": true, "declaration": false, "declarationMap": false, "isolatedModules": true, "module": "esnext", - "moduleResolution": "node" + "moduleResolution": "bundler" }, - "exclude": [ - "node_modules" - ], - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], + "exclude": ["node_modules"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "references": [ { "path": "../../config" diff --git a/@app/components/README.md b/@app/components/README.md index a5b54b5e..bd111cf5 100644 --- a/@app/components/README.md +++ b/@app/components/README.md @@ -5,7 +5,7 @@ that Next.js depends upon. ## Compilation -Note that these components are compiled to on-disk JS in the same way as the -other packages (except client) so that Next.js can require them as if they were -regular NPM dependencies (thus Next does not need to know about monorepos, or -how to transpile this code). +Note that these components are not compiled to on-disk JS in the same way as the +other packages. `tsc -b` only generates types declarations into /types. This is +because we delegate responsibility for compiling the sources to Next.js, which +is opinionated about optimizing the dependency graph. diff --git a/@app/components/package.json b/@app/components/package.json index b98d6ac2..3ebafbfd 100644 --- a/@app/components/package.json +++ b/@app/components/package.json @@ -1,8 +1,14 @@ { "name": "@app/components", "version": "0.0.0", - "main": "dist/index.js", "type": "module", + "types": "types/index.d.ts", + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./src/index.tsx" + } + }, "scripts": { "build": "tsc -b", "test": "cross-env NODE_ENV=test NODE_OPTIONS=\"${NODE_OPTIONS:-} --require @app/config/env\" jest" diff --git a/@app/components/tsconfig.json b/@app/components/tsconfig.json index 8bcbe8c3..d64b4891 100644 --- a/@app/components/tsconfig.json +++ b/@app/components/tsconfig.json @@ -2,23 +2,21 @@ "extends": "../../tsconfig.json", "compilerOptions": { "noEmit": false, + "emitDeclarationOnly": true, "rootDir": "src", - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", - "declarationDir": "dist", - "lib": ["dom", "dom.iterable", "esnext"], - "target": "es5", + "declarationDir": "types", + "declarationMap": false, + "tsBuildInfoFile": "types/tsconfig.tsbuildinfo", + "target": "es2024", + "lib": ["es2024", "dom", "dom.iterable"], + "jsx": "preserve", "module": "esnext", - "moduleResolution": "bundler", - "jsx": "react" + "moduleResolution": "bundler" }, "include": ["src/**/*.ts", "src/**/*.tsx"], "references": [ { "path": "../graphql" - }, - { - "path": "../lib" } ] } diff --git a/@app/config/tsconfig.json b/@app/config/tsconfig.json index 6c9b836d..e341af1c 100644 --- a/@app/config/tsconfig.json +++ b/@app/config/tsconfig.json @@ -6,8 +6,8 @@ "outDir": "dist", "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", "declarationDir": "dist", - "lib": ["es2018", "esnext.asynciterable"], - "target": "es2018" + "lib": ["es2024"], + "target": "es2024" }, "include": ["src"] } diff --git a/@app/e2e/cypress/tsconfig.json b/@app/e2e/cypress/tsconfig.json index f08407dd..b7cd3c16 100644 --- a/@app/e2e/cypress/tsconfig.json +++ b/@app/e2e/cypress/tsconfig.json @@ -3,8 +3,8 @@ "esModuleInterop": true, "strict": true, "baseUrl": "node_modules", - "target": "es5", - "lib": ["es5", "dom"], + "target": "es2024", + "lib": ["es2024", "dom"], "types": ["cypress"] }, "include": ["**/*.ts"] diff --git a/@app/graphql/codegen.yml b/@app/graphql/codegen.yml index e41b23e9..5b7bc42c 100644 --- a/@app/graphql/codegen.yml +++ b/@app/graphql/codegen.yml @@ -15,7 +15,7 @@ config: withHooks: true reactApolloVersion: 3 generates: - index.tsx: + src/index.tsx: plugins: - add: content: "/* DO NOT EDIT! This file is auto-generated by graphql-code-generator - see `codegen.yml` */" diff --git a/@app/graphql/package.json b/@app/graphql/package.json index 0b2b6f92..de4a4d58 100644 --- a/@app/graphql/package.json +++ b/@app/graphql/package.json @@ -3,8 +3,13 @@ "private": true, "version": "0.0.0", "type": "module", - "main": "index.js", - "types": "index.d.ts", + "types": "types/index.d.ts", + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./src/index.tsx" + } + }, "scripts": { "build": "yarn codegen && tsc -b", "watch": "yarn codegen --watch", diff --git a/@app/graphql/tsconfig.json b/@app/graphql/tsconfig.json index 84b2d8bb..e6e3502b 100644 --- a/@app/graphql/tsconfig.json +++ b/@app/graphql/tsconfig.json @@ -2,15 +2,16 @@ "extends": "../../tsconfig.json", "compilerOptions": { "noEmit": false, - "rootDir": ".", - "outDir": ".", - "tsBuildInfoFile": "tsconfig.tsbuildinfo", - "declarationDir": ".", - "lib": ["es2018", "esnext.asynciterable"], - "target": "es2018", - "jsx": "react", + "emitDeclarationOnly": true, + "rootDir": "src", + "declarationDir": "types", + "declarationMap": false, + "tsBuildInfoFile": "types/tsconfig.tsbuildinfo", + "lib": ["es2024"], + "target": "es2024", + "jsx": "preserve", "module": "esnext", "moduleResolution": "bundler" }, - "include": ["index.tsx"] + "include": ["src/**/*.ts", "src/**/*.tsx"] } diff --git a/@app/lib/README.md b/@app/lib/README.md index 0d41602b..4e4f1d01 100644 --- a/@app/lib/README.md +++ b/@app/lib/README.md @@ -4,7 +4,7 @@ Various utilities, mostly React hooks. ## Compilation -Note that these components are compiled to on-disk JS in the same way as the -other packages (except client) so that Next.js can require them as if they were -regular NPM dependencies (thus Next does not need to know about monorepos, or -how to transpile this code). +Note that these components are not compiled to on-disk JS in the same way as the +other packages. `tsc -b` only generates types declarations into /types. This is +because we delegate responsibility for compiling the sources to Next.js, which +is opinionated about optimizing the dependency graph. diff --git a/@app/lib/package.json b/@app/lib/package.json index 87acdbe5..48855abd 100644 --- a/@app/lib/package.json +++ b/@app/lib/package.json @@ -2,8 +2,13 @@ "name": "@app/lib", "version": "0.0.0", "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "types": "types/index.d.ts", + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./src/index.tsx" + } + }, "scripts": { "build": "tsc -b", "test": "cross-env NODE_ENV=test NODE_OPTIONS=\"${NODE_OPTIONS:-} --require @app/config/env\" jest" diff --git a/@app/lib/tsconfig.json b/@app/lib/tsconfig.json index ab54b2dd..834ac13c 100644 --- a/@app/lib/tsconfig.json +++ b/@app/lib/tsconfig.json @@ -2,13 +2,14 @@ "extends": "../../tsconfig.json", "compilerOptions": { "noEmit": false, + "emitDeclarationOnly": true, "rootDir": "src", - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", - "declarationDir": "dist", - "lib": ["dom", "dom.iterable", "esnext"], - "target": "es5", - "jsx": "react", + "declarationDir": "types", + "declarationMap": false, + "tsBuildInfoFile": "types/tsconfig.tsbuildinfo", + "lib": ["es2024", "dom", "dom.iterable"], + "target": "es2024", + "jsx": "preserve", "module": "esnext", "moduleResolution": "bundler" }, diff --git a/@app/server/tsconfig.json b/@app/server/tsconfig.json index 7f48c3cb..1a9a053d 100644 --- a/@app/server/tsconfig.json +++ b/@app/server/tsconfig.json @@ -6,8 +6,8 @@ "outDir": "dist", "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", "declarationDir": "dist", - "lib": ["es2018", "esnext.asynciterable"], - "target": "es2018" + "lib": ["es2024"], + "target": "es2024" }, "include": ["src"], "references": [{ "path": "../config" }, { "path": "../lib" }], diff --git a/@app/worker/tsconfig.json b/@app/worker/tsconfig.json index 739f968e..15213639 100644 --- a/@app/worker/tsconfig.json +++ b/@app/worker/tsconfig.json @@ -6,8 +6,8 @@ "outDir": "dist", "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", "declarationDir": "dist", - "lib": ["es2018", "esnext.asynciterable"], - "target": "es2018" + "lib": ["es2024"], + "target": "es2024" }, "include": ["src"], "references": [{ "path": "../config" }] diff --git a/production.Dockerfile b/production.Dockerfile index a39eecb9..ae75d181 100644 --- a/production.Dockerfile +++ b/production.Dockerfile @@ -42,8 +42,7 @@ COPY --from=builder /app/@app/config/ /app/@app/config/ COPY --from=builder /app/@app/db/ /app/@app/db/ COPY --from=builder /app/@app/graphql/ /app/@app/graphql/ COPY --from=builder /app/@app/lib/ /app/@app/lib/ -COPY --from=builder /app/@app/components/package.json /app/@app/components/ -COPY --from=builder /app/@app/components/dist/ /app/@app/components/dist/ +COPY --from=builder /app/@app/components/ /app/@app/components/ COPY --from=builder /app/@app/client/package.json /app/@app/client/package.json COPY --from=builder /app/@app/client/src/next.config.js /app/@app/client/src/next.config.js COPY --from=builder /app/@app/client/.next /app/@app/client/.next diff --git a/tsconfig.json b/tsconfig.json index 261ae0c0..38b3269a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,8 +8,8 @@ "allowSyntheticDefaultImports": true, "esModuleInterop": true, "jsx": "preserve", - "lib": ["dom", "es2017"], - "target": "esnext", + "lib": ["es2024", "dom"], + "target": "es2024", "module": "nodenext", "moduleResolution": "nodenext", "noFallthroughCasesInSwitch": true, @@ -42,6 +42,7 @@ { "path": "@app/config" }, { "path": "@app/components" }, { "path": "@app/graphql" }, + { "path": "@app/lib" }, { "path": "@app/server" }, { "path": "@app/worker" } ]