René's URL Explorer Experiment


Title: Introduce new flag for minifier optimization hints · Issue #38374 · microsoft/TypeScript · GitHub

Open Graph Title: Introduce new flag for minifier optimization hints · Issue #38374 · microsoft/TypeScript

X Title: Introduce new flag for minifier optimization hints · Issue #38374 · microsoft/TypeScript

Description: Search Terms Optimization Minifier Bundler IIFE Wrapper Terser Suggestion TypeScript 3.9 pulled in PR #32011, which tailors TypeScript's output for optimization with minifiers such as Terser. This PR definitely goes in the right directio...

Open Graph Description: Search Terms Optimization Minifier Bundler IIFE Wrapper Terser Suggestion TypeScript 3.9 pulled in PR #32011, which tailors TypeScript's output for optimization with minifiers such as Terser. This ...

X Description: Search Terms Optimization Minifier Bundler IIFE Wrapper Terser Suggestion TypeScript 3.9 pulled in PR #32011, which tailors TypeScript's output for optimization with minifiers such as Terser. T...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Introduce new flag for minifier optimization hints","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the FAQ, especially the \"Common Feature Requests\" section: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\nOptimization\r\nMinifier\r\nBundler\r\nIIFE\r\nWrapper\r\nTerser\r\n\r\n## Suggestion\r\n\r\nTypeScript 3.9 pulled in PR #32011, which tailors TypeScript's output for optimization with minifiers such as Terser. This PR definitely goes in the right direction for optimizing TypeScript's emit for most users, but doesn't necessarily work for all toolchains out there. At Google we have optimization processes after TypeScript compilation that use static analysis to look for classes, do some rough type-checking, and for example rename class properties and drop methods. The wrapper introduced in TypeScript 3.9 hinders our ability to analyze these classes.\r\n\r\nWe'd like to propose a new flag to toggle this behavior, which I'll call `--add-optimization-hints` for now. This flag would control if TypeScript decides to emit these hints for optimizers and bundlers, which is not necessarily limited to the `/** @class */` form introduced in TypeScript 3.9. For users such as Google, we can disable this flag and instead rely on our own optimizers to handle this, but users piping directly through Webpack and Terser can still receive the benefits from #32011.\r\n\r\n## Use Cases\r\n\r\n### Removing IIFE Wrapper for ES2015 Classes\r\nExpanding on our toolchain a bit from above, at Google we use a combination of [tsickle](https://github.com/angular/tsickle), [closure-compiler](https://github.com/google/closure-compiler), and other tools to optimize our TypeScript code. Tsickle is used to add type annotations and use the `goog.module` module system to TypeScript's emit such that Closure Compiler can optimize the code. Using the TypeScript 3.9 RC which emits IIFE wrappers around ES2015 classes Closure Compiler is unable to understand that this is an alias for the inner class. By setting `--add-optimization-hints=false` we would be able to statically analyze TypeScript's output without doing additional special processing.\r\n\r\n### Adding Further Optimization Hints\r\nPR #32011 isn't the first to request optimization hints from the TypeScript output, for example #13721 requested a `/** #pure */` annotation as well, and there could be more in the future that TypeScript would like to hint at. Adding this flag allows TypeScript to produce messier code that is less similar to the input, but more compatible with bundlers and minifiers.\r\n\r\n## Examples\r\n\r\nThis would be a new flag for the TypeScript compiler. Assuming TypeScript 3.9 is being used, given the input:\r\n\r\n```ts\r\n// input.ts\r\nclass C {\r\n  static prop = 10;\r\n\r\n  getProp() {\r\n    return C.prop;\r\n  }\r\n}\r\n```\r\n\r\n**Compiling with `tsc --add-optimization-hints=true`**:\r\n\r\n```js\r\n// output.js\r\n\"use strict\";\r\nlet C = /** @class */ (() => {\r\n    class C {\r\n        getProp() {\r\n            return C.prop;\r\n        }\r\n    }\r\n    C.prop = 10;\r\n    return C;\r\n})();\r\n```\r\n\r\n**Compiling with `tsc --add-optimization-hints=false`**:\r\n\r\n```js\r\n// output.js\r\n\"use strict\";\r\nclass C {\r\n    getProp() {\r\n        return C.prop;\r\n    }\r\n}\r\nC.prop = 10;\r\n```\r\n\r\n## Checklist\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, 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","author":{"url":"https://github.com/rrdelaney","@type":"Person","name":"rrdelaney"},"datePublished":"2020-05-06T21:50:46Z","url":"https://github.com/microsoft/TypeScript/issues/38374"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d23a55ac-21e8-74db-298e-de44325f5ba1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCB0:3A8E64:D6DF5:11D9C7:6B0182AF
html-safe-nonce5930ad9ea4c53f83941dbb1ba6b18e692de30fb0b0794fc57e8f8246c25dda67
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0IwOjNBOEU2NDpENkRGNToxMUQ5Qzc6NkIwMTgyQUYiLCJ2aXNpdG9yX2lkIjoiNjcyMzE5MzA5MzcxMTAzNzEwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacd6067d2b017a1a168f49f80eca821408958548e9433b1b829c043f3279f7d60b
hovercard-subject-tagissue:613635487
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/38374/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ff1b9b683e190c978106841d093f24b81de512523d8d7caf26904fbe15034ea3/microsoft/TypeScript/issues/38374
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ff1b9b683e190c978106841d093f24b81de512523d8d7caf26904fbe15034ea3/microsoft/TypeScript/issues/38374
og:image:altSearch Terms Optimization Minifier Bundler IIFE Wrapper Terser Suggestion TypeScript 3.9 pulled in PR #32011, which tailors TypeScript's output for optimization with minifiers such as Terser. This ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerrdelaney
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/38374#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F38374
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F38374
Sign uphttps://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/38374
Reloadhttps://github.com/microsoft/TypeScript/issues/38374
Reloadhttps://github.com/microsoft/TypeScript/issues/38374
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38374
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38374
Introduce new flag for minifier optimization hintshttps://github.com/microsoft/TypeScript/issues/38374#top
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/rrdelaney
Ryan Delaney (rrdelaney)https://github.com/rrdelaney
on May 6, 2020https://github.com/microsoft/TypeScript/issues/38374#issue-613635487
#32011https://github.com/microsoft/TypeScript/pull/32011
#32011https://github.com/microsoft/TypeScript/pull/32011
tsicklehttps://github.com/angular/tsickle
closure-compilerhttps://github.com/google/closure-compiler
#32011https://github.com/microsoft/TypeScript/pull/32011
#13721https://github.com/microsoft/TypeScript/issues/13721
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
Nexthttps://github.com/microsoft/TypeScript/issues/38374?timeline_page=1
https://github.com/j-oliveras
Jordi Oliveras Rovira (j-oliveras)https://github.com/j-oliveras
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-625131650
#8https://github.com/microsoft/TypeScript/issues/8
https://github.com/evmar
Evan Martin (evmar)https://github.com/evmar
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-625373593
#8https://github.com/microsoft/TypeScript/issues/8
Demo linkhttps://www.typescriptlang.org/play/?target=2&module=1&ts=4.0.0-dev.20200506#code/MYGwhgzhAEDC0G8BQ1XQGYHtMAoCUiKaxwmAdhJiAKYB0ImA5jgOQAeLeA3EagL69oEAC5hhAS2DQ20ALzQAzDwFA
https://github.com/concavelenz
John Lenz (concavelenz)https://github.com/concavelenz
on May 7, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-625445689
Classhttps://github.com/Class
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on May 8, 2020https://github.com/microsoft/TypeScript/issues/38374#event-3318564812
https://github.com/rrdelaney
Ryan Delaney (rrdelaney)https://github.com/rrdelaney
on May 12, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-627452786
https://github.com/evmar
Evan Martin (evmar)https://github.com/evmar
on May 12, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-627479278
Ryan Delaney (@rrdelaney)https://github.com/rrdelaney
https://github.com/IgorMinar
Igor Minar (IgorMinar)https://github.com/IgorMinar
on May 13, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-627678053
https://github.com/mprobst
Martin Probst (mprobst)https://github.com/mprobst
on May 19, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-630860708
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/j-oliveras
Jordi Oliveras Rovira (j-oliveras)https://github.com/j-oliveras
on May 19, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-630882926
Martin Probst (@mprobst)https://github.com/mprobst
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on May 20, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-631686599
#38566https://github.com/microsoft/TypeScript/pull/38566
https://github.com/rrdelaney
Ryan Delaney (rrdelaney)https://github.com/rrdelaney
on May 20, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-631695328
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
#38566https://github.com/microsoft/TypeScript/pull/38566
Kara (kara)https://github.com/kara
on May 21, 2020https://github.com/microsoft/TypeScript/issues/38374#event-3361332440
fix(core): disable tsickle pass when producing APF packages (#37221)https://github.com/angular/angular/commit/a1001f2ea0e59e3ce20bcc8c93d6ab5a912f6a4a
#37221https://github.com/angular/angular/pull/37221
a1001f2https://github.com/angular/angular/commit/a1001f2ea0e59e3ce20bcc8c93d6ab5a912f6a4a
https://github.com/DavidANeil
David Neil (DavidANeil)https://github.com/DavidANeil
on May 22, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-632412100
Lucidcharthttps://www.lucidchart.com
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on May 22, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-632756300
#32011https://github.com/microsoft/TypeScript/pull/32011
https://github.com/IgorMinar
Igor Minar (IgorMinar)https://github.com/IgorMinar
on May 22, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-632920137
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
#32011https://github.com/microsoft/TypeScript/pull/32011
#32011https://github.com/microsoft/TypeScript/pull/32011
post processing step in @angular-devkit/build-optimizerhttps://github.com/angular/angular-cli/blob/a42ce844a7b706bbfc8222ddcad178e4453db0be/packages/angular_devkit/build_optimizer/src/transforms/prefix-classes.ts
Wrap classes with decorators or static properties in an IIFE, even for ES2015+ #32011https://github.com/microsoft/TypeScript/pull/32011
Wrap classes with decorators or static properties in an IIFE, even for ES2015+ #32011https://github.com/microsoft/TypeScript/pull/32011
#32011https://github.com/microsoft/TypeScript/pull/32011
https://github.com/mprobst
Martin Probst (mprobst)https://github.com/mprobst
on May 26, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-634169809
Igor Minar (@IgorMinar)https://github.com/IgorMinar
Ryan Delaney (@rrdelaney)https://github.com/rrdelaney
https://github.com/rrdelaney
Ryan Delaney (rrdelaney)https://github.com/rrdelaney
on May 26, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-634219202
Igor Minar (@IgorMinar)https://github.com/IgorMinar
Martin Probst (@mprobst)https://github.com/mprobst
Ryan Delaney (@rrdelaney)https://github.com/rrdelaney
Wrap classes with decorators or static properties in an IIFE, even for ES2015+ #32011https://github.com/microsoft/TypeScript/pull/32011
TypeScript's design goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
https://github.com/martonlederer
Marton Lederer (martonlederer)https://github.com/martonlederer
on Jul 23, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-662930559
profanis (profanis)https://github.com/profanis
on Sep 5, 2020https://github.com/microsoft/TypeScript/issues/38374#event-3732915862
fix(core): disable tsickle pass when producing APF packages (angular#…https://github.com/profanis/angular/commit/f879596bf2df6c48fd7e09080e3932944bb1667d
angular#…https://github.com/angular/angular/pull/37221
f879596https://github.com/profanis/angular/commit/f879596bf2df6c48fd7e09080e3932944bb1667d
https://github.com/farfromrefug
farfromrefuge (farfromrefug)https://github.com/farfromrefug
on Nov 11, 2020https://github.com/microsoft/TypeScript/issues/38374#issuecomment-725628022
Nativescripthttps://nativescript.org/
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/38374
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/38374
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
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.