Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Mist3rBru
Copy link
Contributor

@Mist3rBru Mist3rBru commented Nov 28, 2023

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 a type 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.

Copy link

changeset-bot bot commented Nov 28, 2023

⚠️ No Changeset found

Latest commit: 28b067f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -3,11 +3,15 @@
"noEmit": true,
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"moduleResolution": "Bundler",

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

Copy link
Contributor Author

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?

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

Copy link
Contributor Author

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.

@Mist3rBru Mist3rBru closed this Jun 27, 2024
@Mist3rBru Mist3rBru reopened this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants