Skip to content

Commit

Permalink
make changes
Browse files Browse the repository at this point in the history
  • Loading branch information
khanayan123 committed Dec 1, 2023
1 parent 456476f commit 630ba66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const isWin = process.platform === "win32"
// FIXME: Typescript extensions are added temporarily until we find a better
// way of supporting arbitrary extensions
const EXTENSION_RE = /\.(js|mjs|cjs|ts|mts|cts)$/
const EXTENSION_MJS_RE = /\.mjs$/;
const NODE_VERSION = process.versions.node.split('.')
const NODE_MAJOR = Number(NODE_VERSION[0])
const NODE_MINOR = Number(NODE_VERSION[1])
Expand Down Expand Up @@ -110,10 +111,14 @@ function createHook (meta) {
) {
return url
}


// on Node 16.12.0, url.format is undefined for .mjs files, so explicitly set it to 'module'
if (url.format === undefined && EXTENSION_MJS_RE.test(url.url)) {
url.format = 'module'
}

specifiers.set(url.url, specifier)

return {
url: url.format !== 'module' || NODE_MAJOR < 16 ? addIitm(url.url) : url.url,
shortCircuit: true,
Expand Down
File renamed without changes.

0 comments on commit 630ba66

Please sign in to comment.