Skip to content

Commit cec3edc

Browse files
committed
@app/components, @app/lib, @app/graphql -> source first
Tell Next.js to build @app/components, @app/lib, and @app/graphql from source, rather than pulling artifacts from their dist/ directories. This is a slightly more vanilla setup and hopefully will get us out of a jam come Next 15.
1 parent d68ba46 commit cec3edc

File tree

19 files changed

+78
-65
lines changed

19 files changed

+78
-65
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
node_modules
22
**/dist
3+
@app/*/types
34
/data/schema.graphql
45
/data/schema.sql
56
/@app/graphql/index.*
7+
/@app/graphql/src
68
/@app/client/.next
79
.next

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
.next
33
node_modules
44
dist
5+
@app/*/types/**
56
/heroku-setup
67
/yarn-error.log
78
/@app/e2e/cypress/videos
89
/@app/e2e/cypress/screenshots
910
/@app/graphql/index.*
11+
/@app/graphql/src/index.*
1012
.agignore
1113
*.tsbuildinfo
1214
.ethereal

@app/client/src/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ if (!process.env.ROOT_URL) {
2121
// config bloat in next.js 15
2222
// https://nextjs.org/docs/15/pages/api-reference/config/next-config-js/bundlePagesRouterDependencies
2323
transpilePackages: [
24+
"@app/components",
25+
"@app/graphql",
26+
"@app/lib",
2427
"@ant-design/icons",
2528
"@ant-design/icons-svg",
2629
"rc-cascader",

@app/client/src/tsconfig.json

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,18 @@
33
"compilerOptions": {
44
"composite": false,
55
"incremental": false,
6-
"target": "es5",
7-
"lib": [
8-
"dom",
9-
"dom.iterable",
10-
"esnext"
11-
],
6+
"target": "es2024",
7+
"lib": ["es2024", "dom", "dom.iterable"],
128
"noEmit": true,
139
"esModuleInterop": true,
1410
"declaration": false,
1511
"declarationMap": false,
1612
"isolatedModules": true,
1713
"module": "esnext",
18-
"moduleResolution": "node"
14+
"moduleResolution": "bundler"
1915
},
20-
"exclude": [
21-
"node_modules"
22-
],
23-
"include": [
24-
"next-env.d.ts",
25-
"**/*.ts",
26-
"**/*.tsx"
27-
],
16+
"exclude": ["node_modules"],
17+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
2818
"references": [
2919
{
3020
"path": "../../config"

@app/components/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ that Next.js depends upon.
55

66
## Compilation
77

8-
Note that these components are compiled to on-disk JS in the same way as the
9-
other packages (except client) so that Next.js can require them as if they were
10-
regular NPM dependencies (thus Next does not need to know about monorepos, or
11-
how to transpile this code).
8+
Note that these components are not compiled to on-disk JS in the same way as the
9+
other packages. `tsc -b` only generates types declarations into /types. This is
10+
because we delegate responsibility for compiling the sources to Next.js, which
11+
is opinionated about optimizing the dependency graph.

@app/components/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"name": "@app/components",
33
"version": "0.0.0",
4-
"main": "dist/index.js",
54
"type": "module",
5+
"types": "types/index.d.ts",
6+
"exports": {
7+
".": {
8+
"types": "./types/index.d.ts",
9+
"default": "./src/index.tsx"
10+
}
11+
},
612
"scripts": {
713
"build": "tsc -b",
814
"test": "cross-env NODE_ENV=test NODE_OPTIONS=\"${NODE_OPTIONS:-} --require @app/config/env\" jest"

@app/components/tsconfig.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"noEmit": false,
5+
"emitDeclarationOnly": true,
56
"rootDir": "src",
6-
"outDir": "dist",
7-
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
8-
"declarationDir": "dist",
9-
"lib": ["dom", "dom.iterable", "esnext"],
10-
"target": "es5",
7+
"declarationDir": "types",
8+
"declarationMap": false,
9+
"tsBuildInfoFile": "types/tsconfig.tsbuildinfo",
10+
"target": "es2024",
11+
"lib": ["es2024", "dom", "dom.iterable"],
12+
"jsx": "preserve",
1113
"module": "esnext",
12-
"moduleResolution": "bundler",
13-
"jsx": "react"
14+
"moduleResolution": "bundler"
1415
},
1516
"include": ["src/**/*.ts", "src/**/*.tsx"],
1617
"references": [
1718
{
1819
"path": "../graphql"
19-
},
20-
{
21-
"path": "../lib"
2220
}
2321
]
2422
}

@app/config/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"outDir": "dist",
77
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
88
"declarationDir": "dist",
9-
"lib": ["es2018", "esnext.asynciterable"],
10-
"target": "es2018"
9+
"lib": ["es2024"],
10+
"target": "es2024"
1111
},
1212
"include": ["src"]
1313
}

@app/e2e/cypress/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"esModuleInterop": true,
44
"strict": true,
55
"baseUrl": "node_modules",
6-
"target": "es5",
7-
"lib": ["es5", "dom"],
6+
"target": "es2024",
7+
"lib": ["es2024", "dom"],
88
"types": ["cypress"]
99
},
1010
"include": ["**/*.ts"]

@app/graphql/codegen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config:
1515
withHooks: true
1616
reactApolloVersion: 3
1717
generates:
18-
index.tsx:
18+
src/index.tsx:
1919
plugins:
2020
- add:
2121
content: "/* DO NOT EDIT! This file is auto-generated by graphql-code-generator - see `codegen.yml` */"

0 commit comments

Comments
 (0)