microsoft / microsoft/TypeScript
Write typescript as modules, but output js without modules
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
Searched the whole internet for anything like it, only webpack and browserify related 'solutions' are proposed.
Suggestion
Split module options in tsconfig so typescript modules could be set separately from output target modules.
Use Cases
Our usecase:
- We have a huge codebase, and we want to slowly move to typescript.
- We have a sophisticated build system that we don't want to change - we want typescript to transpile to js and to take js and continue to use it as we were.
- We don't need nor want to use modules in js. We never used modules - we have our system of imports, minification,
versioning, caching, etc. - The only reason why we need to use modules in typescript is tsc incremental watch build. With no modules, it builds complete codebase on each change. We want to build only file changed and dependent files.
So currently we have two bad options - don't use modules (unacceptably slow build time) or use modules (get the output that we don't want). Currently we 'mitigate' the issue by removing parts of js tsc has output (removing stuff we recognize as related to exports and require), but that's just terrible.
Even worse, even if we were to use modules, require / exports are inlined even in output we want to inline to index.html as critical JS...
Examples
I guess I explained it all above.
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 reviewing the tsconfig module options and the incremental watch-build behavior described in the issue. Determine how separate source-module and emitted-module settings should interact, then verify that TypeScript can emit non-module JavaScript while retaining module-based incremental builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- build-system, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100