Skip to content

Commit

Permalink
perf: replace hashObject w/ stable-hash
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 11, 2024
1 parent 007c5de commit cc6947e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/utils/export-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type {
} from '../types'

import { getValue } from './get-value'
import { hashObject } from './hash'
import { hasValidExtension, ignore } from './ignore'
import { lazy } from './lazy-value'
import { parse } from './parse'
Expand Down Expand Up @@ -60,7 +59,7 @@ export type ModuleImport = {
export class ExportMap {
static for(context: ChildContext) {
const filepath = context.path
const cacheKey = context.cacheKey || hashObject(context).digest('hex')
const cacheKey = context.cacheKey
let exportMap = exportCache.get(cacheKey)

const stats = lazy(() => fs.statSync(context.path))
Expand Down
4 changes: 2 additions & 2 deletions src/utils/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import type {
RuleContext,
} from '../types'

import { hashObject } from './hash'
import { ModuleCache } from './module-cache'
import { pkgDir } from './pkg-dir'

Check failure on line 14 in src/utils/resolve.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on macos-latest

There should be at least one empty line between import groups

Check failure on line 14 in src/utils/resolve.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest

There should be at least one empty line between import groups

Check failure on line 14 in src/utils/resolve.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on ubuntu-latest

There should be at least one empty line between import groups
import stableHash from 'stable-hash'

Check failure on line 15 in src/utils/resolve.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on macos-latest

`stable-hash` import should occur before type import of `../types`

Check failure on line 15 in src/utils/resolve.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest

`stable-hash` import should occur before type import of `../types`

Check failure on line 15 in src/utils/resolve.ts

View workflow job for this annotation

GitHub Actions / Lint and Test with Node.js 20 and ESLint 8 on ubuntu-latest

`stable-hash` import should occur before type import of `../types`

export type ResultNotFound = {
found: false
Expand Down Expand Up @@ -139,7 +139,7 @@ function fullResolve(
const sourceDir = path.dirname(sourceFile)

if (prevSettings !== settings) {
memoizedHash = hashObject(settings).digest('hex')
memoizedHash = stableHash(settings)
prevSettings = settings
}

Expand Down

0 comments on commit cc6947e

Please sign in to comment.