René's URL Explorer Experiment


Title: Do not check in the `transpileModule` API · Issue #50699 · microsoft/TypeScript · GitHub

Open Graph Title: Do not check in the `transpileModule` API · Issue #50699 · microsoft/TypeScript

X Title: Do not check in the `transpileModule` API · Issue #50699 · microsoft/TypeScript

Description: Suggestion 🔍 Search Terms transpileModule skip typechecking no typechecking Semi-related issues found: Skip typechecking; only emit (support --transpileOnly in tsc, re-open of #4176) #29651 [FEATURE REQUEST] Please supply a minified vers...

Open Graph Description: Suggestion 🔍 Search Terms transpileModule skip typechecking no typechecking Semi-related issues found: Skip typechecking; only emit (support --transpileOnly in tsc, re-open of #4176) #29651 [FEATUR...

X Description: Suggestion 🔍 Search Terms transpileModule skip typechecking no typechecking Semi-related issues found: Skip typechecking; only emit (support --transpileOnly in tsc, re-open of #4176) #29651 [FEATUR...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/50699

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Do not check in the `transpileModule` API","articleBody":"# Suggestion\r\n\r\n\u003c!--\r\n  Please fill in each section completely. Thank you!\r\n--\u003e\r\n\r\n## 🔍 Search Terms\r\n\r\n\u003c!--\r\n  💡 Did you know? TypeScript has over 2,000 open suggestions!\r\n  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.\r\n  The \"Common Feature Requests\" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests\r\n\r\n  Replace the text below:\r\n--\u003e\r\n\r\n-   `transpileModule`\r\n-   `skip typechecking`\r\n-   `no typechecking`\r\n\r\nSemi-related issues found:\r\n\r\n-   Skip typechecking; only emit (support --transpileOnly in tsc, re-open of #4176) #29651\r\n-   [FEATURE REQUEST] Please supply a minified version with only transpilation functionality #9245\r\n-   Allow transformers to run without type-checking #41986\r\n\r\n## ✅ Viability Checklist\r\n\r\n\u003c!--\r\n   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.\r\n   We always recommend reviewing the TypeScript design goals before investing time writing\r\n   a proposal for ideas outside the scope of the project.\r\n--\u003e\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n-   [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n-   [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n-   [x] This could be implemented without emitting different JS based on the types of the expressions\r\n-   [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)\r\n-   [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n## ⭐ Suggestion\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed --\u003e\r\n\r\nModify the `transpileModule` API to mostly do the following:\r\n\r\n-   Parses a source string\r\n-   Runs the corresponding transforms to get to the target ES version\r\n-   Emits a resulting string with a sourceMap string\r\n\r\nThe API itself would be unchanged but would be guaranteed to not hit the type-checker if a certain set of compatible compiler options is set. (deoptimizing options TBD)\r\n\r\nAchieving this without modifying TypeScript is currently not possible with the current TypeScript API: there is currently no way to just apply the transforms without running the checker as a `Program` has to be created in the process.\r\n\r\nAlternatively, if changing `transpileModule` is not possible we would be interested in exposing more minimal API primitives so we could build up this API ourselves:\r\n\r\n-   A public `Printer` API that can issue sourcemaps\r\n-   A way to run transforms on TS ASTs without the need to build up a `Program` (and run the checker...)\r\n\r\n## 📃 Motivating Example\r\n\r\n\u003c!--\r\n  If you were announcing this feature in a blog post, what's a short explanation that shows\r\n  a developer why this feature improves the language?\r\n--\u003e\r\n\r\nIn our build system, for certain workflows, we introduced a new build mode that runs `transpileModule` instead of compiling and type-checking the full project. `transpileModule` is run on a per-file basis as we are reading files into our build stream, meaning there are no inter-file ordering dependencies.\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eApproximative `transpileModule` API usage\u003c/summary\u003e\r\n\r\n```ts\r\nconst result = ts.transpileModule(tsFileStr, {\r\n    compilerOptions, // \u003c- with an ESNext target\r\n    reportDiagnostics: true,\r\n    moduleName: tsFilePath,\r\n    fileName: tsFilePath,\r\n});\r\nif (result.diagnostics) {\r\n    // report syntax errors\r\n    if (result.diagnostics.length \u003e 0) {\r\n        return;\r\n    }\r\n}\r\nconst jsFilePath = tsFilePath.replace(/\\.tsx?$/, \".js\");\r\nconst jsFileStr = result.outputText;\r\nconst sourceMapPath = jsFilePath + \".map\";\r\nconst sourceMapStr = result.sourceMapText;\r\n// ...\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nWith this new mode, we managed to get 4x faster than an equivalent fully-typechecked build! This is an amazing speedup that is appreciated for running common workflows (while VSCode continues to type-check things in the editor).\r\n\r\nWe are still trying to get faster: most of the time is now spent type-checking inside `transpileModule`, as seen in the CPU flamecharts.\r\n\r\n![Screenshot 2022-09-08 at 13 47 40](https://user-images.githubusercontent.com/246520/189321406-d3753ba4-0c86-4150-8926-9f1ff6f67614.png)\r\n\r\nWe researched using alternative build tools such as [swc](https://swc.rs) or [esbuild](https://esbuild.github.io) but using their transpile API alone in our setup is not significantly better than using `transpileModule`! (I could do a writeup on this if anyone is interested in that research) However, those other tools do tend to get really fast when they are run standalone and handle file I/O but unfortunately this does not fit our use case.\r\n\r\nAt this point, a pure js-based transform might be the better option and simply using the TypeScript compiler infrastructure would make sense since all the tools to create a relatively fast module type-stripping system should be there but are not exposed through the current API.\r\n\r\n## 💻 Use Cases\r\n\r\n\u003c!--\r\n  What do you want to use this for?\r\n  What shortcomings exist with current approaches?\r\n  What workarounds are you using in the meantime?\r\n--\u003e\r\n\r\nOur goal is to be able to keep `transpileModule` and have it go faster if the options don't require checking:\r\n\r\n```ts\r\n// ✅ doesn't require checking, fast path:\r\nts.transpileModule(tsFileStr, {\r\n    compilerOptions: {\r\n        target: \"esnext\",\r\n    },\r\n});\r\n\r\n// ❌ requires checking, slow path:\r\nts.transpileModule(\"class c { @x f: string };\", {\r\n    compilerOptions: {\r\n        target: \"esnext\",\r\n        emitDecoratorMetadata: true,\r\n        noEmitHelpers: true,\r\n    },\r\n});\r\n// emits with some type system info:\r\nclass c { f }\r\n__decorate([], x, __metadata(\"design:type\", String), c.prototype, \"f\", void 0);\r\n```\r\n\r\nBy avoiding type-checking code paths when possible (deoptimizing options TBD), we could speed things up significantly again for the users of `transpileModule`.\r\n\r\nIn the future, it could also be the base to then introduce a `tsc` flag for fast unchecked builds as suggested in #29651.This would permit `tsc` to be significantly faster if opted into with the flag.\r\n\r\n### Deoptimizing options\r\n\r\nThis is a temporary list that we intend to build up over time:\r\n\r\n- `emitDecoratorMetadata`\r\n- ... TBD ...\r\n\r\n---\r\n\r\nIf you can provide some guidance on whether this would be a good thing to change/fix, along with any implementation constraints/tips, I would be happy to attempt an implementation.\r\n","author":{"url":"https://github.com/rricard","@type":"Person","name":"rricard"},"datePublished":"2022-09-09T09:40:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/50699/TypeScript/issues/50699"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5e6bae0e-8735-be0d-db3e-95cc7659a324
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9808:3EF61D:36CEE87:4D2E4AB:6A5F9ADE
html-safe-nonce29971fab58e6e381af418462ab9617fb29038474b6367a73e162dd2db0e487fc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODA4OjNFRjYxRDozNkNFRTg3OjREMkU0QUI6NkE1RjlBREUiLCJ2aXNpdG9yX2lkIjoiMTk3ODEyNjc2MjgxNjU0MzQ1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca36043f1804201b64ff7492e25618357d9392b19dcf59f1fe95b31310569491b
hovercard-subject-tagissue:1367563682
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/50699/issue_layout
twitter:imagehttps://opengraph.githubassets.com/85d5b728dae9fce2fadf5bda839ce18c50f756b9bbb1c2e0308fb0073a9bea6d/microsoft/TypeScript/issues/50699
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/85d5b728dae9fce2fadf5bda839ce18c50f756b9bbb1c2e0308fb0073a9bea6d/microsoft/TypeScript/issues/50699
og:image:altSuggestion 🔍 Search Terms transpileModule skip typechecking no typechecking Semi-related issues found: Skip typechecking; only emit (support --transpileOnly in tsc, re-open of #4176) #29651 [FEATUR...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerricard
hostnamegithub.com
expected-hostnamegithub.com
None9353cc7b48460319d80daeeb399e4919b4abcfe6f78d37c7b457924d164a40b1
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release755d210ae728fcf699d7ab1cdd9866592be6ad35
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/50699#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F50699
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F50699
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/50699
Reloadhttps://github.com/microsoft/TypeScript/issues/50699
Reloadhttps://github.com/microsoft/TypeScript/issues/50699
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/50699
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.6k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 110k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 29 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Do not check in the transpileModule APIhttps://github.com/microsoft/TypeScript/issues/50699#top
https://github.com/weswigham
Domain: APIRelates to the public API for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20API%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 5.5.1https://github.com/microsoft/TypeScript/milestone/202
https://github.com/rricard
rricardhttps://github.com/rricard
on Sep 9, 2022https://github.com/microsoft/TypeScript/issues/50699#issue-1367563682
Skip typechecking; only emit #4176https://github.com/microsoft/TypeScript/issues/4176
Skip typechecking; only emit (support --transpileOnly in tsc, re-open of #4176) #29651https://github.com/microsoft/TypeScript/issues/29651
[FEATURE REQUEST] Please supply a minified version with only transpilation functionality  #9245https://github.com/microsoft/TypeScript/issues/9245
Allow transformers to run without type-checking #41986https://github.com/microsoft/TypeScript/issues/41986
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
https://user-images.githubusercontent.com/246520/189321406-d3753ba4-0c86-4150-8926-9f1ff6f67614.png
swchttps://swc.rs
esbuildhttps://esbuild.github.io
#29651https://github.com/microsoft/TypeScript/issues/29651
weswighamhttps://github.com/weswigham
Domain: APIRelates to the public API for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20API%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 5.5.1https://github.com/microsoft/TypeScript/milestone/202
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.