microsoft / microsoft/TypeScript
`importHelpers` generates code, that is incompatible with browsers
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Currently enabling importHelpers adds
import * as tslib_1 from "tslib";
at the top of every source file.
Such notation is not compatible with browsers. Nowadays, all modern browsers supports Ecma modules, there's no reason for writing code that assumes Node.js environment + bundler build. Code should assume "Ecma modules" environment instead. And bundlers can stop being compilers and do the work they are supposed to do - create optimized builds (if needed at all).
The change is simple, importHelpers should generate:
import * as tslib_1 from "../../../node_modules/tslib/index.js";
The path to "node_modules" should be determined at compile time of course.
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 tracing the TypeScript compiler code that emits the importHelpers tslib import. Compare the current module specifier with the requested browser-compatible path, then verify that the generated import resolves from an Ecma modules environment and that the node_modules path is determined at compile time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100