Title: Modules loaded through `--import` seem to use a separate ESM cache · Issue #44583 · nodejs/node · GitHub
Open Graph Title: Modules loaded through `--import` seem to use a separate ESM cache · Issue #44583 · nodejs/node
X Title: Modules loaded through `--import` seem to use a separate ESM cache · Issue #44583 · nodejs/node
Description: Version v18.8.0 Platform Darwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64 Subsystem ECMAScript modules What steps will reproduce the bug? Whe...
Open Graph Description: Version v18.8.0 Platform Darwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64 Subsystem ECMAScript module...
X Description: Version v18.8.0 Platform Darwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64 Subsystem ECMAScript module...
Opengraph URL: https://github.com/nodejs/node/issues/44583
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Modules loaded through `--import` seem to use a separate ESM cache","articleBody":"### Version\r\n\r\nv18.8.0\r\n\r\n### Platform\r\n\r\nDarwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64\r\n\r\n### Subsystem\r\n\r\nECMAScript modules\r\n\r\n### What steps will reproduce the bug?\r\n\r\nWhen running the following command:\r\n\r\n node --experimental-loader ./loader.mjs ./run.mjs\r\n\r\nGiven the following context:\r\n\r\n```js\r\n// loader.mjs\r\nimport './shared-dep.mjs';\r\nconsole.log('loaded loader.mjs');\r\n```\r\n```js\r\n// shared-dep.mjs\r\nconsole.log('loaded shared-dep.mjs');\r\n```\r\n```js\r\n// run.mjs\r\nimport './loader.mjs';\r\nimport './shared-dep.mjs';\r\nconsole.log('loaded run.mjs');\r\n```\r\n\r\nThe output is as follows:\r\n\r\n```\r\nloaded shared-dep.mjs\r\nloaded loader.mjs\r\nloaded shared-dep.mjs\r\nloaded loader.mjs\r\nloaded run.mjs\r\n```\r\n\r\nNotice how the imports from `--experimental-loader ./loader.mjs` are reloaded once they are imported from `node ./run.mjs`, while the two times that `shared-dep.mjs` is imported as a result of the latter triggers only a single load. This looks to me like we are dealing with two ESM caches here.\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\nSharing modules between A \u0026 B when doing `node --experimental-loader A B`.\r\n\r\n### What is the expected behavior?\r\n\r\n```\r\nloaded shared-dep.mjs\r\nloaded loader.mjs\r\nloaded run.mjs\r\n```\r\n\r\n### What do you see instead?\r\n\r\n```\r\nloaded shared-dep.mjs\r\nloaded loader.mjs\r\nloaded shared-dep.mjs\r\nloaded loader.mjs\r\nloaded run.mjs\r\n```\r\n\r\n### Additional information\r\n\r\nThe two _do_ share the same `global`.","author":{"url":"https://github.com/timmolendijk","@type":"Person","name":"timmolendijk"},"datePublished":"2022-09-09T19:15:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/44583/node/issues/44583"}
| 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:1936bc64-402b-6d92-9310-601de38db38f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D416:B6892:FD92:14621:6969C4C4 |
| html-safe-nonce | f3ced6e3bbf4162d00a3973f4bb26a3c3843c3ab57b9dbafb30578cb40858e3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDE2OkI2ODkyOkZEOTI6MTQ2MjE6Njk2OUM0QzQiLCJ2aXNpdG9yX2lkIjoiNDcxNTE1NDgzMTc4MzM0NzM5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8ad1c821ed4f97ce75cf267c26b096a5ba9f07020252e29d372f5ec38df56bc5 |
| hovercard-subject-tag | issue:1368228473 |
| 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/nodejs/node/44583/issue_layout |
| twitter:image | https://opengraph.githubassets.com/256d7a284ff12ebfe2495ea8d76b66126713ed26b4f35ea5b62f6da94702dd87/nodejs/node/issues/44583 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/256d7a284ff12ebfe2495ea8d76b66126713ed26b4f35ea5b62f6da94702dd87/nodejs/node/issues/44583 |
| og:image:alt | Version v18.8.0 Platform Darwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64 Subsystem ECMAScript module... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timmolendijk |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width