Provide TypeScript as an ESM #32949
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Search Terms
commonjs, esm, lib/typescript
Suggestion
Currently
lib/typescript.js
and otherlib
files do not support being loaded as ES modules. They only support loading as a global script or a CommonJS module.Use Cases
For runtimes that want to load TypeScript as a module and not in the global namespace, they have to do some pre-processing using a packager like webpack, rollup, etc. to be able to load TypeScript as an ES Module.
In addition, there are useful CDNs like Pike which can parse npm packages, find the ES modules, and will host an optimised version designed for loading in greenfield modern/browsers.
Examples
For example, it is impossible to currently load
lib/typescript.js
in Deno as it only supports ESM and eachimport
is assumed to be a module, and therefore thevar ts
is scoped to the module. Also loading directly as a module in a browser would be possible.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: