| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Andrew Branch (@andrewbranch) why does bundler apply the node export condition by default? I've been trying to make a package with conditional exports that use node-fetch types for fetch, Response etc in node and Web API types otherwise, and it would be a lot easier to provide a good user experience if bundler, or some other mode, would not apply the node export condition. Because the only option is to tell users to set customConditions. And node condition seems like a weird default for bundler since it's more common for bundlers to be used to deploy to web environments than to Node. |
Sorry, something went wrong.
|
It doesn’t; #52940 removed it. I’ll update the PR description since docs still aren’t on the website (😬) |
Sorry, something went wrong.
|
Okay great! Thanks for letting me know |
Sorry, something went wrong.
|
Andy Edwards (@jedwards1211) No problem. I assume you’re aware that Webpack, and I assume other bundlers too, do apply the node condition even though they’re not Node 🤦🏻♂️ |
Sorry, something went wrong.
|
Andrew Branch (@andrewbranch) so I've learned recently...and even Deno does, somewhat surprisingly |
Sorry, something went wrong.
|
I found this setting fixed a long running problem I had (yay!). In trying to learn more about it I checked out https://www.typescriptlang.org/tsconfig#moduleResolution , https://www.typescriptlang.org/docs/handbook/modules.html , and https://www.typescriptlang.org/docs/handbook/module-resolution.html and none of them cover it. What's the best reference for details (this PR discussion is rather long)? Hopefully the docs will be updated soon. Thanks! |
Sorry, something went wrong.
The release notes for TypeScript 5.0 recommend using "bundler" when using tools like Vite, esbuild, Webpack, and so on. - Docs (which unfortunately don't say much): https://www.typescriptlang.org/tsconfig#moduleResolution - See also this PR: microsoft/TypeScript#51669
| Back | FazBrowse Home | New Git URL |
This PR introduces a new moduleResolution setting value called hybrid bundler (see #51714), designed primarily for bundlers and runtimes that include a range of Node-like resolution features and ESM syntax, but do not enforce the strict resolution rules that accompany ES modules in Node or in the browser. Special consideration has also been given for bundlers and runtimes that understand TypeScript natively and do not require compilation to JavaScript by tsc before consumption. Additionally, resolution of package.json exports and imports can be enabled/disabled/customized in configuration options. This should allow users of different bundlers and runtimes with slight variations in resolution features to customize TypeScript’s resolution settings under bundler as appropriate.
Who should use this mode?
Comparison with existing module resolution settings
import from ESM,
require from CJS;
custom additions
custom additions
Module syntax restrictions
--moduleResolution bundler does not support resolution of require calls. In TypeScript files, this means the import mod = require("foo") syntax is forbidden; in JavaScript files, require calls are not errors but only ever return the type any (or whatever an ambient declaration of a global require function is declared to return).
New compiler options
Open questions