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

Provide TypeScript as an ESM #32949

Open
5 tasks done
kitsonk opened this issue Aug 17, 2019 · 0 comments
Open
5 tasks done

Provide TypeScript as an ESM #32949

kitsonk opened this issue Aug 17, 2019 · 0 comments
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

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Aug 17, 2019

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants