tungsten 0.2.3 → 0.2.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moduleReloader.d.ts","sourceRoot":"","sources":["../src/moduleReloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,CAAA;AAGhB,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"moduleReloader.d.ts","sourceRoot":"","sources":["../src/moduleReloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,CAAA;AAGhB,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AA2B5C,QAAA,MAAM,OAAO,EAAE,WAmCd,CAAA"}
|
package/dist/moduleReloader.js
CHANGED
|
@@ -7,6 +7,10 @@ const selfURL = import.meta.url.replace(/\?loader$/, '');
|
|
|
7
7
|
const isSelf = url => url === selfURL;
|
|
8
8
|
const hasUrlScheme = specifier => /^[a-zA-Z][a-zA-Z\d+.-]*:/.test(specifier);
|
|
9
9
|
const isBareImport = specifier => !specifier.startsWith('.') && !specifier.startsWith('/') && !specifier.startsWith('\\') && !hasUrlScheme(specifier);
|
|
10
|
+
const cachedModulePattern = /\._cached_\.(?:[cm]?js|[cm]?ts|jsx|tsx)$/i;
|
|
11
|
+
function isCachedModule(url) {
|
|
12
|
+
return cachedModulePattern.test(url.pathname);
|
|
13
|
+
}
|
|
10
14
|
const isStaticModule = url => {
|
|
11
15
|
const pathname = url.pathname.toLowerCase();
|
|
12
16
|
return pathname.includes('/node_modules/') || pathname.includes('/.packages/');
|
|
@@ -16,6 +20,9 @@ const resolve = async (specifier, context, nextResolve) => {
|
|
|
16
20
|
const result = await nextResolve(specifier, context);
|
|
17
21
|
if (!isSelf(result.url) && !isBuiltin(result.url) && context.parentURL !== undefined) {
|
|
18
22
|
const url = new URL(result.url);
|
|
23
|
+
// A *._cached_.js/ts module and its dependency graph use Node's ordinary
|
|
24
|
+
// process-wide module cache instead of inheriting the test file instance.
|
|
25
|
+
if (isCachedModule(url)) return result;
|
|
19
26
|
if (isBareImport(specifier) || isStaticModule(url)) {
|
|
20
27
|
return result;
|
|
21
28
|
}
|