Is module.register scoped to the called file or the rest of the process?
              
              #4609
            
            
          -
        ExampleWhile running a process, there's a case where I need to register a hook to resolve TypeScript. // foo.js
if (shouldRegisterHook) {
  const { register } = require('module')
  register('./loader.mjs')
}
// Expect this TypeScript file to be imported correctly.
const typescriptFile = await import('path/to/typescript/file.ts')
// ...Question
  | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            aduh95
          
      
      
        Nov 25, 2024 
      
    
    Replies: 0 comments 2 replies
-
| 
         Calling   | 
  
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
      Answer selected by
        devjiwonchoi
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Calling
register()affects the whole thread. A hook can be registered several times but I don't really see a use-case for that.