Skip to content

Commit a6ee325

Browse files
Enhance TypeScript configuration for react-on-rails packages
- Added declaration and declarationMap options in tsconfig.json for better type definitions. - Updated build scripts in package.json files to remove unnecessary --declaration flag. - Adjusted file patterns in package.json to include both .js and .d.ts files. - Introduced a new tsconfig.json for the react-on-rails package to manage its own build settings. These changes improve type declaration handling and streamline the build process across packages.
1 parent e5abac1 commit a6ee325

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

packages/react-on-rails-pro/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "React on Rails Pro package with React Server Components support",
55
"type": "module",
66
"scripts": {
7-
"build": "yarn run clean && ../../node_modules/.bin/tsc --project tsconfig.json --declaration",
8-
"build-watch": "yarn run clean && ../../node_modules/.bin/tsc --project tsconfig.json --watch",
7+
"build": "yarn run clean && yarn run tsc",
8+
"build-watch": "yarn run clean && yarn run tsc --watch",
99
"clean": "rm -rf ./lib",
1010
"test": "jest tests",
11-
"type-check": "../../node_modules/.bin/tsc --project tsconfig.json --noEmit --noErrorTruncation",
11+
"type-check": "yarn run tsc --noEmit --noErrorTruncation",
1212
"prepack": "nps build.prepack",
1313
"prepare": "nps build.prepack",
1414
"prepublishOnly": "yarn run build"
@@ -57,7 +57,8 @@
5757
}
5858
},
5959
"files": [
60-
"lib"
60+
"lib/**/*.js",
61+
"lib/**/*.d.ts"
6162
],
6263
"bugs": {
6364
"url": "https://github.com/shakacode/react_on_rails/issues"

packages/react-on-rails-pro/tsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./src",
6-
"declaration": true,
7-
"declarationMap": true,
8-
"sourceMap": true,
9-
"allowSyntheticDefaultImports": true,
10-
"incremental": true,
11-
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"
4+
"outDir": "./lib"
125
},
136
"include": ["src/**/*"],
147
"exclude": ["node_modules", "lib", "tests"]

packages/react-on-rails/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "lib/ReactOnRails.full.js",
66
"type": "module",
77
"scripts": {
8-
"build": "yarn run clean && yarn run tsc --declaration",
8+
"build": "yarn run clean && yarn run tsc",
99
"build-watch": "yarn run clean && yarn run tsc --watch",
1010
"clean": "rm -rf ./lib",
1111
"test": "jest tests",
@@ -68,7 +68,8 @@
6868
}
6969
},
7070
"files": [
71-
"lib"
71+
"lib/**/*.js",
72+
"lib/**/*.d.ts"
7273
],
7374
"bugs": {
7475
"url": "https://github.com/shakacode/react_on_rails/issues"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./lib"
5+
},
6+
"include": ["src/**/*"],
7+
"exclude": ["node_modules", "lib", "tests"]
8+
}

tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
"compilerOptions": {
44
"allowJs": true,
55
"esModuleInterop": false,
6+
"declaration": true,
7+
"declarationMap": true,
68
// needed for Jest tests even though we don't use .tsx
79
"jsx": "react-jsx",
810
"lib": ["dom", "es2020"],
911
"noImplicitAny": true,
10-
"outDir": "packages/react-on-rails/lib",
1112
"allowImportingTsExtensions": true,
1213
"rewriteRelativeImportExtensions": true,
1314
"strict": true,
15+
"sourceMap": true,
1416
"incremental": true,
1517
"target": "es2020",
1618
"typeRoots": ["./node_modules/@types"]
17-
},
18-
"include": ["packages/react-on-rails/src/**/*"]
19+
}
1920
}

0 commit comments

Comments
 (0)