Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module.register is not chainable #50886

Closed
himself65 opened this issue Nov 23, 2023 · 1 comment
Closed

module.register is not chainable #50886

himself65 opened this issue Nov 23, 2023 · 1 comment
Labels
module Issues and PRs related to the module subsystem.

Comments

@himself65
Copy link
Member

Version

v20.10.0

Platform

Darwin Alexs-MacBook-Pro.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020 arm64

Subsystem

module

What steps will reproduce the bug?

// register.js
export async function resolve (specifier, context, nextResolve) {
  // Take an `import` or `require` specifier and resolve it to a URL.
  console.log('context', context.conditions)
  return nextResolve(specifier,
    {
      ...context,
      conditions: [...context.conditions, 'react-server']
    },
    nextResolve)
}
// register2.js
export async function resolve (specifier, context, nextResolve) {
  // Take an `import` or `require` specifier and resolve it to a URL.
  console.log('context2', context.conditions)
  return nextResolve(specifier, context, nextResolve)
}
// main.js
import { register } from 'node:module'

register('./register.js', import.meta.url)
register('./register2.js', import.meta.url)

console.log('1')

import('./test.js')
// test.js
console.log(3)

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

> node ./worker.js
1
context [ 'node', 'import', 'node-addons' ]
context2 [ 'node', 'import', 'node-addons', 'react-server' ]
context [ 'node', 'import', 'node-addons' ]
3

What do you see instead?

> node ./worker.js
1
context [ 'node', 'import', 'node-addons' ]
context2 [ 'node', 'import', 'node-addons' ]
context [ 'node', 'import', 'node-addons' ]
3

Additional information

No response

@himself65 himself65 added the module Issues and PRs related to the module subsystem. label Nov 23, 2023
@himself65
Copy link
Member Author

Oh I just realize that I ran it in the wrong order

@himself65 himself65 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem.
Projects
None yet
Development

No branches or pull requests

1 participant