Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pr feedback
  • Loading branch information
guybedford authored and GeoffreyBooth committed Aug 13, 2023
commit 69796fd8e387976c2e5ff3d7eca7dacc0e8164a4
7 changes: 5 additions & 2 deletions lib/internal/modules/esm/initialize_import_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const experimentalImportMetaResolve = getOptionValue('--experimental-import-meta
* @param {string} defaultParentURL The default base to use for resolution
* @param {typeof import('./loader.js').ModuleLoader} loader Reference to the current module loader
* @param {bool} allowParentURL Whether to permit parentURL second argument for contextual resolution
* @returns {(specifier: string, parentURL?: string) => string} Function to assign to import.meta.resolve
* @returns {(specifier: string) => string} Function to assign to import.meta.resolve
*/
function createImportMetaResolve(defaultParentURL, loader, allowParentURL) {
return function resolve(specifier) {
Comment thread
guybedford marked this conversation as resolved.
Outdated
let url;
const parentURL = allowParentURL ? arguments[1] ?? defaultParentURL : defaultParentURL;

const parentURL = allowParentURL ?
arguments[1] ?? defaultParentURL :
defaultParentURL;

try {
({ url } = loader.resolveSync(specifier, parentURL));
Expand Down
1 change: 0 additions & 1 deletion test/es-module/test-esm-loader-hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ describe('Loader hooks', { concurrency: true }, () => {
it('should be fine to call `process.exit` from a custom sync hook', async () => {
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
'--no-warnings',
'--experimental-import-meta-resolve',
'--experimental-loader',
'data:text/javascript,export function resolve(a,b,next){if(a==="exit:")process.exit(42);return next(a,b)}',
'--input-type=module',
Expand Down