-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
tsconfig.json
support to tsc
plugin
Although I would love if the ecosystem was as mature for non-`tsconfig.json` projects compared to `tsconfig.json` projects, this just isn't the case: * VSCode works much better with a local `tsconfig.json` file (e.g. it complains about `replaceAll` not being a method because we haven't set the correct `lib`) * There is a maximum line length for `cmd` (8191) that can be quite limiting when passing a large number of files via the command line * There are certain `tsconfig.json` options that cannot be passed via the command line (e.g. `paths`) * Existing users will most likely have a `tsconfig.json` file and it is simpler for them to migrate to `ninjutsu-build` if they can reuse this * There are other tools, such as TypeDoc, that only work with a `tsconfig.json` file This commit adds support for a `tsconfig.json` file in the `makeTSCRule` and `makeTypeCheckRule`. Right now I am unsure whether to overload the `makeTSCRule` and `makeTypeCheckRule` or rename the existing ones to `makeTSCRuleNoConfig` and `makeTypeCheckRuleNoConfig` simplify the return types. I will test this change out in building `ninjutsu` itself and reevaluate.
- Loading branch information
1 parent
a743145
commit 0d68c2b
Showing
10 changed files
with
358 additions
and
71 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,3 @@ | ||
src | ||
entry.ts | ||
tsconfig.show.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
This tests the speed of `tsconfig.json` `files` vs `include` properties. | ||
|
||
Preferring `files` over `include` for performance is recommended in the | ||
[TypeScript wiki page on performance](https://github.com/microsoft/TypeScript/wiki/Performance#specifying-files). | ||
|
||
``` | ||
node create.mjs 10000 | ||
``` | ||
|
||
``` | ||
npx tsc --noEmit -p tsconfig.files.json | ||
``` | ||
|
||
``` | ||
npx tsc --noEmit -p tsconfig.include.json | ||
``` | ||
|
||
There starts being a difference after 10K files of ~1.5s on Windows (5s vs 6.5s). | ||
|
||
``` | ||
npx tsc --showConfig -p tsconfig.include.json > tsconfig.show.json | ||
``` | ||
|
||
A `tsconfig.json` file with both `files` and `include` takes about 5.2s. A little bit | ||
slower than `tsconfig.files.json` but not as much as `tsconfig.include.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; | ||
import { join } from "node:path/posix"; | ||
|
||
const limit = process.argv[2] ?? 100; | ||
|
||
rmSync("src", { recursive: true, force: true }); | ||
|
||
let entry = ""; | ||
for (let i = 0; i < limit; ++i) { | ||
const dir = join("src", ...i.toString()); | ||
if (!existsSync(dir)) { | ||
mkdirSync(dir, { recursive: true }); | ||
} | ||
writeFileSync(join(dir, "file.ts"), `export const var${i} = ${i};\n`); | ||
entry += `import { var${i} } from "./${dir}/file.js";\n`; | ||
} | ||
|
||
writeFileSync("entry.ts", entry); | ||
|
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,3 @@ | ||
{ | ||
"files": ["entry.ts"] | ||
} |
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,3 @@ | ||
{ | ||
"include": ["**/*.ts"] | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.