@remix-run/assets 0.4.1 → 0.4.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/dist/lib/access.d.ts +0 -1
- package/dist/lib/access.d.ts.map +1 -1
- package/dist/lib/access.js +1 -7
- package/dist/lib/asset-server.d.ts.map +1 -1
- package/dist/lib/asset-server.js +0 -1
- package/dist/lib/files/compiler.js +1 -1
- package/dist/lib/scripts/compiler.d.ts +0 -1
- package/dist/lib/scripts/compiler.d.ts.map +1 -1
- package/dist/lib/scripts/compiler.js +15 -32
- package/dist/lib/scripts/resolve.d.ts.map +1 -1
- package/dist/lib/scripts/resolve.js +8 -35
- package/dist/lib/scripts/transform.d.ts.map +1 -1
- package/dist/lib/scripts/transform.js +10 -2
- package/dist/lib/styles/compiler.js +1 -1
- package/dist/lib/watch.js +1 -1
- package/package.json +7 -7
- package/src/lib/access.ts +1 -8
- package/src/lib/asset-server.ts +0 -1
- package/src/lib/files/compiler.ts +1 -1
- package/src/lib/scripts/compiler.ts +18 -45
- package/src/lib/scripts/resolve.ts +9 -57
- package/src/lib/scripts/transform.ts +13 -2
- package/src/lib/styles/compiler.ts +1 -1
- package/src/lib/watch.ts +1 -1
- package/dist/lib/scripts/specifiers.d.ts +0 -2
- package/dist/lib/scripts/specifiers.d.ts.map +0 -1
- package/dist/lib/scripts/specifiers.js +0 -9
- package/src/lib/scripts/specifiers.ts +0 -11
package/dist/lib/access.d.ts
CHANGED
package/dist/lib/access.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/lib/access.ts"],"names":[],"mappings":"AAGA,KAAK,YAAY,GAAG;IAClB,
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/lib/access.ts"],"names":[],"mappings":"AAGA,KAAK,YAAY,GAAG;IAClB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CACrC,CAAA;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,YAAY,CAcf"}
|
package/dist/lib/access.js
CHANGED
|
@@ -3,19 +3,13 @@ import { isInjectedPackageFilePath } from "./injected-packages.js";
|
|
|
3
3
|
export function createAccessPolicy(options) {
|
|
4
4
|
let allowMatchers = options.allow.map((pattern) => createFileMatcher(pattern, options.rootDir));
|
|
5
5
|
let denyMatchers = (options.deny ?? []).map((pattern) => createFileMatcher(pattern, options.rootDir));
|
|
6
|
-
function isDenied(filePath) {
|
|
7
|
-
if (isInjectedPackageFilePath(filePath))
|
|
8
|
-
return false;
|
|
9
|
-
return denyMatchers.length > 0 && denyMatchers.some((matcher) => matcher(filePath));
|
|
10
|
-
}
|
|
11
6
|
return {
|
|
12
|
-
isDenied,
|
|
13
7
|
isAllowed(filePath) {
|
|
14
8
|
if (isInjectedPackageFilePath(filePath))
|
|
15
9
|
return true;
|
|
16
10
|
if (!allowMatchers.some((matcher) => matcher(filePath)))
|
|
17
11
|
return false;
|
|
18
|
-
if (
|
|
12
|
+
if (denyMatchers.length > 0 && denyMatchers.some((matcher) => matcher(filePath)))
|
|
19
13
|
return false;
|
|
20
14
|
return true;
|
|
21
15
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-server.d.ts","sourceRoot":"","sources":["../../src/lib/asset-server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,mBAAmB,CAAA;AAU1B,OAAO,KAAK,EAAE,WAAW,EAA6C,MAAM,aAAa,CAAA;AAEzF,OAAO,KAAK,EAAsB,eAAe,EAAE,MAAM,YAAY,CAAA;AAErE,UAAU,uBAAuB;IAC/B;;;OAGG;IACH,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,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAA;CAC3D,CAAA;AAEL;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,UAAU,SAAS,wBAAwB,GAAG,EAAE;IAC3E;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;IACjD;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3F;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACpE;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAyBD,wBAAgB,0BAA0B,CAAC,UAAU,SAAS,wBAAwB,EACpF,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,GACnC,eAAe,GAAG,SAAS,CAE7B;AAED,wBAAgB,uBAAuB,CAAC,UAAU,SAAS,wBAAwB,EACjF,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,GACnC,SAAS,MAAM,EAAE,CAEnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,UAAU,SAAS,wBAAwB,GAAG,EAAE,EACtF,OAAO,EAAE,wBAAwB,CAAC,UAAU,CAAC,GAC5C,WAAW,CAAC,UAAU,CAAC,CA2VzB"}
|
package/dist/lib/asset-server.js
CHANGED
|
@@ -60,7 +60,6 @@ export function createAssetServer(options) {
|
|
|
60
60
|
external: resolvedOptions.external,
|
|
61
61
|
fingerprintAssets: resolvedOptions.fingerprintAssets,
|
|
62
62
|
isAllowed: accessPolicy.isAllowed,
|
|
63
|
-
isDenied: accessPolicy.isDenied,
|
|
64
63
|
minify: resolvedOptions.minify,
|
|
65
64
|
onWatchDirectoriesChange: (delta) => {
|
|
66
65
|
if (!watcher)
|
|
@@ -2,7 +2,7 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as fsp from 'node:fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { IfNoneMatch } from '@remix-run/headers';
|
|
5
|
+
import { IfNoneMatch } from '@remix-run/headers/if-none-match';
|
|
6
6
|
import { detectContentType } from '@remix-run/mime';
|
|
7
7
|
import { createAssetServerCompilationError, isAssetServerCompilationError, } from "../compilation-error.js";
|
|
8
8
|
import { formatFingerprintedPathname, generateFingerprint, hashContent } from "../fingerprint.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/compiler.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,KAAK,EAKV,gBAAgB,EACjB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/compiler.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,KAAK,EAKV,gBAAgB,EACjB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,WAAW,CAAA;AAK5D,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,YAAY,GAAG,IAAI,CAAA;CAC/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AAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC3E,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1C,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAAA;CACrE,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAKD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAmUnF;AAsLD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE;IACP,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,kBAAkB,EAAE,OAAO,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,GACA,QAAQ,CA6BV"}
|
|
@@ -2,7 +2,7 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as os from 'node:os';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { IfNoneMatch } from '@remix-run/headers';
|
|
5
|
+
import { IfNoneMatch } from '@remix-run/headers/if-none-match';
|
|
6
6
|
import { createAssetServerCompilationError } from "../compilation-error.js";
|
|
7
7
|
import { createFileMatcher } from "../file-matcher.js";
|
|
8
8
|
import { formatFingerprintedPathname, getFingerprintRequestCacheControl, parseFingerprintSuffix, } from "../fingerprint.js";
|
|
@@ -12,7 +12,6 @@ import { resolveModule, resolverExtensionAlias, resolverExtensions, supportedScr
|
|
|
12
12
|
import { createModuleStore } from "../module-store.js";
|
|
13
13
|
import { createTsconfigTransformOptionsResolver, transformModule } from "./transform.js";
|
|
14
14
|
import { ResolverFactory } from 'oxc-resolver';
|
|
15
|
-
import { isBareImportSpecifier } from "./specifiers.js";
|
|
16
15
|
const supportedScriptExtensionSet = new Set(supportedScriptExtensions);
|
|
17
16
|
const preloadConcurrency = Math.max(1, Math.min(8, os.availableParallelism() - 1));
|
|
18
17
|
export function createScriptCompiler(options) {
|
|
@@ -31,14 +30,8 @@ export function createScriptCompiler(options) {
|
|
|
31
30
|
extensionAlias: resolverExtensionAlias,
|
|
32
31
|
extensions: resolverExtensions,
|
|
33
32
|
mainFields: ['browser', 'module', 'main'],
|
|
34
|
-
symlinks: false,
|
|
35
33
|
tsconfig: 'auto',
|
|
36
34
|
});
|
|
37
|
-
let resolveModulePathOptions = {
|
|
38
|
-
isAllowed: resolvedOptions.isAllowed,
|
|
39
|
-
isDenied: resolvedOptions.isDenied,
|
|
40
|
-
routes: resolvedOptions.routes,
|
|
41
|
-
};
|
|
42
35
|
let resolveInFlightByCacheKey = new Map();
|
|
43
36
|
let emitInFlightByCacheKey = new Map();
|
|
44
37
|
let transformArgs = {
|
|
@@ -57,9 +50,7 @@ export function createScriptCompiler(options) {
|
|
|
57
50
|
let resolveArgs = {
|
|
58
51
|
isAllowed: resolvedOptions.isAllowed,
|
|
59
52
|
isWatchIgnored,
|
|
60
|
-
resolveModulePath
|
|
61
|
-
return resolveModulePath(absolutePath, resolveModulePathOptions);
|
|
62
|
-
},
|
|
53
|
+
resolveModulePath,
|
|
63
54
|
resolverFactory,
|
|
64
55
|
routes: resolvedOptions.routes,
|
|
65
56
|
};
|
|
@@ -153,7 +144,7 @@ export function createScriptCompiler(options) {
|
|
|
153
144
|
return resolveFilePath(resolvedOptions.rootDir, filePath);
|
|
154
145
|
}
|
|
155
146
|
function resolveServedScriptOrThrow(absolutePath) {
|
|
156
|
-
let resolvedModule = resolveModulePath(absolutePath
|
|
147
|
+
let resolvedModule = resolveModulePath(absolutePath);
|
|
157
148
|
if (!resolvedModule) {
|
|
158
149
|
throw createAssetServerCompilationError(`File not found: ${absolutePath}`, {
|
|
159
150
|
code: 'FILE_NOT_FOUND',
|
|
@@ -375,11 +366,10 @@ function isTsconfigPath(filePath) {
|
|
|
375
366
|
function shouldClearResolverCacheForFileEvent(filePath, event) {
|
|
376
367
|
return event !== 'change' || isPackageJsonPath(filePath) || isTsconfigPath(filePath);
|
|
377
368
|
}
|
|
378
|
-
function resolveModulePath(absolutePath
|
|
379
|
-
let candidateIdentityPath = normalizeFilePath(absolutePath);
|
|
369
|
+
function resolveModulePath(absolutePath) {
|
|
380
370
|
let resolvedPath;
|
|
381
371
|
try {
|
|
382
|
-
resolvedPath = normalizeFilePath(fs.realpathSync(
|
|
372
|
+
resolvedPath = normalizeFilePath(fs.realpathSync(normalizeFilePath(absolutePath)));
|
|
383
373
|
}
|
|
384
374
|
catch (error) {
|
|
385
375
|
if (isNoEntityError(error))
|
|
@@ -390,26 +380,10 @@ function resolveModulePath(absolutePath, options) {
|
|
|
390
380
|
return null;
|
|
391
381
|
}
|
|
392
382
|
return {
|
|
393
|
-
identityPath:
|
|
383
|
+
identityPath: resolvedPath,
|
|
394
384
|
resolvedPath,
|
|
395
385
|
};
|
|
396
386
|
}
|
|
397
|
-
function getModuleIdentityPath(candidateIdentityPath, resolvedPath, options) {
|
|
398
|
-
if (candidateIdentityPath === resolvedPath)
|
|
399
|
-
return resolvedPath;
|
|
400
|
-
if (!containsNodeModulesPathSegment(candidateIdentityPath))
|
|
401
|
-
return resolvedPath;
|
|
402
|
-
if (!options.routes.toUrlPathname(candidateIdentityPath))
|
|
403
|
-
return resolvedPath;
|
|
404
|
-
if (!options.isAllowed(candidateIdentityPath))
|
|
405
|
-
return resolvedPath;
|
|
406
|
-
if (options.isDenied(resolvedPath))
|
|
407
|
-
return resolvedPath;
|
|
408
|
-
return candidateIdentityPath;
|
|
409
|
-
}
|
|
410
|
-
function containsNodeModulesPathSegment(filePath) {
|
|
411
|
-
return filePath.split('/').includes('node_modules');
|
|
412
|
-
}
|
|
413
387
|
function resolveActualPath(identityPath) {
|
|
414
388
|
try {
|
|
415
389
|
return normalizeFilePath(fs.realpathSync(identityPath));
|
|
@@ -420,6 +394,15 @@ function resolveActualPath(identityPath) {
|
|
|
420
394
|
throw error;
|
|
421
395
|
}
|
|
422
396
|
}
|
|
397
|
+
function isBareImportSpecifier(specifier) {
|
|
398
|
+
return (!specifier.startsWith('./') &&
|
|
399
|
+
!specifier.startsWith('../') &&
|
|
400
|
+
!specifier.startsWith('/') &&
|
|
401
|
+
!specifier.startsWith('file:') &&
|
|
402
|
+
!specifier.startsWith('data:') &&
|
|
403
|
+
!specifier.startsWith('http://') &&
|
|
404
|
+
!specifier.startsWith('https://'));
|
|
405
|
+
}
|
|
423
406
|
function isNoEntityError(error) {
|
|
424
407
|
return (error instanceof Error &&
|
|
425
408
|
'code' in error &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/resolve.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAMnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAM1E,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/resolve.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAMnD,OAAO,KAAK,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2B,CAAA;CACnC,CACJ,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAA;IACxC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;IACzC,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAAA;IACnE,eAAe,EAAE,eAAe,CAAA;IAChC,MAAM,EAAE,cAAc,CAAA;CACvB,CAAA;AAaD,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,iBAAiB,EAC9B,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,aAAa,CAAC,CA0IxB"}
|
|
@@ -3,7 +3,6 @@ import * as path from 'node:path';
|
|
|
3
3
|
import { createAssetServerCompilationError, isAssetServerCompilationError, } from "../compilation-error.js";
|
|
4
4
|
import { getInjectedPackageNameForSpecifier, getInjectedPackageImporterPath, restoreAuthoredInjectedPackageSpecifier, } from "../injected-packages.js";
|
|
5
5
|
import { normalizeFilePath } from "../paths.js";
|
|
6
|
-
import { isBareImportSpecifier } from "./specifiers.js";
|
|
7
6
|
export const resolverExtensionAlias = {
|
|
8
7
|
'.js': ['.js', '.ts', '.tsx', '.jsx'],
|
|
9
8
|
'.jsx': ['.jsx', '.tsx'],
|
|
@@ -19,10 +18,7 @@ export async function resolveModule(record, transformed, args) {
|
|
|
19
18
|
try {
|
|
20
19
|
resolvedImports =
|
|
21
20
|
transformed.unresolvedImports.length > 0
|
|
22
|
-
? await batchResolveSpecifiers(getUniqueSpecifiers(transformed.unresolvedImports),
|
|
23
|
-
identityPath: transformed.identityPath,
|
|
24
|
-
resolvedPath: transformed.resolvedPath,
|
|
25
|
-
}, args.resolverFactory)
|
|
21
|
+
? await batchResolveSpecifiers(getUniqueSpecifiers(transformed.unresolvedImports), transformed.resolvedPath, args.resolverFactory)
|
|
26
22
|
: new Map();
|
|
27
23
|
}
|
|
28
24
|
catch (error) {
|
|
@@ -64,7 +60,7 @@ export async function resolveModule(record, transformed, args) {
|
|
|
64
60
|
}
|
|
65
61
|
deps.add(resolvedImport.identityPath);
|
|
66
62
|
if (transformed.packageSpecifiers.includes(unresolved.specifier)) {
|
|
67
|
-
let packageJsonPath =
|
|
63
|
+
let packageJsonPath = resolvedSpec.packageJsonPath ?? findNearestPackageJsonPath(resolvedImport.resolvedPath);
|
|
68
64
|
if (packageJsonPath && !args.isWatchIgnored(packageJsonPath)) {
|
|
69
65
|
trackedFiles.add(packageJsonPath);
|
|
70
66
|
}
|
|
@@ -98,20 +94,6 @@ export async function resolveModule(record, transformed, args) {
|
|
|
98
94
|
},
|
|
99
95
|
};
|
|
100
96
|
}
|
|
101
|
-
function resolvePackageJsonPath(packageJsonPath, resolvedPath) {
|
|
102
|
-
return ((packageJsonPath ? resolveExistingPath(packageJsonPath) : null) ??
|
|
103
|
-
findNearestPackageJsonPath(resolvedPath));
|
|
104
|
-
}
|
|
105
|
-
function resolveExistingPath(filePath) {
|
|
106
|
-
try {
|
|
107
|
-
return normalizeFilePath(fs.realpathSync(filePath));
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
if (isNoEntityError(error))
|
|
111
|
-
return null;
|
|
112
|
-
throw error;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
97
|
function findNearestPackageJsonPath(filePath) {
|
|
116
98
|
let directory = path.dirname(filePath);
|
|
117
99
|
while (true) {
|
|
@@ -125,12 +107,6 @@ function findNearestPackageJsonPath(filePath) {
|
|
|
125
107
|
directory = parentDirectory;
|
|
126
108
|
}
|
|
127
109
|
}
|
|
128
|
-
function isNoEntityError(error) {
|
|
129
|
-
return (error instanceof Error &&
|
|
130
|
-
'code' in error &&
|
|
131
|
-
(error.code === 'ENOENT' ||
|
|
132
|
-
error.code === 'ENOTDIR'));
|
|
133
|
-
}
|
|
134
110
|
function isRelativeImportSpecifier(specifier) {
|
|
135
111
|
return specifier.startsWith('./') || specifier.startsWith('../');
|
|
136
112
|
}
|
|
@@ -184,13 +160,13 @@ function getTrackedRelativeImportResolution(importerDir, specifier, isWatchIgnor
|
|
|
184
160
|
function resolveCandidateBasePath(importerDir, specifier) {
|
|
185
161
|
return normalizeFilePath(path.resolve(importerDir, specifier));
|
|
186
162
|
}
|
|
187
|
-
async function batchResolveSpecifiers(specifiers,
|
|
163
|
+
async function batchResolveSpecifiers(specifiers, importerPath, resolverFactory) {
|
|
188
164
|
let resolvedBySpecifier = new Map();
|
|
189
165
|
if (specifiers.length === 0)
|
|
190
166
|
return resolvedBySpecifier;
|
|
191
167
|
try {
|
|
192
168
|
for (let specifier of specifiers) {
|
|
193
|
-
let normalizedResolution = normalizeSpecifierResolution(specifier,
|
|
169
|
+
let normalizedResolution = normalizeSpecifierResolution(specifier, importerPath);
|
|
194
170
|
let resolutionResult = await resolverFactory.resolveFileAsync(normalizedResolution.importerPath, normalizedResolution.specifier);
|
|
195
171
|
if (resolutionResult.error) {
|
|
196
172
|
throw createAssetServerCompilationError(normalizedResolution.importerPath === getInjectedPackageImporterPath()
|
|
@@ -215,7 +191,7 @@ async function batchResolveSpecifiers(specifiers, importer, resolverFactory) {
|
|
|
215
191
|
if (isAssetServerCompilationError(error) && error.code === 'IMPORT_RESOLUTION_FAILED') {
|
|
216
192
|
throw error;
|
|
217
193
|
}
|
|
218
|
-
throw createAssetServerCompilationError(`Failed to resolve imports in ${
|
|
194
|
+
throw createAssetServerCompilationError(`Failed to resolve imports in ${importerPath}. ${formatUnknownError(error)}`, {
|
|
219
195
|
cause: error,
|
|
220
196
|
code: 'IMPORT_RESOLUTION_FAILED',
|
|
221
197
|
});
|
|
@@ -228,11 +204,11 @@ function getUniqueSpecifiers(unresolvedImports) {
|
|
|
228
204
|
function formatUnknownError(error) {
|
|
229
205
|
return error instanceof Error ? error.message : String(error);
|
|
230
206
|
}
|
|
231
|
-
function normalizeSpecifierResolution(specifier,
|
|
207
|
+
function normalizeSpecifierResolution(specifier, importerPath) {
|
|
232
208
|
let authoredInjectedPackageSpecifier = restoreAuthoredInjectedPackageSpecifier(specifier);
|
|
233
209
|
if (authoredInjectedPackageSpecifier) {
|
|
234
210
|
return {
|
|
235
|
-
importerPath
|
|
211
|
+
importerPath,
|
|
236
212
|
specifier: authoredInjectedPackageSpecifier,
|
|
237
213
|
};
|
|
238
214
|
}
|
|
@@ -243,13 +219,10 @@ function normalizeSpecifierResolution(specifier, importer) {
|
|
|
243
219
|
};
|
|
244
220
|
}
|
|
245
221
|
return {
|
|
246
|
-
importerPath
|
|
222
|
+
importerPath,
|
|
247
223
|
specifier,
|
|
248
224
|
};
|
|
249
225
|
}
|
|
250
|
-
function getSpecifierImporterPath(specifier, importer) {
|
|
251
|
-
return isBareImportSpecifier(specifier) ? importer.resolvedPath : importer.identityPath;
|
|
252
|
-
}
|
|
253
226
|
function getDisplayImportSpecifier(specifier) {
|
|
254
227
|
return restoreAuthoredInjectedPackageSpecifier(specifier) ?? specifier;
|
|
255
228
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/transform.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAS,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAS/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAO1E,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/transform.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAS,oBA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,EAAE,IAAI,CAAA;IACR,KAAK,EAAE,iBAAiB,CAAA;CACzB,GACD;IACE,EAAE,EAAE,KAAK,CAAA;IACT,KAAK,EAAE,2BAA2B,CAAA;CACnC,CACJ,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,oBAAoB,CAAA;CACnC,CAAA;AAED,KAAK,gCAAgC,GAAG,UAAU,CAAC,OAAO,sCAAsC,CAAC,CAAA;AAEjG,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IACrC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAChC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;IACzC,MAAM,EAAE,OAAO,CAAA;IACf,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACtD,MAAM,EAAE,cAAc,CAAA;IACtB,oBAAoB,EAAE,UAAU,GAAG,KAAK,CAAA;IACxC,UAAU,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAA;IACxC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAA;IACnC,gCAAgC,EAAE,gCAAgC,CAAA;CACnE,CAAA;AAED,wBAAgB,sCAAsC;;;EAkCrD;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,eAAe,CAAC,CA6H1B"}
|
|
@@ -13,7 +13,6 @@ import { generateFingerprint } from "../fingerprint.js";
|
|
|
13
13
|
import { maskAuthoredInjectedPackageSpecifier, mayContainInjectedPackageSpecifier, restoreAuthoredInjectedPackageSpecifier, } from "../injected-packages.js";
|
|
14
14
|
import { normalizeFilePath } from "../paths.js";
|
|
15
15
|
import { composeSourceMaps, rewriteSourceMapSources, stringifySourceMap } from "../source-maps.js";
|
|
16
|
-
import { isBareImportSpecifier } from "./specifiers.js";
|
|
17
16
|
const scriptModuleTypes = [
|
|
18
17
|
{ extension: '.js', lang: 'js' },
|
|
19
18
|
{ extension: '.jsx', lang: 'jsx' },
|
|
@@ -142,7 +141,7 @@ export async function transformModule(record, args) {
|
|
|
142
141
|
content: sourceText,
|
|
143
142
|
}),
|
|
144
143
|
identityPath: record.identityPath,
|
|
145
|
-
importerDir: path.dirname(
|
|
144
|
+
importerDir: path.dirname(resolvedPath),
|
|
146
145
|
packageSpecifiers: analysis.unresolvedImports
|
|
147
146
|
.filter((unresolved) => isBareImportSpecifier(unresolved.specifier))
|
|
148
147
|
.map((unresolved) => unresolved.specifier),
|
|
@@ -178,6 +177,15 @@ function findNearestTsconfigPath(directory) {
|
|
|
178
177
|
currentDirectory = parentDirectory;
|
|
179
178
|
}
|
|
180
179
|
}
|
|
180
|
+
function isBareImportSpecifier(specifier) {
|
|
181
|
+
return (!specifier.startsWith('./') &&
|
|
182
|
+
!specifier.startsWith('../') &&
|
|
183
|
+
!specifier.startsWith('/') &&
|
|
184
|
+
!specifier.startsWith('file:') &&
|
|
185
|
+
!specifier.startsWith('data:') &&
|
|
186
|
+
!specifier.startsWith('http://') &&
|
|
187
|
+
!specifier.startsWith('https://'));
|
|
188
|
+
}
|
|
181
189
|
async function analyzeModuleSource(sourceText, resolvedPath, transformOptions, options) {
|
|
182
190
|
let maskedSourceText = maskAuthoredInjectedPackageImports(sourceText, resolvedPath);
|
|
183
191
|
let transformResult;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as os from 'node:os';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { IfNoneMatch } from '@remix-run/headers';
|
|
4
|
+
import { IfNoneMatch } from '@remix-run/headers/if-none-match';
|
|
5
5
|
import { createFileMatcher } from "../file-matcher.js";
|
|
6
6
|
import { formatFingerprintedPathname } from "../fingerprint.js";
|
|
7
7
|
import { createModuleStore } from "../module-store.js";
|
package/dist/lib/watch.js
CHANGED
|
@@ -69,7 +69,7 @@ function resolveChokidarWatchOptions(options) {
|
|
|
69
69
|
depth: 0,
|
|
70
70
|
ignored: ['**/.git/**', ...(options.ignore ?? [])],
|
|
71
71
|
interval: options.pollInterval ?? 100,
|
|
72
|
-
usePolling: options.poll ??
|
|
72
|
+
usePolling: options.poll ?? process.platform === 'win32',
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
function getWatchTargets(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix-run/assets",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Fetch-based server for compiling browser JS/TS and CSS assets on demand",
|
|
5
5
|
"author": "Michael Jackson <mjijackson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"oxc-transform": "^0.121.0",
|
|
39
39
|
"picomatch": "^4.0.4",
|
|
40
40
|
"source-map-js": "^1.2.1",
|
|
41
|
-
"@remix-run/file-storage": "0.13.
|
|
42
|
-
"@remix-run/headers": "0.21.
|
|
43
|
-
"@remix-run/
|
|
44
|
-
"@remix-run/
|
|
41
|
+
"@remix-run/file-storage": "0.13.6",
|
|
42
|
+
"@remix-run/headers": "0.21.1",
|
|
43
|
+
"@remix-run/mime": "0.4.1",
|
|
44
|
+
"@remix-run/route-pattern": "0.22.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^24.6.0",
|
|
48
48
|
"@types/picomatch": "^4.0.3",
|
|
49
49
|
"@typescript/native-preview": "7.0.0-dev.20251125.1",
|
|
50
|
-
"@remix-run/assert": "0.
|
|
51
|
-
"@remix-run/test": "0.
|
|
50
|
+
"@remix-run/assert": "0.3.0",
|
|
51
|
+
"@remix-run/test": "0.5.0"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"remix",
|
package/src/lib/access.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { createFileMatcher } from './file-matcher.ts'
|
|
|
2
2
|
import { isInjectedPackageFilePath } from './injected-packages.ts'
|
|
3
3
|
|
|
4
4
|
type AccessPolicy = {
|
|
5
|
-
isDenied(filePath: string): boolean
|
|
6
5
|
isAllowed(filePath: string): boolean
|
|
7
6
|
}
|
|
8
7
|
|
|
@@ -16,17 +15,11 @@ export function createAccessPolicy(options: {
|
|
|
16
15
|
createFileMatcher(pattern, options.rootDir),
|
|
17
16
|
)
|
|
18
17
|
|
|
19
|
-
function isDenied(filePath: string): boolean {
|
|
20
|
-
if (isInjectedPackageFilePath(filePath)) return false
|
|
21
|
-
return denyMatchers.length > 0 && denyMatchers.some((matcher) => matcher(filePath))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
18
|
return {
|
|
25
|
-
isDenied,
|
|
26
19
|
isAllowed(filePath) {
|
|
27
20
|
if (isInjectedPackageFilePath(filePath)) return true
|
|
28
21
|
if (!allowMatchers.some((matcher) => matcher(filePath))) return false
|
|
29
|
-
if (
|
|
22
|
+
if (denyMatchers.length > 0 && denyMatchers.some((matcher) => matcher(filePath))) return false
|
|
30
23
|
return true
|
|
31
24
|
},
|
|
32
25
|
}
|
package/src/lib/asset-server.ts
CHANGED
|
@@ -252,7 +252,6 @@ export function createAssetServer<const transforms extends AssetRequestTransform
|
|
|
252
252
|
external: resolvedOptions.external,
|
|
253
253
|
fingerprintAssets: resolvedOptions.fingerprintAssets,
|
|
254
254
|
isAllowed: accessPolicy.isAllowed,
|
|
255
|
-
isDenied: accessPolicy.isDenied,
|
|
256
255
|
minify: resolvedOptions.minify,
|
|
257
256
|
onWatchDirectoriesChange: (delta) => {
|
|
258
257
|
if (!watcher) return
|
|
@@ -3,7 +3,7 @@ import * as fsp from 'node:fs/promises'
|
|
|
3
3
|
import * as path from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
import type { FileStorage } from '@remix-run/file-storage'
|
|
6
|
-
import { IfNoneMatch } from '@remix-run/headers'
|
|
6
|
+
import { IfNoneMatch } from '@remix-run/headers/if-none-match'
|
|
7
7
|
import { detectContentType } from '@remix-run/mime'
|
|
8
8
|
import {
|
|
9
9
|
createAssetServerCompilationError,
|
|
@@ -2,7 +2,7 @@ import * as fs from 'node:fs'
|
|
|
2
2
|
import * as os from 'node:os'
|
|
3
3
|
import * as path from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
|
-
import { IfNoneMatch } from '@remix-run/headers'
|
|
5
|
+
import { IfNoneMatch } from '@remix-run/headers/if-none-match'
|
|
6
6
|
|
|
7
7
|
import { createAssetServerCompilationError } from '../compilation-error.ts'
|
|
8
8
|
import { createFileMatcher } from '../file-matcher.ts'
|
|
@@ -34,7 +34,6 @@ import { createTsconfigTransformOptionsResolver, transformModule } from './trans
|
|
|
34
34
|
import type { ResolveModuleResult, TransformArgs, TransformedModule } from './transform.ts'
|
|
35
35
|
import { ResolverFactory } from 'oxc-resolver'
|
|
36
36
|
import type { EmittedAsset, EmittedModule } from './emit.ts'
|
|
37
|
-
import { isBareImportSpecifier } from './specifiers.ts'
|
|
38
37
|
|
|
39
38
|
type ScriptRecord = ModuleRecord<TransformedModule, ResolvedModule, EmittedModule>
|
|
40
39
|
type ScriptStore = ModuleStore<TransformedModule, ResolvedModule, EmittedModule>
|
|
@@ -67,7 +66,6 @@ type ScriptCompilerOptions = {
|
|
|
67
66
|
external: string[]
|
|
68
67
|
fingerprintAssets: boolean
|
|
69
68
|
isAllowed(absolutePath: string): boolean
|
|
70
|
-
isDenied(absolutePath: string): boolean
|
|
71
69
|
minify: boolean
|
|
72
70
|
onWatchDirectoriesChange?: (delta: { add: string[]; remove: string[] }) => void
|
|
73
71
|
rootDir: string
|
|
@@ -119,14 +117,8 @@ export function createScriptCompiler(options: ScriptCompilerOptions): ScriptComp
|
|
|
119
117
|
extensionAlias: resolverExtensionAlias,
|
|
120
118
|
extensions: resolverExtensions,
|
|
121
119
|
mainFields: ['browser', 'module', 'main'],
|
|
122
|
-
symlinks: false,
|
|
123
120
|
tsconfig: 'auto',
|
|
124
121
|
})
|
|
125
|
-
let resolveModulePathOptions = {
|
|
126
|
-
isAllowed: resolvedOptions.isAllowed,
|
|
127
|
-
isDenied: resolvedOptions.isDenied,
|
|
128
|
-
routes: resolvedOptions.routes,
|
|
129
|
-
}
|
|
130
122
|
let resolveInFlightByCacheKey = new Map<string, Promise<ResolvedModule>>()
|
|
131
123
|
let emitInFlightByCacheKey = new Map<string, Promise<EmittedModule>>()
|
|
132
124
|
|
|
@@ -146,9 +138,7 @@ export function createScriptCompiler(options: ScriptCompilerOptions): ScriptComp
|
|
|
146
138
|
let resolveArgs: ResolveArgs = {
|
|
147
139
|
isAllowed: resolvedOptions.isAllowed,
|
|
148
140
|
isWatchIgnored,
|
|
149
|
-
resolveModulePath
|
|
150
|
-
return resolveModulePath(absolutePath, resolveModulePathOptions)
|
|
151
|
-
},
|
|
141
|
+
resolveModulePath,
|
|
152
142
|
resolverFactory,
|
|
153
143
|
routes: resolvedOptions.routes,
|
|
154
144
|
}
|
|
@@ -263,7 +253,7 @@ export function createScriptCompiler(options: ScriptCompilerOptions): ScriptComp
|
|
|
263
253
|
}
|
|
264
254
|
|
|
265
255
|
function resolveServedScriptOrThrow(absolutePath: string): ResolveModuleResult {
|
|
266
|
-
let resolvedModule = resolveModulePath(absolutePath
|
|
256
|
+
let resolvedModule = resolveModulePath(absolutePath)
|
|
267
257
|
if (!resolvedModule) {
|
|
268
258
|
throw createAssetServerCompilationError(`File not found: ${absolutePath}`, {
|
|
269
259
|
code: 'FILE_NOT_FOUND',
|
|
@@ -558,19 +548,11 @@ function shouldClearResolverCacheForFileEvent(filePath: string, event: ModuleWat
|
|
|
558
548
|
return event !== 'change' || isPackageJsonPath(filePath) || isTsconfigPath(filePath)
|
|
559
549
|
}
|
|
560
550
|
|
|
561
|
-
function resolveModulePath(
|
|
562
|
-
absolutePath: string,
|
|
563
|
-
options: {
|
|
564
|
-
isAllowed(absolutePath: string): boolean
|
|
565
|
-
isDenied(absolutePath: string): boolean
|
|
566
|
-
routes: CompiledRoutes
|
|
567
|
-
},
|
|
568
|
-
): ResolveModuleResult | null {
|
|
569
|
-
let candidateIdentityPath = normalizeFilePath(absolutePath)
|
|
551
|
+
function resolveModulePath(absolutePath: string): ResolveModuleResult | null {
|
|
570
552
|
let resolvedPath: string
|
|
571
553
|
|
|
572
554
|
try {
|
|
573
|
-
resolvedPath = normalizeFilePath(fs.realpathSync(
|
|
555
|
+
resolvedPath = normalizeFilePath(fs.realpathSync(normalizeFilePath(absolutePath)))
|
|
574
556
|
} catch (error) {
|
|
575
557
|
if (isNoEntityError(error)) return null
|
|
576
558
|
throw error
|
|
@@ -581,32 +563,11 @@ function resolveModulePath(
|
|
|
581
563
|
}
|
|
582
564
|
|
|
583
565
|
return {
|
|
584
|
-
identityPath:
|
|
566
|
+
identityPath: resolvedPath,
|
|
585
567
|
resolvedPath,
|
|
586
568
|
}
|
|
587
569
|
}
|
|
588
570
|
|
|
589
|
-
function getModuleIdentityPath(
|
|
590
|
-
candidateIdentityPath: string,
|
|
591
|
-
resolvedPath: string,
|
|
592
|
-
options: {
|
|
593
|
-
isAllowed(absolutePath: string): boolean
|
|
594
|
-
isDenied(absolutePath: string): boolean
|
|
595
|
-
routes: CompiledRoutes
|
|
596
|
-
},
|
|
597
|
-
): string {
|
|
598
|
-
if (candidateIdentityPath === resolvedPath) return resolvedPath
|
|
599
|
-
if (!containsNodeModulesPathSegment(candidateIdentityPath)) return resolvedPath
|
|
600
|
-
if (!options.routes.toUrlPathname(candidateIdentityPath)) return resolvedPath
|
|
601
|
-
if (!options.isAllowed(candidateIdentityPath)) return resolvedPath
|
|
602
|
-
if (options.isDenied(resolvedPath)) return resolvedPath
|
|
603
|
-
return candidateIdentityPath
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
function containsNodeModulesPathSegment(filePath: string): boolean {
|
|
607
|
-
return filePath.split('/').includes('node_modules')
|
|
608
|
-
}
|
|
609
|
-
|
|
610
571
|
function resolveActualPath(identityPath: string): string | null {
|
|
611
572
|
try {
|
|
612
573
|
return normalizeFilePath(fs.realpathSync(identityPath))
|
|
@@ -616,6 +577,18 @@ function resolveActualPath(identityPath: string): string | null {
|
|
|
616
577
|
}
|
|
617
578
|
}
|
|
618
579
|
|
|
580
|
+
function isBareImportSpecifier(specifier: string): boolean {
|
|
581
|
+
return (
|
|
582
|
+
!specifier.startsWith('./') &&
|
|
583
|
+
!specifier.startsWith('../') &&
|
|
584
|
+
!specifier.startsWith('/') &&
|
|
585
|
+
!specifier.startsWith('file:') &&
|
|
586
|
+
!specifier.startsWith('data:') &&
|
|
587
|
+
!specifier.startsWith('http://') &&
|
|
588
|
+
!specifier.startsWith('https://')
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
|
+
|
|
619
592
|
function isNoEntityError(
|
|
620
593
|
error: unknown,
|
|
621
594
|
): error is NodeJS.ErrnoException & { code: 'ENOENT' | 'ENOTDIR' } {
|
|
@@ -17,7 +17,6 @@ import { normalizeFilePath } from '../paths.ts'
|
|
|
17
17
|
import type { CompiledRoutes } from '../routes.ts'
|
|
18
18
|
import type { ResolveModuleResult, TransformedModule } from './transform.ts'
|
|
19
19
|
import type { EmittedModule } from './emit.ts'
|
|
20
|
-
import { isBareImportSpecifier } from './specifiers.ts'
|
|
21
20
|
|
|
22
21
|
type ScriptRecord = ModuleRecord<TransformedModule, ResolvedModule, EmittedModule>
|
|
23
22
|
|
|
@@ -92,11 +91,6 @@ type NormalizedSpecifierResolution = {
|
|
|
92
91
|
specifier: string
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
type SpecifierResolutionImporter = {
|
|
96
|
-
identityPath: string
|
|
97
|
-
resolvedPath: string
|
|
98
|
-
}
|
|
99
|
-
|
|
100
94
|
export async function resolveModule(
|
|
101
95
|
record: ScriptRecord,
|
|
102
96
|
transformed: TransformedModule,
|
|
@@ -111,10 +105,7 @@ export async function resolveModule(
|
|
|
111
105
|
transformed.unresolvedImports.length > 0
|
|
112
106
|
? await batchResolveSpecifiers(
|
|
113
107
|
getUniqueSpecifiers(transformed.unresolvedImports),
|
|
114
|
-
|
|
115
|
-
identityPath: transformed.identityPath,
|
|
116
|
-
resolvedPath: transformed.resolvedPath,
|
|
117
|
-
},
|
|
108
|
+
transformed.resolvedPath,
|
|
118
109
|
args.resolverFactory,
|
|
119
110
|
)
|
|
120
111
|
: new Map<string, ResolvedSpec>()
|
|
@@ -205,10 +196,8 @@ export async function resolveModule(
|
|
|
205
196
|
deps.add(resolvedImport.identityPath)
|
|
206
197
|
|
|
207
198
|
if (transformed.packageSpecifiers.includes(unresolved.specifier)) {
|
|
208
|
-
let packageJsonPath =
|
|
209
|
-
resolvedSpec.packageJsonPath
|
|
210
|
-
resolvedImport.resolvedPath,
|
|
211
|
-
)
|
|
199
|
+
let packageJsonPath =
|
|
200
|
+
resolvedSpec.packageJsonPath ?? findNearestPackageJsonPath(resolvedImport.resolvedPath)
|
|
212
201
|
if (packageJsonPath && !args.isWatchIgnored(packageJsonPath)) {
|
|
213
202
|
trackedFiles.add(packageJsonPath)
|
|
214
203
|
}
|
|
@@ -246,25 +235,6 @@ export async function resolveModule(
|
|
|
246
235
|
}
|
|
247
236
|
}
|
|
248
237
|
|
|
249
|
-
function resolvePackageJsonPath(
|
|
250
|
-
packageJsonPath: string | null,
|
|
251
|
-
resolvedPath: string,
|
|
252
|
-
): string | null {
|
|
253
|
-
return (
|
|
254
|
-
(packageJsonPath ? resolveExistingPath(packageJsonPath) : null) ??
|
|
255
|
-
findNearestPackageJsonPath(resolvedPath)
|
|
256
|
-
)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function resolveExistingPath(filePath: string): string | null {
|
|
260
|
-
try {
|
|
261
|
-
return normalizeFilePath(fs.realpathSync(filePath))
|
|
262
|
-
} catch (error) {
|
|
263
|
-
if (isNoEntityError(error)) return null
|
|
264
|
-
throw error
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
238
|
function findNearestPackageJsonPath(filePath: string): string | null {
|
|
269
239
|
let directory = path.dirname(filePath)
|
|
270
240
|
|
|
@@ -280,17 +250,6 @@ function findNearestPackageJsonPath(filePath: string): string | null {
|
|
|
280
250
|
}
|
|
281
251
|
}
|
|
282
252
|
|
|
283
|
-
function isNoEntityError(
|
|
284
|
-
error: unknown,
|
|
285
|
-
): error is NodeJS.ErrnoException & { code: 'ENOENT' | 'ENOTDIR' } {
|
|
286
|
-
return (
|
|
287
|
-
error instanceof Error &&
|
|
288
|
-
'code' in error &&
|
|
289
|
-
((error as NodeJS.ErrnoException).code === 'ENOENT' ||
|
|
290
|
-
(error as NodeJS.ErrnoException).code === 'ENOTDIR')
|
|
291
|
-
)
|
|
292
|
-
}
|
|
293
|
-
|
|
294
253
|
function isRelativeImportSpecifier(specifier: string): boolean {
|
|
295
254
|
return specifier.startsWith('./') || specifier.startsWith('../')
|
|
296
255
|
}
|
|
@@ -367,7 +326,7 @@ function resolveCandidateBasePath(importerDir: string, specifier: string): strin
|
|
|
367
326
|
|
|
368
327
|
async function batchResolveSpecifiers(
|
|
369
328
|
specifiers: string[],
|
|
370
|
-
|
|
329
|
+
importerPath: string,
|
|
371
330
|
resolverFactory: ResolveArgs['resolverFactory'],
|
|
372
331
|
): Promise<Map<string, ResolvedSpec>> {
|
|
373
332
|
let resolvedBySpecifier = new Map<string, ResolvedSpec>()
|
|
@@ -375,7 +334,7 @@ async function batchResolveSpecifiers(
|
|
|
375
334
|
|
|
376
335
|
try {
|
|
377
336
|
for (let specifier of specifiers) {
|
|
378
|
-
let normalizedResolution = normalizeSpecifierResolution(specifier,
|
|
337
|
+
let normalizedResolution = normalizeSpecifierResolution(specifier, importerPath)
|
|
379
338
|
let resolutionResult = await resolverFactory.resolveFileAsync(
|
|
380
339
|
normalizedResolution.importerPath,
|
|
381
340
|
normalizedResolution.specifier,
|
|
@@ -409,7 +368,7 @@ async function batchResolveSpecifiers(
|
|
|
409
368
|
}
|
|
410
369
|
|
|
411
370
|
throw createAssetServerCompilationError(
|
|
412
|
-
`Failed to resolve imports in ${
|
|
371
|
+
`Failed to resolve imports in ${importerPath}. ${formatUnknownError(error)}`,
|
|
413
372
|
{
|
|
414
373
|
cause: error,
|
|
415
374
|
code: 'IMPORT_RESOLUTION_FAILED',
|
|
@@ -430,12 +389,12 @@ function formatUnknownError(error: unknown): string {
|
|
|
430
389
|
|
|
431
390
|
function normalizeSpecifierResolution(
|
|
432
391
|
specifier: string,
|
|
433
|
-
|
|
392
|
+
importerPath: string,
|
|
434
393
|
): NormalizedSpecifierResolution {
|
|
435
394
|
let authoredInjectedPackageSpecifier = restoreAuthoredInjectedPackageSpecifier(specifier)
|
|
436
395
|
if (authoredInjectedPackageSpecifier) {
|
|
437
396
|
return {
|
|
438
|
-
importerPath
|
|
397
|
+
importerPath,
|
|
439
398
|
specifier: authoredInjectedPackageSpecifier,
|
|
440
399
|
}
|
|
441
400
|
}
|
|
@@ -448,18 +407,11 @@ function normalizeSpecifierResolution(
|
|
|
448
407
|
}
|
|
449
408
|
|
|
450
409
|
return {
|
|
451
|
-
importerPath
|
|
410
|
+
importerPath,
|
|
452
411
|
specifier,
|
|
453
412
|
}
|
|
454
413
|
}
|
|
455
414
|
|
|
456
|
-
function getSpecifierImporterPath(
|
|
457
|
-
specifier: string,
|
|
458
|
-
importer: SpecifierResolutionImporter,
|
|
459
|
-
): string {
|
|
460
|
-
return isBareImportSpecifier(specifier) ? importer.resolvedPath : importer.identityPath
|
|
461
|
-
}
|
|
462
|
-
|
|
463
415
|
function getDisplayImportSpecifier(specifier: string): string {
|
|
464
416
|
return restoreAuthoredInjectedPackageSpecifier(specifier) ?? specifier
|
|
465
417
|
}
|
|
@@ -30,7 +30,6 @@ import { composeSourceMaps, rewriteSourceMapSources, stringifySourceMap } from '
|
|
|
30
30
|
import type { EmittedModule } from './emit.ts'
|
|
31
31
|
import type { ResolvedScriptTarget } from '../target.ts'
|
|
32
32
|
import type { ResolvedModule } from './resolve.ts'
|
|
33
|
-
import { isBareImportSpecifier } from './specifiers.ts'
|
|
34
33
|
|
|
35
34
|
type ScriptRecord = ModuleRecord<TransformedModule, ResolvedModule, EmittedModule>
|
|
36
35
|
|
|
@@ -262,7 +261,7 @@ export async function transformModule(
|
|
|
262
261
|
content: sourceText,
|
|
263
262
|
}),
|
|
264
263
|
identityPath: record.identityPath,
|
|
265
|
-
importerDir: path.dirname(
|
|
264
|
+
importerDir: path.dirname(resolvedPath),
|
|
266
265
|
packageSpecifiers: analysis.unresolvedImports
|
|
267
266
|
.filter((unresolved) => isBareImportSpecifier(unresolved.specifier))
|
|
268
267
|
.map((unresolved) => unresolved.specifier),
|
|
@@ -300,6 +299,18 @@ function findNearestTsconfigPath(directory: string): string | null {
|
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
301
|
|
|
302
|
+
function isBareImportSpecifier(specifier: string): boolean {
|
|
303
|
+
return (
|
|
304
|
+
!specifier.startsWith('./') &&
|
|
305
|
+
!specifier.startsWith('../') &&
|
|
306
|
+
!specifier.startsWith('/') &&
|
|
307
|
+
!specifier.startsWith('file:') &&
|
|
308
|
+
!specifier.startsWith('data:') &&
|
|
309
|
+
!specifier.startsWith('http://') &&
|
|
310
|
+
!specifier.startsWith('https://')
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
|
|
303
314
|
async function analyzeModuleSource(
|
|
304
315
|
sourceText: string,
|
|
305
316
|
resolvedPath: string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as os from 'node:os'
|
|
2
2
|
import * as path from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import { IfNoneMatch } from '@remix-run/headers'
|
|
4
|
+
import { IfNoneMatch } from '@remix-run/headers/if-none-match'
|
|
5
5
|
import { createFileMatcher } from '../file-matcher.ts'
|
|
6
6
|
import { formatFingerprintedPathname } from '../fingerprint.ts'
|
|
7
7
|
import { createModuleStore } from '../module-store.ts'
|
package/src/lib/watch.ts
CHANGED
|
@@ -101,7 +101,7 @@ function resolveChokidarWatchOptions(
|
|
|
101
101
|
depth: 0,
|
|
102
102
|
ignored: ['**/.git/**', ...(options.ignore ?? [])],
|
|
103
103
|
interval: options.pollInterval ?? 100,
|
|
104
|
-
usePolling: options.poll ??
|
|
104
|
+
usePolling: options.poll ?? process.platform === 'win32',
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"specifiers.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/specifiers.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAUhE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function isBareImportSpecifier(specifier) {
|
|
2
|
-
return (!specifier.startsWith('./') &&
|
|
3
|
-
!specifier.startsWith('../') &&
|
|
4
|
-
!specifier.startsWith('/') &&
|
|
5
|
-
!specifier.startsWith('file:') &&
|
|
6
|
-
!specifier.startsWith('data:') &&
|
|
7
|
-
!specifier.startsWith('http://') &&
|
|
8
|
-
!specifier.startsWith('https://'));
|
|
9
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function isBareImportSpecifier(specifier: string): boolean {
|
|
2
|
-
return (
|
|
3
|
-
!specifier.startsWith('./') &&
|
|
4
|
-
!specifier.startsWith('../') &&
|
|
5
|
-
!specifier.startsWith('/') &&
|
|
6
|
-
!specifier.startsWith('file:') &&
|
|
7
|
-
!specifier.startsWith('data:') &&
|
|
8
|
-
!specifier.startsWith('http://') &&
|
|
9
|
-
!specifier.startsWith('https://')
|
|
10
|
-
)
|
|
11
|
-
}
|