* * @param {string} name - The filename of the script. * @param {string} body - The code of the script. * @param {string} baseUrl Path of the parent importing the module. * @returns {ContextifyScript} The created contextify script.
(name, body, baseUrl)
| 411 | * @returns {ContextifyScript} The created contextify script. |
| 412 | */ |
| 413 | function compileScript(name, body, baseUrl) { |
| 414 | const hostDefinedOptionId = Symbol(name); |
| 415 | async function importModuleDynamically(specifier, _, importAttributes, phase) { |
| 416 | const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader(); |
| 417 | return cascadedLoader.import(specifier, baseUrl, importAttributes, |
| 418 | phase === 'source' ? kSourcePhase : kEvaluationPhase); |
| 419 | } |
| 420 | return makeContextifyScript( |
| 421 | body, // code |
| 422 | name, // filename, |
| 423 | 0, // lineOffset |
| 424 | 0, // columnOffset, |
| 425 | undefined, // cachedData |
| 426 | false, // produceCachedData |
| 427 | undefined, // parsingContext |
| 428 | hostDefinedOptionId, // hostDefinedOptionId |
| 429 | importModuleDynamically, // importModuleDynamically |
| 430 | ); |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * @param {string} name - The filename of the script. |
no test coverage detected
searching dependent graphs…