@contrast/esm-hooks 2.38.2 → 2.38.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hooks.mjs +3 -1
- package/package.json +1 -1
package/lib/hooks.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import { mappings } from './common.mjs';
|
|
|
19
19
|
import { getFileType } from './get-file-type.mjs';
|
|
20
20
|
import { default as initLoaderAgent } from './loader-agent.mjs';
|
|
21
21
|
import { primordials } from '@contrast/common';
|
|
22
|
+
import { dirname } from 'node:path';
|
|
22
23
|
const { StringPrototypeSplit, BufferPrototypeToString } = primordials;
|
|
23
24
|
|
|
24
25
|
const [major, minor] = StringPrototypeSplit.call(process.versions.node, '.').map(it => +it);
|
|
@@ -105,7 +106,8 @@ async function load(url, context, nextLoad) {
|
|
|
105
106
|
loaderAgent?.esmHooks?.debugEsmLoad?.(url);
|
|
106
107
|
|
|
107
108
|
const urlObject = new URL(url);
|
|
108
|
-
const
|
|
109
|
+
const stopAt = loaderAgent?.appInfo?.app_dir ? dirname(loaderAgent.appInfo.app_dir) : null;
|
|
110
|
+
const type = await getFileType(url, stopAt);
|
|
109
111
|
|
|
110
112
|
// if it's not a builtin or a flagged file, it needs to be rewritten.
|
|
111
113
|
// if it's not an es module it will be rewritten by the require hooks.
|