Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize watched directories #623

Merged
merged 8 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/ember-auto-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@
"fs-extra": "^10.0.0",
"fs-tree-diff": "^2.0.0",
"handlebars": "^4.3.1",
"is-subdir": "^1.2.0",
"js-string-escape": "^1.0.1",
"lodash": "^4.17.19",
"mini-css-extract-plugin": "^2.5.2",
"minimatch": "^3.0.0",
"parse5": "^6.0.1",
"pkg-entry-points": "^1.1.0",
"resolve": "^1.20.0",
"resolve-package-path": "^4.0.3",
"semver": "^7.3.4",
Expand Down
3 changes: 3 additions & 0 deletions packages/ember-auto-import/ts/auto-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import type { TransformOptions } from '@babel/core';
import { MARKER } from './analyzer-syntax';
import path from 'path';
import funnel from 'broccoli-funnel';
import makeDebug from 'debug';

const debugTree = buildDebugCallback('ember-auto-import');
const debugWatch = makeDebug('ember-auto-import:watch');

// This interface must be stable across all versions of ember-auto-import that
// speak the same leader-election protocol. So don't change this unless you know
Expand Down Expand Up @@ -244,6 +246,7 @@ function depsFor(allAppTree: Node, packages: Set<Package>) {
let watched = pkg.watchedDirectories;
if (watched) {
deps = deps.concat(watched.map((dir) => new WatchedDir(dir)));
debugWatch(`Adding watched directories: ${watched.join(', ')}`);
}
}
return deps;
Expand Down
9 changes: 6 additions & 3 deletions packages/ember-auto-import/ts/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { PluginItem, TransformOptions } from '@babel/core';
import { MacrosConfig } from '@embroider/macros/src/node';
import minimatch from 'minimatch';
import { stripQuery } from './util';
import { getWatchedDirectories } from './watch-utils';

// from child addon instance to their parent package
const parentCache: WeakMap<AddonInstance, Package> = new WeakMap();
Expand Down Expand Up @@ -514,13 +515,15 @@ export default class Package {
for (let name of names) {
let path = resolvePackagePath(name, cursor);
if (!path) {
return undefined;
return [];
}
cursor = dirname(path);
}
return cursor;
return getWatchedDirectories(cursor).map((relativeDir) =>
join(cursor, relativeDir)
);
})
.filter(Boolean) as string[];
.flat();
}
}

Expand Down
Loading
Loading