-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
729c6b1
commit 6ca8cbc
Showing
15 changed files
with
322 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
"generator-single-spa": major | ||
"ts-config-single-spa": major | ||
--- | ||
|
||
For typescript projects, automatically emit types during `build`. | ||
|
||
# Migrating | ||
|
||
The create-single-spa api for generating new typescript projects did not change. However, to upgrade existing projects, do the following: | ||
|
||
1. Update your package.json. Make sure to replace `<%= packageManager %>` with either `npm`, `yarn`, or `pnpm` | ||
|
||
```diff | ||
{ | ||
"scripts": { | ||
- "build": "webpack --mode=production", | ||
+ "build": "concurrently <%= packageManager %>:build:*", | ||
+ "build:webpack": "webpack --mode=production", | ||
+ "build:types": "tsc" | ||
} | ||
} | ||
``` | ||
|
||
2. Update your tsconfig.json. Make sure to replace `<%= mainFile %>` with the proper value. This is in the format `org-project.ts`. React projects should have the `.tsx` file extension | ||
|
||
```diff | ||
{ | ||
"compilerOptions": { | ||
+ "declarationDir": "dist" | ||
}, | ||
+ "files": ["src/<%= mainFile %>"] | ||
- "include": ["src/**/*", "node_modules/@types"], | ||
+ "include": ["src/**/*"] | ||
} | ||
``` | ||
|
||
3. Add the `"types"` property to your package.json: | ||
|
||
```diff | ||
{ | ||
+ "types": "dist/<%= mainFile %>.d.ts" | ||
} | ||
``` | ||
|
||
4. Upgrade `ts-config-single-spa` to the latest 3.x release, which has new configuration for emitting types. | ||
|
||
```sh | ||
npm install --save-dev ts-config-single-spa@^3.0.0 | ||
|
||
pnpm install --save-dev ts-config-single-spa@^3.0.0 | ||
|
||
yarn add --dev ts-config-single-spa@^3.0.0 | ||
``` | ||
|
||
5. Now run `npm run build` or `npm run build:types` and verify that a typescript declaration file is outputted to your `dist` directory. Verify that the output file name is the same as the `"types"` property in your package.json. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
packages/generator-single-spa/src/react/templates/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{ | ||
"extends": "ts-config-single-spa", | ||
"compilerOptions": { | ||
"jsx": "react-jsx" | ||
"jsx": "react-jsx", | ||
"declarationDir": "dist" | ||
}, | ||
"include": ["src/**/*", "node_modules/@types"], | ||
"files": ["<%- mainFile %>"], | ||
"include": ["src/**/*"], | ||
"exclude": ["src/**/*.test*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
packages/generator-single-spa/src/root-config/templates/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"extends": "ts-config-single-spa", | ||
"include": ["src/**/*", "node_modules/@types"], | ||
"files": ["<%- mainFile %>"], | ||
"compilerOptions": { | ||
"declarationDir": "dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["src/**/*.test*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
packages/generator-single-spa/src/util-module/templates/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"extends": "ts-config-single-spa", | ||
"include": ["src/**/*", "node_modules/@types"], | ||
"files": ["<%= mainFile %>"], | ||
"compilerOptions": { | ||
"declarationDir": "dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["src/**/*.test*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"es2016.array.include", | ||
"es2018" | ||
], | ||
"noEmit": true | ||
"declaration": true, | ||
"emitDeclarationOnly": true | ||
} | ||
} |
Oops, something went wrong.