Title: [v22.x] backport module loader & loader hook fixes by joyeecheung · Pull Request #62029 · nodejs/node · GitHub
Open Graph Title: [v22.x] backport module loader & loader hook fixes by joyeecheung · Pull Request #62029 · nodejs/node
X Title: [v22.x] backport module loader & loader hook fixes by joyeecheung · Pull Request #62029 · nodejs/node
Description: Fixes: #61801 This backports the following bug fixes/refactors: #59679 #59874 #59929 #60072 #61088 #61479 #61529 As discussed in #61801 (comment), #59929 is backported with an additional diff to check how the module is loaded differently (by observing NODE_DEBUG output, instead of checking that require.cache does not exist) for the --experimental-default-type=module test, since this feature was only in early development and had been removed since v23.4.0, backporting a small behavior change to v22 (which arguably is the less surprising behavior) should be fine. see diff diff --git a/test/es-module/test-esm-type-flag-errors.mjs b/test/es-module/test-esm-type-flag-errors.mjs index 2f7a1db35d2..fbef806b907 100644 --- a/test/es-module/test-esm-type-flag-errors.mjs +++ b/test/es-module/test-esm-type-flag-errors.mjs @@ -36,14 +36,16 @@ describe('--experimental-default-type=module', { concurrency: !process.env.TEST_ const result = await spawnPromisified(process.execPath, [ '--experimental-default-type=module', fixtures.path('es-modules/package-type-commonjs/echo-require-cache.js'), - ]); - - deepStrictEqual(result, { - code: 0, - stderr: '', - stdout: 'undefined\n', - signal: null, + ], { + env: { + ...process.env, + NODE_DEBUG: 'esm', + } }); + match(result.stderr, /Translating CJSModule file.+echo-require-cache\.js/); + match(result.stdout, /Object: null prototype/); + strictEqual(result.code, 0); + strictEqual(result.signal, null); }); it('should affect .cjs files that are imported', async () => { @@ -51,25 +53,34 @@ describe('--experimental-default-type=module', { concurrency: !process.env.TEST_ '--experimental-default-type=module', '-e', `import ${JSON.stringify(fixtures.fileURL('es-module-require-cache/echo.cjs'))}`, - ]); - - deepStrictEqual(result, { - code: 0, - stderr: '', - stdout: 'undefined\n', - signal: null, + ], { + env: { + ...process.env, + NODE_DEBUG: 'esm', + } }); + + match(result.stderr, /Translating CJSModule file.+echo\.cjs/); + match(result.stdout, /Object: null prototype/); + strictEqual(result.code, 0); + strictEqual(result.signal, null); }); it('should affect entry point .cjs files (with no hooks)', async () => { - const { stderr, stdout, code } = await spawnPromisified(process.execPath, [ + const result = await spawnPromisified(process.execPath, [ '--experimental-default-type=module', fixtures.path('es-module-require-cache/echo.cjs'), - ]); + ], { + env: { + ...process.env, + NODE_DEBUG: 'esm', + } + }); - strictEqual(stderr, ''); - match(stdout, /^undefined\n$/); - strictEqual(code, 0); + match(result.stderr, /Translating CJSModule file.+echo\.cjs/); + match(result.stdout, /Object: null prototype/); + strictEqual(result.code, 0); + strictEqual(result.signal, null); }); it('should affect entry point .cjs files (when any hooks is registered)', async () => {
Open Graph Description: Fixes: #61801 This backports the following bug fixes/refactors: #59679 #59874 #59929 #60072 #61088 #61479 #61529 As discussed in #61801 (comment), #59929 is backported with an additional diff to ...
X Description: Fixes: #61801 This backports the following bug fixes/refactors: #59679 #59874 #59929 #60072 #61088 #61479 #61529 As discussed in #61801 (comment), #59929 is backported with an additional diff to ...
Opengraph URL: https://github.com/nodejs/node/pull/62029
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:237e7dd0-a612-8a63-fb0d-c4a18648d719 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A4F6:76C74:22C3093:32230B2:6A4D137F |
| html-safe-nonce | 6890af0fa1cd13ad700986011cc6cd13966ad0112d9bf42ee52fa20d9008260e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEY2Ojc2Qzc0OjIyQzMwOTM6MzIyMzBCMjo2QTREMTM3RiIsInZpc2l0b3JfaWQiOiIzODc5OTAwNzkwNzE0NjAyMzY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7165762222c2bd46c8970dc25797e1ee390fcb2bc7d8ae6c0aa3fd06bf2a30b4 |
| hovercard-subject-tag | pull_request:3336332839 |
| 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/62029/files |
| twitter:image | https://avatars.githubusercontent.com/u/4299420?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4299420?s=400&v=4 |
| og:image:alt | Fixes: #61801 This backports the following bug fixes/refactors: #59679 #59874 #59929 #60072 #61088 #61479 #61529 As discussed in #61801 (comment), #59929 is backported with an additional diff to ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | f02420044fa3730a0607f4a52546bdd73f5ae60187ef57d284ecb6d7f3f1d880 |
| 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 | f0b6a62c1f0be1086cb0b5b077b82cebe520eb42 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width