Title: Design Meeting Notes, 5/19/2021 · Issue #44256 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 5/19/2021 · Issue #44256 · microsoft/TypeScript
X Title: Design Meeting Notes, 5/19/2021 · Issue #44256 · microsoft/TypeScript
Description: ES Modules in Node https://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78 Resolution Settings Last meeting: exports, types, typesVersions types@VERSION_SPECIFIER moduleResolution flag node12 module target flag? node Uhhhh but...
Open Graph Description: ES Modules in Node https://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78 Resolution Settings Last meeting: exports, types, typesVersions types@VERSION_SPECIFIER moduleResolution flag n...
X Description: ES Modules in Node https://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78 Resolution Settings Last meeting: exports, types, typesVersions types@VERSION_SPECIFIER moduleResolution flag n...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/44256
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 5/19/2021","articleBody":"# ES Modules in Node\r\n\r\nhttps://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78\r\n\r\n## Resolution Settings\r\n\r\n* Last meeting: `exports`, `types`, `typesVersions`\r\n * `types@VERSION_SPECIFIER`\r\n* `moduleResolution` flag\r\n * `node12`\r\n* `module` target flag?\r\n * `node`\r\n * Uhhhh but...~~that could change~~ already does exist and changed.\r\n * Let's say it does change in the future - how do you opt into the old behavior?\r\n * Is there potential for shifting behavior to \"bork\" an existing program?\r\n * So `node12` as well?\r\n * Should have these match.\r\n * What about a rolling `node-esm` flag that accumulates more?\r\n * `node-next`?\r\n * `node14` could come out, etc. so `node-next` could be that rolling target.\r\n * Is there an official name?\r\n * No, it's just an update in the docs really.\r\n * Could ask for a name?\r\n * The name is there, it's Node 12 😄\r\n* Could `module` and `moduleResolution` be one flag?\r\n * `module` toggles a specific `moduleResolution`\r\n * Do we need a new `moduleResolution` flag?\r\n * Yeah.\r\n* Is `node` backwards-compatible?\r\n * Ehhh, they *layer* on the existing behavior.\r\n * But if you continue following the existing resolution rules (e.g. `main` field in `package.json`), you'll get the wrong behavior.\r\n* Kind of weird that `package.json`s have more and more of our configuration.\r\n* Sounds like `node12` for both\r\n * Eventually `node-next` or `node-esm` or something along those lines.\r\n* So `\"module\": \"node12\"` implies `\"moduleResolution\": \"node12\"`.\r\n\r\n## Emit\r\n\r\n* Implementation strategy: don't want to ship in stable with a partial implementation - lots of moving parts.\r\n* What other things do we have to support?\r\n * `.cjs`\r\n * `.mjs`\r\n * Unfortunate reality in Node.\r\n * Potentially not used all that often, but users keep asking about them even though there's `\"type\": \"module\"`.\r\n * Under that, we have a path forward for `.ts` -> `.js` which is still good.\r\n * But still need `.mjs` output. So `.mts`?\r\n * What about `.mtsx`?\r\n * What if you just have `.mts`?\r\n * `.mts` just supports JSX, doesn't support `\u003cAngleBracketCastSyntaxOn>values`\r\n * Also type parameter lists with no constraint or trailing comma.\r\n\r\n ```ts\r\n const f = \u003cT>(t: T) => {};\r\n\r\n // no good, have to rewrite as\r\n\r\n const f = \u003cT extends unknown>() => {}\r\n const f = \u003cT,>() => {}\r\n ```\r\n * What about `.tsx` for modules?\r\n * Well, doesn't generate an `.mjs`.\r\n * API isn't set up to disambiguate.\r\n * Feels bad to say \"JSX is allowed in this file.\"\r\n * `.mtx`? 🤯\r\n * Supporting multiple extensions: we can do that, but we have special support `include` and `exclude` globs being specialized for TypeScript. Already got burned by this with `JSON` files.\r\n * How realistic would it be for us to say \"no `.mts` and `.cts`\"?\r\n * Probably for a bit, but we would inevitably get demand.\r\n * Still could start with something prescriptive. Maybe don't do it until we get an absolute need, along with a better sense of how people will organize their projects.\r\n * Our own experience: sometimes when you're in ESM fully, with `\"type\": \"module\"`, you'll end up with times that you want to break out.\r\n * If you want to use native ESM with Electron, you need to break out and jump into CJS land to get `require`\r\n * Maybe `.cts` is more important than `.mts`.\r\n * Is there a way to say \"this is CJS in a `package.json`?\"\r\n * Nope.\r\n * You can put it in a sub-folder with a `package.json` that says `\"type\": \"whatever-is-not-module\"`.\r\n* File extension madness! Can't imagine the cost of `.cts`, `.cd.ts`, etc.\r\n * We already use `readDirectory`, luckily it's not too bad anymore.\r\n* Luckily, a lot of resolution \"just works\" today but we need module disambiguation with modules.\r\n* We can start working on this, but we will not ship until we feel feature-complete. ✅\r\n\r\n# Performance\r\n\r\n* Our team has been working hard off thinking about how to help speed up TypeScript, and to help big projects scale.\r\n* Lots of anecdotes\r\n* One internal team switched from 1100 projects to way fewer. Hour-long compilation goes from 10 minutes.\r\n* Massive React projects that use project references.\r\n * Much of the time, projects incorrectly set up. Our bad, we had poor docs.\r\n * Often look for hot spots in check time - didn't see it.\r\n * React's `ComponentProps` - maybe takes 500ms to check?\r\n * If you have 100 projects that have to re-check this thing over and over, that's like 50 seconds on that one declaration alone.\r\n * Declaration emit\r\n * Checking + transforms\r\n * Also, `--incremental`/`--watch` needs to compute shape. Declaration emit happens twice. #43995.\r\n * #44043, #44042\r\n * We now do some caching, cache and clone the nodes of declaration (#43973)\r\n * Found that a lot of anonymous generated types are massive. A lot of duplicated text. #44044.\r\n * Feels weird to add `imports` that weren't there.\r\n * `import type`, bam, make everyone feel better.\r\n * Feels like we conflate a lot in declaration files.\r\n* One codebase used this huge set of path mappings - 1800 of them.\r\n * We were re-checking the mappings over and over and over again. Now we cache the patterns.\r\n * #44078\r\n* Normalizing slashes - one massive codebase does it 3 million times, 2 seconds total on its own, generates a ton of garbage\r\n * But MOST paths always have correct slashes, and on Unix they're ALWAYS the same.\r\n * Basically, just see if you can skip that work ahead of time.\r\n* Normalizing paths - removing relative intermediate components of paths. \r\n * #44173\r\n * Our regex was wrong.\r\n * Seeing if we need to even process these paths before splitting etc. gives a 5% boost in project load across codebases.\r\n* Been using pprof\r\n * Basically the same info as the regular profiler, but its internal format actually allows you to handle longer profiling runs.\r\n * Also some visualizer properties.\r\n * Seems to have bugs on recursive functions though!","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2021-05-25T23:21:05Z","url":"https://github.com/microsoft/TypeScript/issues/44256"}
| 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:ce82d348-9537-03d4-debb-78641281959f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DF2:7A60E:339EEB0:423D94A:6B01D899 |
| html-safe-nonce | 5f696bb16a383ca0806f984a1edb2ae4eb721cc46a4cda0c0fc8428c302a3a34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REYyOjdBNjBFOjMzOUVFQjA6NDIzRDk0QTo2QjAxRDg5OSIsInZpc2l0b3JfaWQiOiI4OTQ4MjE2MTg2MTcwMTQ0MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 58351f0838620f69a1623fb11061d2b34ad592d04ae0a5d9efa7434a298f7a5d |
| hovercard-subject-tag | issue:901499285 |
| 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/44256/issue_layout |
| twitter:image | https://opengraph.githubassets.com/403d580a59296432905ce47ae3bdd7bb2ca5f99cfde8972dc740459d1b7b1754/microsoft/TypeScript/issues/44256 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/403d580a59296432905ce47ae3bdd7bb2ca5f99cfde8972dc740459d1b7b1754/microsoft/TypeScript/issues/44256 |
| og:image:alt | ES Modules in Node https://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78 Resolution Settings Last meeting: exports, types, typesVersions types@VERSION_SPECIFIER moduleResolution flag n... |
| 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