* Registers a dynamically imported module for customization. * @param {string} referrer - The path of the referrer module. * @param {VmImportModuleDynamicallyCallback} importModuleDynamically - The * dynamically imported module function to be registered.
(referrer, importModuleDynamically)
| 95 | * dynamically imported module function to be registered. |
| 96 | */ |
| 97 | function registerImportModuleDynamically(referrer, importModuleDynamically) { |
| 98 | // If it's undefined or certain known symbol, there's no customization so |
| 99 | // no need to register anything. |
| 100 | if (importModuleDynamically === undefined || |
| 101 | importModuleDynamically === vm_dynamic_import_main_context_default || |
| 102 | importModuleDynamically === vm_dynamic_import_default_internal) { |
| 103 | return; |
| 104 | } |
| 105 | const { importModuleDynamicallyWrap } = require('internal/vm/module'); |
| 106 | const { registerModule } = require('internal/modules/esm/utils'); |
| 107 | registerModule(referrer, { |
| 108 | __proto__: null, |
| 109 | importModuleDynamically: |
| 110 | importModuleDynamicallyWrap(importModuleDynamically), |
| 111 | }); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Compiles a function from the given code string. |
no test coverage detected
searching dependent graphs…