Title: module: expose module format by module loader by legendecas · Pull Request #57777 · nodejs/node · GitHub
Open Graph Title: module: expose module format by module loader by legendecas · Pull Request #57777 · nodejs/node
X Title: module: expose module format by module loader by legendecas · Pull Request #57777 · nodejs/node
Description: Module loaders may change a requested module format. It is not safe to determine a .js format by package.json#type as well. Expose a helper function to frameworks that load js files to avoid relying on import/require failover-and-retry. Taking mocha as an example: https://github.com/mochajs/mocha/blob/b0c269616e775689f4f28eedc0a9c5e99048139b/lib/nodejs/esm-utils.js#L41-L53. import has a different resolution method compared to require. So mocha relies on import and failover to require. But this approach fails when --experimental-strip-types is enabled by default. For a legacy TypeScript module file, its module syntax should not be depended on. And in the case of mochajs/mocha#5314, given that strip-types is enabled, the error becomes SyntaxError and the failover bails out. Frameworks like mocha should take advantage of Node.js module format detection (including custom loaders) to use import or require deterministically.
Open Graph Description: Module loaders may change a requested module format. It is not safe to determine a .js format by package.json#type as well. Expose a helper function to frameworks that load js files to avoid relyin...
X Description: Module loaders may change a requested module format. It is not safe to determine a .js format by package.json#type as well. Expose a helper function to frameworks that load js files to avoid relyin...
Opengraph URL: https://github.com/nodejs/node/pull/57777
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c57a8037-0dc9-c52e-982d-bfca4279ff45 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D168:110179:107CC7:1687A8:6A4D2FB4 |
| html-safe-nonce | 89634d3f0ee833a697a0ba377ae0170035a339979c5845b606190b59339a5f84 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTY4OjExMDE3OToxMDdDQzc6MTY4N0E4OjZBNEQyRkI0IiwidmlzaXRvcl9pZCI6IjE2NjkxODY5NDM0MjA1NDI5MDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cbe62b50ef95f21328d3f41eef48d3c66abce7fb9a83742c33f28507b01f772c |
| hovercard-subject-tag | pull_request:2441883683 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/nodejs/node/pull/57777/files |
| twitter:image | https://avatars.githubusercontent.com/u/8500303?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/8500303?s=400&v=4 |
| og:image:alt | Module loaders may change a requested module format. It is not safe to determine a .js format by package.json#type as well. Expose a helper function to frameworks that load js files to avoid relyin... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 93f17a978ee60bc4668e1d7b90e6bd2d622261fd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width