microsoft / microsoft/TypeScript
Provide TypeScript as an ESM
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
commonjs, esm, lib/typescript
Suggestion
Currently lib/typescript.js and other lib 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 each import is assumed to be a module, and therefore the var ts is scoped to the module. Also loading directly as a module in a browser would be possible.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting lib/typescript.js and the other lib files mentioned in the issue, focusing on how they currently load as global scripts or CommonJS modules. Determine the ESM loading requirements for Deno and browsers; done means TypeScript can load directly as an ES module without preprocessing while existing JavaScript behavior remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100