Skip to content

Commit

Permalink
fix(canvas) Tweaks from PR feedback.
Browse files Browse the repository at this point in the history
- Speed improvement to `projectContentsSameForRefreshRequire`.
- Remove unused code.
  • Loading branch information
seanparsons committed Oct 22, 2024
1 parent 9dad5dd commit 112d15b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 4 additions & 0 deletions editor/src/components/canvas/canvas-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,10 @@ export function projectContentsSameForRefreshRequire(
} else {
for (const [filename, oldProjectTree] of Object.entries(oldProjectContents)) {
const newProjectTree = newProjectContents[filename]
// No need to check these further if they have the same reference.
if (oldProjectTree === newProjectTree) {
continue
}
// If the file can't be found in the other tree, the imports are not the same.
if (newProjectTree == null) {
return false
Expand Down
12 changes: 1 addition & 11 deletions editor/src/components/editor/import-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
NodeModules,
} from '../../core/shared/project-file-types'
import { importAlias, importDetails, importsResolution } from '../../core/shared/project-file-types'
import { walkContentsTreeForParseSuccess, type ProjectContentTreeRoot } from '../assets'
import type { ProjectContentTreeRoot } from '../assets'
import type { BuiltInDependencies } from '../../core/es-modules/package-manager/built-in-dependencies-list'
import { withUnderlyingTarget } from './store/editor-state'
import * as EP from '../../core/shared/element-path'
Expand Down Expand Up @@ -366,13 +366,3 @@ function removeImportDetails(
importedFromWithin: importedFromWithin,
}
}

export function getProjectImports(projectContents: ProjectContentTreeRoot): {
[filename: string]: Imports
} {
let result: { [filename: string]: Imports } = {}
walkContentsTreeForParseSuccess(projectContents, (filePath, parseSuccess) => {
result[filePath] = parseSuccess.imports
})
return result
}

0 comments on commit 112d15b

Please sign in to comment.