Title: TS Build api failed when using node ESM module (mjs) · Issue #56366 · microsoft/TypeScript · GitHub
Open Graph Title: TS Build api failed when using node ESM module (mjs) · Issue #56366 · microsoft/TypeScript
X Title: TS Build api failed when using node ESM module (mjs) · Issue #56366 · microsoft/TypeScript
Description: 🔎 Search Terms ESM ts.sys undefined 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about modules ⏯ Playground Link https://github.com/stevebeauge/tsc-api-esm 💻 Code im...
Open Graph Description: 🔎 Search Terms ESM ts.sys undefined 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about modules ⏯ Playground Link https://gith...
X Description: 🔎 Search Terms ESM ts.sys undefined 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about modules ⏯ Playground Link https://...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/56366
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS Build api failed when using node ESM module (mjs)","articleBody":"### 🔎 Search Terms\n\nESM ts.sys undefined \n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about modules\r\n\r\n\n\n### ⏯ Playground Link\n\nhttps://github.com/stevebeauge/tsc-api-esm\n\n### 💻 Code\n\n```ts\r\nimport * as tsc from \"typescript\";\r\n\r\nconst tsSystem = tsc.sys;\r\n\r\nconsole.log({ tsSystem });\r\n\r\n```\r\n\n\n### 🙁 Actual behavior\n\nIf I transpile this code into CJS and run `node index.cjs` works as expected (tsc.sys is defined).\r\n\r\nIf I transpile this code into ESM and run `node index.mjs` the code does not works as expected (tsc.sys is undefined).\r\n\r\n\n\n### 🙂 Expected behavior\n\ntsc.sys (`System`) should be available in CLI tools, whether the output is ESM or CJS.\n\n### Additional information about the issue\n\nThe issue occurs when trying to create a CLI tool that require parsing tsconfig files, including potential \"extends\". Typescript provides an API for that.\r\n\r\nHowever, my cli tool requires to be ESM because of some imports not available as CJS.\r\n\r\nRepro steps (using pnpm but it does not matter):\r\n\r\n````\r\ngit clone https://github.com/stevebeauge/tsc-api-esm\r\ncd tsc-api-esm\r\npnpm i \r\nnode index.cjs\r\nnode index.mjs\r\n````\r\n\r\nWhen using cjs : OK\r\nWhen using ESM : KO\r\n\r\nMy investigations leds me to : https://github.com/microsoft/TypeScript/blob/80ab111685e3e0c10d8d13cdd18d8dffa8328895/src/compiler/core.ts#L2748\r\n\r\nIt populates the tsc.sys when the function \"isNodeLikeSystem\" returns true. However, the test expect to have `module` be defined (which is true in CJS, not in ESM).","author":{"url":"https://github.com/stevebeauge","@type":"Person","name":"stevebeauge"},"datePublished":"2023-11-10T20:30:45Z","url":"https://github.com/microsoft/TypeScript/issues/56366"}
| 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:6531106f-090b-a692-dbf3-0f61b128d55f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD30:9FD79:C5E1E8:105BCF2:6B04FF33 |
| html-safe-nonce | a016ea0a448e404ef3c8d7f2742769075a0a018b69badbeca16c6ce48ecfa204 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDMwOjlGRDc5OkM1RTFFODoxMDVCQ0YyOjZCMDRGRjMzIiwidmlzaXRvcl9pZCI6Ijc2MDMwOTczNzg1ODA5MjIxNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9aa1c41efcd7414c8124dabbe72f724fdde7c227bbb9b2467a52ce1a0a790ef0 |
| hovercard-subject-tag | issue:1988344869 |
| 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/56366/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1319fb58614d2af4f12f058cce488338c6c2eabc0f1c11c1c9b91a6b476d7aac/microsoft/TypeScript/issues/56366 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1319fb58614d2af4f12f058cce488338c6c2eabc0f1c11c1c9b91a6b476d7aac/microsoft/TypeScript/issues/56366 |
| og:image:alt | 🔎 Search Terms ESM ts.sys undefined 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about modules ⏯ Playground Link https://gith... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stevebeauge |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| 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 | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width