Skip to content

Commit 8e92c7f

Browse files
committed
DO-1802: Fix changeset publishing by switching to in-place builds
- Change TypeScript compilation to build in-place within packages/ instead of separate dist/ folder - Update all tsconfig.app.json files to use outDir: "." and rootDir: "." - Update all Nx project.json build targets to use direct tsc compilation - Add .gitignore files to exclude compiled JS/d.ts files from version control - Add .npmignore files to exclude TypeScript source files from published packages - Update root .gitignore to globally exclude compiled artifacts This fixes the issue where changeset was publishing raw TypeScript source files instead of compiled JavaScript, which happened because changeset doesn't support building to separate dist directories. Version 2.13.0 of prerender-fargate was broken because it contained .ts files instead of .js files. The new workflow: - Development: Work with TypeScript source files (tracked in git) - Build: Compile TypeScript in-place within packages/ - Publish: Changeset publishes compiled JS (source excluded by .npmignore) - Git: Compiled files excluded from version control
1 parent 213e50e commit 8e92c7f

File tree

27 files changed

+141
-132
lines changed

27 files changed

+141
-132
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
node_modules/
88
dist/
99

10+
# Compiled JavaScript files in packages (built in-place)
11+
packages/**/*.js
12+
packages/**/*.d.ts
13+
packages/**/*.js.map
14+
15+
# But keep specific files that should be tracked
16+
!packages/**/lib/handlers/**/*.js
17+
!packages/**/lib/prerender/**/*.js
18+
1019
# Yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
1120
.yarn/*
1221
!.yarn/cache

packages/basic-auth/project.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
"projectType": "application",
66
"targets": {
77
"build": {
8-
"executor": "@nx/js:tsc",
8+
"executor": "nx:run-commands",
99
"options": {
10-
"main": "packages/basic-auth/index.ts",
11-
"outputPath": "dist/basic-auth",
12-
"tsConfig": "packages/basic-auth/tsconfig.app.json",
13-
"assets": [
14-
"packages/basic-auth/lib/handlers/**",
15-
"packages/basic-auth/README.md"
16-
]
10+
"command": "tsc --project tsconfig.app.json",
11+
"cwd": "packages/basic-auth"
1712
},
1813
"dependsOn": ["merge-gitignore"]
1914
},
@@ -30,7 +25,11 @@
3025
}
3126
},
3227
"publish": {
33-
"command": "node tools/scripts/publish.mjs basic-auth {args.ver} {args.tag}",
28+
"executor": "nx:run-commands",
29+
"options": {
30+
"command": "npm publish --access public",
31+
"cwd": "packages/basic-auth"
32+
},
3433
"dependsOn": ["build"]
3534
},
3635
"merge-gitignore": {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../../dist/out-tsc",
4+
"outDir": ".",
5+
"rootDir": ".",
56
"module": "commonjs",
67
"types": ["node"]
78
},
8-
"exclude": ["./jest.config.ts", "lib/handlers"],
9+
"exclude": ["./jest.config.ts", "lib/handlers", "**/*.test.ts", "**/*.spec.ts"],
910
"include": ["lib/**/*.ts", "index.ts"]
1011
}

packages/cloudfront-security-headers/project.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
"projectType": "application",
66
"targets": {
77
"build": {
8-
"executor": "@nx/js:tsc",
8+
"executor": "nx:run-commands",
99
"options": {
10-
"main": "packages/cloudfront-security-headers/index.ts",
11-
"outputPath": "dist/cloudfront-security-headers",
12-
"tsConfig": "packages/cloudfront-security-headers/tsconfig.app.json",
13-
"assets": [
14-
"packages/cloudfront-security-headers/lib/handlers/**",
15-
"packages/cloudfront-security-headers/README.md"
16-
]
10+
"command": "tsc --project tsconfig.app.json",
11+
"cwd": "packages/cloudfront-security-headers"
1712
},
1813
"dependsOn": ["merge-gitignore"]
1914
},
@@ -30,7 +25,11 @@
3025
}
3126
},
3227
"publish": {
33-
"command": "node tools/scripts/publish.mjs cloudfront-security-headers {args.ver} {args.tag}",
28+
"executor": "nx:run-commands",
29+
"options": {
30+
"command": "npm publish --access public",
31+
"cwd": "packages/cloudfront-security-headers"
32+
},
3433
"dependsOn": ["build"]
3534
},
3635
"merge-gitignore": {

packages/cloudfront-security-headers/tsconfig.app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../../dist/out-tsc",
4+
"outDir": ".",
5+
"rootDir": ".",
56
"module": "commonjs",
67
"types": ["node"]
78
},

packages/esbuild/project.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
"projectType": "application",
66
"targets": {
77
"build": {
8-
"executor": "@nx/js:tsc",
8+
"executor": "nx:run-commands",
99
"options": {
10-
"main": "packages/esbuild/index.ts",
11-
"outputPath": "dist/esbuild",
12-
"tsConfig": "packages/esbuild/tsconfig.app.json",
13-
"assets": ["packages/esbuild/README.md"]
14-
},
15-
"dependsOn": ["merge-gitignore"]
10+
"command": "tsc --project tsconfig.app.json",
11+
"cwd": "packages/esbuild"
1612
},
1713
"lint": {
1814
"executor": "@nx/eslint:lint",
@@ -27,7 +23,11 @@
2723
}
2824
},
2925
"publish": {
30-
"command": "node tools/scripts/publish.mjs esbuild {args.ver} {args.tag}",
26+
"executor": "nx:run-commands",
27+
"options": {
28+
"command": "npm publish --access public",
29+
"cwd": "packages/esbuild"
30+
},
3131
"dependsOn": ["build"]
3232
},
3333
"merge-gitignore": {

packages/esbuild/tsconfig.app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../../dist/out-tsc",
4+
"outDir": ".",
5+
"rootDir": ".",
56
"module": "commonjs",
67
"types": ["node"]
78
},

packages/feature-env-handlers/project.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
"projectType": "application",
66
"targets": {
77
"build": {
8-
"executor": "@nx/js:tsc",
8+
"executor": "nx:run-commands",
99
"options": {
10-
"main": "packages/feature-env-handlers/index.ts",
11-
"outputPath": "dist/feature-env-handlers",
12-
"tsConfig": "packages/feature-env-handlers/tsconfig.app.json",
13-
"assets": [
14-
"packages/feature-env-handlers/README.md",
15-
"packages/feature-env-handlers/docs/**"
16-
]
10+
"command": "tsc --project tsconfig.app.json",
11+
"cwd": "packages/feature-env-handlers"
1712
},
1813
"dependsOn": ["merge-gitignore"]
1914
},
@@ -30,7 +25,11 @@
3025
}
3126
},
3227
"publish": {
33-
"command": "node tools/scripts/publish.mjs feature-env-handlers {args.ver} {args.tag}",
28+
"executor": "nx:run-commands",
29+
"options": {
30+
"command": "npm publish --access public",
31+
"cwd": "packages/feature-env-handlers"
32+
},
3433
"dependsOn": ["build"]
3534
},
3635
"merge-gitignore": {

packages/feature-env-handlers/tsconfig.app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../../dist/out-tsc",
4+
"outDir": ".",
5+
"rootDir": ".",
56
"module": "commonjs",
67
"types": ["node"]
78
},

packages/geoip-redirect/project.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55
"projectType": "application",
66
"targets": {
77
"build": {
8-
"executor": "@nx/js:tsc",
8+
"executor": "nx:run-commands",
99
"options": {
10-
"main": "packages/geoip-redirect/index.ts",
11-
"outputPath": "dist/geoip-redirect",
12-
"tsConfig": "packages/geoip-redirect/tsconfig.app.json",
13-
"assets": [
14-
"packages/geoip-redirect/lib/handlers/**",
15-
"packages/geoip-redirect/README.md"
16-
]
10+
"command": "tsc --project tsconfig.app.json",
11+
"cwd": "packages/geoip-redirect"
1712
},
1813
"dependsOn": ["merge-gitignore"]
1914
},
@@ -30,7 +25,11 @@
3025
}
3126
},
3227
"publish": {
33-
"command": "node tools/scripts/publish.mjs geoip-redirect {args.ver} {args.tag}",
28+
"executor": "nx:run-commands",
29+
"options": {
30+
"command": "npm publish --access public",
31+
"cwd": "packages/geoip-redirect"
32+
},
3433
"dependsOn": ["build"]
3534
},
3635
"merge-gitignore": {

0 commit comments

Comments
 (0)