-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: improve tsconfig #180
base: main
Are you sure you want to change the base?
Conversation
|
…into improved-tsconfig
@@ -3,11 +3,15 @@ | |||
"noEmit": true, | |||
"module": "ESNext", | |||
"target": "ESNext", | |||
"moduleResolution": "node", | |||
"moduleResolution": "Bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bundler
is good for apps, but node16
is better for libraries. that's because bundler is more permissive about things like file endings, which is good for consuming a variety of libraries, but node16
is stricter, which is better when your library may be consumed by apps with a variety of different settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but in the end it will be changed by unbuild
. Do you think it's still worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with unbuild
or why they would do that. Ideally it shouldn't or there should be an option to configure it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unbuild
imports all the code and puts it in a single file, then minimizes it, so there is no import after it has been compiled. It means that the moduleResolution
won't have any impact after all.
This pull request includes updates to the tsconfig.json file, aligning it with modern development practices. The changes introduced are as follows:
Changes
"moduleResolution": "Bundler"
: This option is configured for use with bundlers. Unlike the Node.js resolution modes, this setting supports package.json "imports" and "exports" without requiring file extensions on relative paths in imports."moduleDetection": "force"
: Enabling this option ensures that every non-declaration file is treated as a module, providing a more consistent and predictable module handling approach."isolatedModules": true
: TypeScript will now issue warnings for code that might not be correctly interpreted by a single-file transpilation process, helping catch potential issues early in the development process."verbatimModuleSyntax": true
: Forces type imports to be flagged with atype
modifier. This is particularly useful for bundlers, as it signals upfront that the code won't be used as a value, allowing the bundler to exclude it from the generated JavaScript code."lib": ["ES2022"]
: Updated to include only APIs from ES2022, explicitly excluding DOM APIs.