Title: Consider emitting `export {}` in all ambiguous module output · Issue #38696 · microsoft/TypeScript · GitHub
Open Graph Title: Consider emitting `export {}` in all ambiguous module output · Issue #38696 · microsoft/TypeScript
X Title: Consider emitting `export {}` in all ambiguous module output · Issue #38696 · microsoft/TypeScript
Description: In TypeScript 3.9, we started preserving export * for type-only modules. While this keeps our behavior more predictable long-term, this caused bundle-size regressions for teams combining Webpack and TypeScript (webpack/webpack#10889). My...
Open Graph Description: In TypeScript 3.9, we started preserving export * for type-only modules. While this keeps our behavior more predictable long-term, this caused bundle-size regressions for teams combining Webpack an...
X Description: In TypeScript 3.9, we started preserving export * for type-only modules. While this keeps our behavior more predictable long-term, this caused bundle-size regressions for teams combining Webpack an...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38696
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consider emitting `export {}` in all ambiguous module output","articleBody":"In TypeScript 3.9, we started preserving `export *` for type-only modules. While this keeps our behavior more predictable long-term, this caused bundle-size regressions for teams combining Webpack and TypeScript (https://github.com/webpack/webpack/issues/10889).\r\n\r\nMy understanding of the situation is that tools like Webpack use a similar disambiguation strategy as that of TypeScript to figure out whether a file is a module. Given that, when Webpack resolved to an empty file, it would bail out of certain optimizations thinking it was a global script file. In reality, all users using ts-loader's `transpileModule` mode were hitting this as well - it just turned out that the new behavior uncovered this behavior in a very large codebase.\r\n\r\nWe also discovered that we were not emitting `\"use strict\"` prologue directives even under `alwaysStrict` because we assumed that the output would be a module.\r\n\r\nI also just discovered that `import type { foo } from \"bar\"` *doesn't* force an `export {}` in a module that *does* have values in it. That seems bad because this goes beyond special-casing for empty modules.\r\n\r\nHere's the outcomes I could imagine:\r\n\r\n* TypeScript always emits an `export {}`. Is this really useful if the fix is already in-flight for Webpack?\r\n* TypeScript always emits an `export {}` under `alwaysStrict` when the output is empty (but then why does this matter?)\r\n* TypeScript keeps the current behavior.\r\n\r\nPersonally, my gut was to always emit the `export {}`; then I swung into thinking that emitting `export {}` on empty modules would be a weird vestigial behavior for empty modules. But *then* I realized that TypeScript doesn't emit any sort of module marker even when using `import type`, so I'm back to thinking we should always emit `export {}`.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2020-05-20T22:19:55Z","url":"https://github.com/microsoft/TypeScript/issues/38696"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f84bb4ba-42b2-1a21-97c4-6b1de07c7fe6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A08E:7A60E:24DDF73:2F3A564:6B018298 |
| html-safe-nonce | 6de2ae4891c3b08542d937541525ce81d540e500cd8f5a6c2b221acdcf610a0b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDhFOjdBNjBFOjI0RERGNzM6MkYzQTU2NDo2QjAxODI5OCIsInZpc2l0b3JfaWQiOiIzMDM2NDkwOTY3NTI0OTM0Mjk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2bfd5bf1a243e2801a66c5198eb21ac58f370e2f5ee4048c51317957a74ec426 |
| hovercard-subject-tag | issue:622119612 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/38696/issue_layout |
| twitter:image | https://opengraph.githubassets.com/14dec02bb8fb912db7e1f249ce7c6e0e33c0f936eea359c0c9ebf82ac1499712/microsoft/TypeScript/issues/38696 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/14dec02bb8fb912db7e1f249ce7c6e0e33c0f936eea359c0c9ebf82ac1499712/microsoft/TypeScript/issues/38696 |
| og:image:alt | In TypeScript 3.9, we started preserving export * for type-only modules. While this keeps our behavior more predictable long-term, this caused bundle-size regressions for teams combining Webpack an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width