@contrast/esm-hooks 2.6.2 → 2.6.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 +15 -4
- package/package.json +3 -3
package/lib/hooks.mjs
CHANGED
|
@@ -122,10 +122,21 @@ async function load(url, context, nextLoad) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (loaderAgent.config.agent.node.rewrite.cache.enable) {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
const cachedURL = await loaderAgent.rewriter.cache.find(filename);
|
|
126
|
+
if (cachedURL) {
|
|
127
|
+
// allow other load hooks to run
|
|
128
|
+
const loadResult = await nextLoad(pathToFileURL(cachedURL).href, context);
|
|
129
|
+
// use original url so that import.meta.url and import.meta.resolve work as expected
|
|
130
|
+
loadResult.responseURL = url;
|
|
131
|
+
|
|
132
|
+
if (process.env.CSI_EXPOSE_CORE) {
|
|
133
|
+
// only do this in testing scenarios
|
|
134
|
+
loaderAgent.esmHooks.portClient.sendStatus('rewritten file loaded from cache', {
|
|
135
|
+
cachedURL,
|
|
136
|
+
responseURL: loadResult.responseURL,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return loadResult;
|
|
129
140
|
}
|
|
130
141
|
}
|
|
131
142
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/esm-hooks",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Support for loading and instrumenting ECMAScript modules",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"test": "../scripts/test.sh"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@contrast/common": "1.21.
|
|
23
|
-
"@contrast/core": "1.32.
|
|
22
|
+
"@contrast/common": "1.21.3",
|
|
23
|
+
"@contrast/core": "1.32.3",
|
|
24
24
|
"@contrast/find-package-json": "^1.0.0"
|
|
25
25
|
}
|
|
26
26
|
}
|