-
-
Notifications
You must be signed in to change notification settings - Fork 7
Implement watch mode #278
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
base: main
Are you sure you want to change the base?
Implement watch mode #278
Conversation
🦋 Changeset detectedLatest commit: 5a3b590 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
869ea8e to
56f6254
Compare
56f6254 to
04e1b6e
Compare
|
TODO: Add tests for |
| emitAndReportDiagnosticsTimer = setTimeout(() => { | ||
| emitAndReportDiagnosticsTimer = undefined; | ||
| emitAndReportDiagnostics().catch(logger.logError.bind(logger)); | ||
| }, 250); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @throws {WriteDtsFileError} | ||
| */ | ||
| async function emitAndReportDiagnostics() { | ||
| logger.clearScreen(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some users may not want the console cleared. We may need to add the --preserveWatchOutput option.
| logger.logDiagnostics(diagnostics); | ||
| } | ||
| logger.logMessage( | ||
| `Found ${diagnostics.length} error${diagnostics.length === 1 ? '' : 's'}. Watching for file changes.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the same format as tsc messages. Users may find it difficult to distinguish whether a message is from tsc or css-modules-kit...
bb76ec3 to
858661d
Compare
352dd22 to
615dc2c
Compare
close: #178
Design Notes:
tsc --watchts.sys.watchDirectory. However, it was unclear whether this API would be provided in ts-go, so it was not adopted.runCMKInWatchModefunction.runCMKInWatchModedelegates most processing toProject.Projectis used by both therunCMKfunction for normal mode and therunCMKInWatchModefunction for watch mode. It implements the common logic for both modes.Project, CSS Module files are parsed and inspected, diagnostics are reported, and .d.ts files are emitted.Projectmaintains internal caches for the parsing, checking, and emitting stages. When notified of file changes byrunCMKInWatchMode, it discards the relevant caches.Project#276