@remix-run/assets 0.4.0 → 0.4.2

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,5 +1,4 @@
1
1
  type AccessPolicy = {
2
- isDenied(filePath: string): boolean;
3
2
  isAllowed(filePath: string): boolean;
4
3
  };
5
4
  export declare function createAccessPolicy(options: {
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/lib/access.ts"],"names":[],"mappings":"AAGA,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;IACnC,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,CAoBf"}
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"}
@@ -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 (isDenied(filePath))
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,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,UAAU,kBAAkB;IAC1B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,KAAK,eAAe,GAAG,QAAQ,GAAG,UAAU,CAAA;AAC5C,KAAK,yBAAyB,GAAG,KAAK,GAAG,UAAU,CAAA;AAEnD,UAAU,wBAAwB;IAChC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAID;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,UAAU,SAAS,wBAAwB,GAAG,EAAE;IAClF,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAA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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"}
@@ -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";
@@ -25,7 +25,6 @@ type ScriptCompilerOptions = {
25
25
  external: string[];
26
26
  fingerprintAssets: boolean;
27
27
  isAllowed(absolutePath: string): boolean;
28
- isDenied(absolutePath: string): boolean;
29
28
  minify: boolean;
30
29
  onWatchDirectoriesChange?: (delta: {
31
30
  add: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/lib/scripts/compiler.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAA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'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";
@@ -30,14 +30,8 @@ export function createScriptCompiler(options) {
30
30
  extensionAlias: resolverExtensionAlias,
31
31
  extensions: resolverExtensions,
32
32
  mainFields: ['browser', 'module', 'main'],
33
- symlinks: false,
34
33
  tsconfig: 'auto',
35
34
  });
36
- let resolveModulePathOptions = {
37
- isAllowed: resolvedOptions.isAllowed,
38
- isDenied: resolvedOptions.isDenied,
39
- routes: resolvedOptions.routes,
40
- };
41
35
  let resolveInFlightByCacheKey = new Map();
42
36
  let emitInFlightByCacheKey = new Map();
43
37
  let transformArgs = {
@@ -56,9 +50,7 @@ export function createScriptCompiler(options) {
56
50
  let resolveArgs = {
57
51
  isAllowed: resolvedOptions.isAllowed,
58
52
  isWatchIgnored,
59
- resolveModulePath(absolutePath) {
60
- return resolveModulePath(absolutePath, resolveModulePathOptions);
61
- },
53
+ resolveModulePath,
62
54
  resolverFactory,
63
55
  routes: resolvedOptions.routes,
64
56
  };
@@ -152,7 +144,7 @@ export function createScriptCompiler(options) {
152
144
  return resolveFilePath(resolvedOptions.rootDir, filePath);
153
145
  }
154
146
  function resolveServedScriptOrThrow(absolutePath) {
155
- let resolvedModule = resolveModulePath(absolutePath, resolveModulePathOptions);
147
+ let resolvedModule = resolveModulePath(absolutePath);
156
148
  if (!resolvedModule) {
157
149
  throw createAssetServerCompilationError(`File not found: ${absolutePath}`, {
158
150
  code: 'FILE_NOT_FOUND',
@@ -374,11 +366,10 @@ function isTsconfigPath(filePath) {
374
366
  function shouldClearResolverCacheForFileEvent(filePath, event) {
375
367
  return event !== 'change' || isPackageJsonPath(filePath) || isTsconfigPath(filePath);
376
368
  }
377
- function resolveModulePath(absolutePath, options) {
378
- let candidateIdentityPath = normalizeFilePath(absolutePath);
369
+ function resolveModulePath(absolutePath) {
379
370
  let resolvedPath;
380
371
  try {
381
- resolvedPath = normalizeFilePath(fs.realpathSync(candidateIdentityPath));
372
+ resolvedPath = normalizeFilePath(fs.realpathSync(normalizeFilePath(absolutePath)));
382
373
  }
383
374
  catch (error) {
384
375
  if (isNoEntityError(error))
@@ -389,26 +380,10 @@ function resolveModulePath(absolutePath, options) {
389
380
  return null;
390
381
  }
391
382
  return {
392
- identityPath: getModuleIdentityPath(candidateIdentityPath, resolvedPath, options),
383
+ identityPath: resolvedPath,
393
384
  resolvedPath,
394
385
  };
395
386
  }
396
- function getModuleIdentityPath(candidateIdentityPath, resolvedPath, options) {
397
- if (candidateIdentityPath === resolvedPath)
398
- return resolvedPath;
399
- if (!containsNodeModulesPathSegment(candidateIdentityPath))
400
- return resolvedPath;
401
- if (!options.routes.toUrlPathname(candidateIdentityPath))
402
- return resolvedPath;
403
- if (!options.isAllowed(candidateIdentityPath))
404
- return resolvedPath;
405
- if (options.isDenied(resolvedPath))
406
- return resolvedPath;
407
- return candidateIdentityPath;
408
- }
409
- function containsNodeModulesPathSegment(filePath) {
410
- return filePath.split('/').includes('node_modules');
411
- }
412
387
  function resolveActualPath(identityPath) {
413
388
  try {
414
389
  return normalizeFilePath(fs.realpathSync(identityPath));
@@ -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,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CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,cAAc,CAAA;CACzB,GAAG,CACA;IACE,EAAE,EAAE,IAAI,CAAA;IACR,KAAK,EAAE,cAAc,CAAA;CACtB,GACD;IACE,EAAE,EAAE,KAAK,CAAA;IACT,KAAK,EAAE,2BAA2B,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"}
@@ -18,7 +18,7 @@ export async function resolveModule(record, transformed, args) {
18
18
  try {
19
19
  resolvedImports =
20
20
  transformed.unresolvedImports.length > 0
21
- ? await batchResolveSpecifiers(getUniqueSpecifiers(transformed.unresolvedImports), transformed.identityPath, args.resolverFactory)
21
+ ? await batchResolveSpecifiers(getUniqueSpecifiers(transformed.unresolvedImports), transformed.resolvedPath, args.resolverFactory)
22
22
  : new Map();
23
23
  }
24
24
  catch (error) {
@@ -60,7 +60,7 @@ export async function resolveModule(record, transformed, args) {
60
60
  }
61
61
  deps.add(resolvedImport.identityPath);
62
62
  if (transformed.packageSpecifiers.includes(unresolved.specifier)) {
63
- let packageJsonPath = resolvePackageJsonPath(resolvedSpec.packageJsonPath, resolvedImport.resolvedPath);
63
+ let packageJsonPath = resolvedSpec.packageJsonPath ?? findNearestPackageJsonPath(resolvedImport.resolvedPath);
64
64
  if (packageJsonPath && !args.isWatchIgnored(packageJsonPath)) {
65
65
  trackedFiles.add(packageJsonPath);
66
66
  }
@@ -94,20 +94,6 @@ export async function resolveModule(record, transformed, args) {
94
94
  },
95
95
  };
96
96
  }
97
- function resolvePackageJsonPath(packageJsonPath, resolvedPath) {
98
- return ((packageJsonPath ? resolveExistingPath(packageJsonPath) : null) ??
99
- findNearestPackageJsonPath(resolvedPath));
100
- }
101
- function resolveExistingPath(filePath) {
102
- try {
103
- return normalizeFilePath(fs.realpathSync(filePath));
104
- }
105
- catch (error) {
106
- if (isNoEntityError(error))
107
- return null;
108
- throw error;
109
- }
110
- }
111
97
  function findNearestPackageJsonPath(filePath) {
112
98
  let directory = path.dirname(filePath);
113
99
  while (true) {
@@ -121,12 +107,6 @@ function findNearestPackageJsonPath(filePath) {
121
107
  directory = parentDirectory;
122
108
  }
123
109
  }
124
- function isNoEntityError(error) {
125
- return (error instanceof Error &&
126
- 'code' in error &&
127
- (error.code === 'ENOENT' ||
128
- error.code === 'ENOTDIR'));
129
- }
130
110
  function isRelativeImportSpecifier(specifier) {
131
111
  return specifier.startsWith('./') || specifier.startsWith('../');
132
112
  }
@@ -141,9 +141,9 @@ export async function transformModule(record, args) {
141
141
  content: sourceText,
142
142
  }),
143
143
  identityPath: record.identityPath,
144
- importerDir: path.dirname(record.identityPath),
144
+ importerDir: path.dirname(resolvedPath),
145
145
  packageSpecifiers: analysis.unresolvedImports
146
- .filter((unresolved) => isPackageImportSpecifier(unresolved.specifier))
146
+ .filter((unresolved) => isBareImportSpecifier(unresolved.specifier))
147
147
  .map((unresolved) => unresolved.specifier),
148
148
  rawCode: analysis.rawCode,
149
149
  resolvedPath,
@@ -177,8 +177,14 @@ function findNearestTsconfigPath(directory) {
177
177
  currentDirectory = parentDirectory;
178
178
  }
179
179
  }
180
- function isPackageImportSpecifier(specifier) {
181
- return !specifier.startsWith('./') && !specifier.startsWith('../') && !specifier.startsWith('/');
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://'));
182
188
  }
183
189
  async function analyzeModuleSource(sourceText, resolvedPath, transformOptions, options) {
184
190
  let maskedSourceText = maskAuthoredInjectedPackageImports(sourceText, resolvedPath);
@@ -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 ?? false,
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.0",
3
+ "version": "0.4.2",
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.4",
42
- "@remix-run/headers": "0.20.0",
41
+ "@remix-run/file-storage": "0.13.6",
43
42
  "@remix-run/mime": "0.4.1",
44
- "@remix-run/route-pattern": "0.21.0"
43
+ "@remix-run/route-pattern": "0.22.0",
44
+ "@remix-run/headers": "0.21.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.2.0",
51
- "@remix-run/test": "0.4.0"
50
+ "@remix-run/assert": "0.2.1",
51
+ "@remix-run/test": "0.4.2"
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 (isDenied(filePath)) return false
22
+ if (denyMatchers.length > 0 && denyMatchers.some((matcher) => matcher(filePath))) return false
30
23
  return true
31
24
  },
32
25
  }
@@ -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'
@@ -66,7 +66,6 @@ type ScriptCompilerOptions = {
66
66
  external: string[]
67
67
  fingerprintAssets: boolean
68
68
  isAllowed(absolutePath: string): boolean
69
- isDenied(absolutePath: string): boolean
70
69
  minify: boolean
71
70
  onWatchDirectoriesChange?: (delta: { add: string[]; remove: string[] }) => void
72
71
  rootDir: string
@@ -118,14 +117,8 @@ export function createScriptCompiler(options: ScriptCompilerOptions): ScriptComp
118
117
  extensionAlias: resolverExtensionAlias,
119
118
  extensions: resolverExtensions,
120
119
  mainFields: ['browser', 'module', 'main'],
121
- symlinks: false,
122
120
  tsconfig: 'auto',
123
121
  })
124
- let resolveModulePathOptions = {
125
- isAllowed: resolvedOptions.isAllowed,
126
- isDenied: resolvedOptions.isDenied,
127
- routes: resolvedOptions.routes,
128
- }
129
122
  let resolveInFlightByCacheKey = new Map<string, Promise<ResolvedModule>>()
130
123
  let emitInFlightByCacheKey = new Map<string, Promise<EmittedModule>>()
131
124
 
@@ -145,9 +138,7 @@ export function createScriptCompiler(options: ScriptCompilerOptions): ScriptComp
145
138
  let resolveArgs: ResolveArgs = {
146
139
  isAllowed: resolvedOptions.isAllowed,
147
140
  isWatchIgnored,
148
- resolveModulePath(absolutePath) {
149
- return resolveModulePath(absolutePath, resolveModulePathOptions)
150
- },
141
+ resolveModulePath,
151
142
  resolverFactory,
152
143
  routes: resolvedOptions.routes,
153
144
  }
@@ -262,7 +253,7 @@ export function createScriptCompiler(options: ScriptCompilerOptions): ScriptComp
262
253
  }
263
254
 
264
255
  function resolveServedScriptOrThrow(absolutePath: string): ResolveModuleResult {
265
- let resolvedModule = resolveModulePath(absolutePath, resolveModulePathOptions)
256
+ let resolvedModule = resolveModulePath(absolutePath)
266
257
  if (!resolvedModule) {
267
258
  throw createAssetServerCompilationError(`File not found: ${absolutePath}`, {
268
259
  code: 'FILE_NOT_FOUND',
@@ -557,19 +548,11 @@ function shouldClearResolverCacheForFileEvent(filePath: string, event: ModuleWat
557
548
  return event !== 'change' || isPackageJsonPath(filePath) || isTsconfigPath(filePath)
558
549
  }
559
550
 
560
- function resolveModulePath(
561
- absolutePath: string,
562
- options: {
563
- isAllowed(absolutePath: string): boolean
564
- isDenied(absolutePath: string): boolean
565
- routes: CompiledRoutes
566
- },
567
- ): ResolveModuleResult | null {
568
- let candidateIdentityPath = normalizeFilePath(absolutePath)
551
+ function resolveModulePath(absolutePath: string): ResolveModuleResult | null {
569
552
  let resolvedPath: string
570
553
 
571
554
  try {
572
- resolvedPath = normalizeFilePath(fs.realpathSync(candidateIdentityPath))
555
+ resolvedPath = normalizeFilePath(fs.realpathSync(normalizeFilePath(absolutePath)))
573
556
  } catch (error) {
574
557
  if (isNoEntityError(error)) return null
575
558
  throw error
@@ -580,32 +563,11 @@ function resolveModulePath(
580
563
  }
581
564
 
582
565
  return {
583
- identityPath: getModuleIdentityPath(candidateIdentityPath, resolvedPath, options),
566
+ identityPath: resolvedPath,
584
567
  resolvedPath,
585
568
  }
586
569
  }
587
570
 
588
- function getModuleIdentityPath(
589
- candidateIdentityPath: string,
590
- resolvedPath: string,
591
- options: {
592
- isAllowed(absolutePath: string): boolean
593
- isDenied(absolutePath: string): boolean
594
- routes: CompiledRoutes
595
- },
596
- ): string {
597
- if (candidateIdentityPath === resolvedPath) return resolvedPath
598
- if (!containsNodeModulesPathSegment(candidateIdentityPath)) return resolvedPath
599
- if (!options.routes.toUrlPathname(candidateIdentityPath)) return resolvedPath
600
- if (!options.isAllowed(candidateIdentityPath)) return resolvedPath
601
- if (options.isDenied(resolvedPath)) return resolvedPath
602
- return candidateIdentityPath
603
- }
604
-
605
- function containsNodeModulesPathSegment(filePath: string): boolean {
606
- return filePath.split('/').includes('node_modules')
607
- }
608
-
609
571
  function resolveActualPath(identityPath: string): string | null {
610
572
  try {
611
573
  return normalizeFilePath(fs.realpathSync(identityPath))
@@ -105,7 +105,7 @@ export async function resolveModule(
105
105
  transformed.unresolvedImports.length > 0
106
106
  ? await batchResolveSpecifiers(
107
107
  getUniqueSpecifiers(transformed.unresolvedImports),
108
- transformed.identityPath,
108
+ transformed.resolvedPath,
109
109
  args.resolverFactory,
110
110
  )
111
111
  : new Map<string, ResolvedSpec>()
@@ -196,10 +196,8 @@ export async function resolveModule(
196
196
  deps.add(resolvedImport.identityPath)
197
197
 
198
198
  if (transformed.packageSpecifiers.includes(unresolved.specifier)) {
199
- let packageJsonPath = resolvePackageJsonPath(
200
- resolvedSpec.packageJsonPath,
201
- resolvedImport.resolvedPath,
202
- )
199
+ let packageJsonPath =
200
+ resolvedSpec.packageJsonPath ?? findNearestPackageJsonPath(resolvedImport.resolvedPath)
203
201
  if (packageJsonPath && !args.isWatchIgnored(packageJsonPath)) {
204
202
  trackedFiles.add(packageJsonPath)
205
203
  }
@@ -237,25 +235,6 @@ export async function resolveModule(
237
235
  }
238
236
  }
239
237
 
240
- function resolvePackageJsonPath(
241
- packageJsonPath: string | null,
242
- resolvedPath: string,
243
- ): string | null {
244
- return (
245
- (packageJsonPath ? resolveExistingPath(packageJsonPath) : null) ??
246
- findNearestPackageJsonPath(resolvedPath)
247
- )
248
- }
249
-
250
- function resolveExistingPath(filePath: string): string | null {
251
- try {
252
- return normalizeFilePath(fs.realpathSync(filePath))
253
- } catch (error) {
254
- if (isNoEntityError(error)) return null
255
- throw error
256
- }
257
- }
258
-
259
238
  function findNearestPackageJsonPath(filePath: string): string | null {
260
239
  let directory = path.dirname(filePath)
261
240
 
@@ -271,17 +250,6 @@ function findNearestPackageJsonPath(filePath: string): string | null {
271
250
  }
272
251
  }
273
252
 
274
- function isNoEntityError(
275
- error: unknown,
276
- ): error is NodeJS.ErrnoException & { code: 'ENOENT' | 'ENOTDIR' } {
277
- return (
278
- error instanceof Error &&
279
- 'code' in error &&
280
- ((error as NodeJS.ErrnoException).code === 'ENOENT' ||
281
- (error as NodeJS.ErrnoException).code === 'ENOTDIR')
282
- )
283
- }
284
-
285
253
  function isRelativeImportSpecifier(specifier: string): boolean {
286
254
  return specifier.startsWith('./') || specifier.startsWith('../')
287
255
  }
@@ -261,9 +261,9 @@ export async function transformModule(
261
261
  content: sourceText,
262
262
  }),
263
263
  identityPath: record.identityPath,
264
- importerDir: path.dirname(record.identityPath),
264
+ importerDir: path.dirname(resolvedPath),
265
265
  packageSpecifiers: analysis.unresolvedImports
266
- .filter((unresolved) => isPackageImportSpecifier(unresolved.specifier))
266
+ .filter((unresolved) => isBareImportSpecifier(unresolved.specifier))
267
267
  .map((unresolved) => unresolved.specifier),
268
268
  rawCode: analysis.rawCode,
269
269
  resolvedPath,
@@ -299,8 +299,16 @@ function findNearestTsconfigPath(directory: string): string | null {
299
299
  }
300
300
  }
301
301
 
302
- function isPackageImportSpecifier(specifier: string): boolean {
303
- return !specifier.startsWith('./') && !specifier.startsWith('../') && !specifier.startsWith('/')
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
+ )
304
312
  }
305
313
 
306
314
  async function analyzeModuleSource(
@@ -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 ?? false,
104
+ usePolling: options.poll ?? process.platform === 'win32',
105
105
  }
106
106
  }
107
107