-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Type checker replacements #12419
Type checker replacements #12419
Conversation
07ad28d
to
504d8e2
Compare
const logger = new TestLogger('rebuild-type-errors'); | ||
|
||
// Race between a timeout and the expected log entry. | ||
const stop$ = race<null | string>( |
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.
Wouldn't the below result in the same test?
let errorAdded = false;
runTargetSpec(host, browserTargetSpec, overrides, DefaultTimeout, logger)
.pipe(
tap((buildEvent) => expect(buildEvent.success).toBe(true, 'build should succeed')),
tap(() => {
// Introduce a known type error to detect in the logger filter.
if (!errorAdded) {
host.appendToFile('src/main.ts', 'console.log({}.prop);');
errorAdded = true;
} else {
expect(logger).toContain(expectedError);
}
}),
tap(() => {
expect(logger).not.toContain(unexpectedError);
logger.clear();
}),
take(2),
).toPromise().then(done, done.fail);
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.
No, because the type checker logs are not synchronized with builds. Since the type checker runs separately, it will finish rebuilds separately from the main webpack process.
In this specific case, the type checker rebuild will take longer. We need to start a build and and rebuild on the main compilation process, then wait for the forked process to send logs messages.
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.
Ah cause it runs in a forked process. 👍 Cool test with the race :)
Looks like you shouldn't pass the |
@alan-agius4 I think it's not the logger since karma doesn't import it directly, but rather the circular dependency between the type checker and compiler plugin introduced by the new message. I'll refactor the messages into a separate file. |
504d8e2
to
fc7c690
Compare
fc7c690
to
8aa8315
Compare
There's a more fundamental issue with the forked type checker. It directly accesses the file system whereas the actual build uses the webpack file system (and host augmentations from within the plugin). The forked type checker should ideally have a custom compiler host that uses IPC to request file content from the main process to ensure the same content is used to type check and build. |
@alan-agius4 ran some debugging on the circular object reported by Karma and indeed it's the logger property inside the @clydin that's probably the best approach, yeah. Unsure of the limitation on Node's child process IPC channel used here for logging (https://nodejs.org/api/child_process.html). I think it's very likely that the main thread is blocked transferring large files. Doing that properly is essentially a virtual FS server, something that I discussed with @hansl in the past. Not transferring unchanged files is very important in that scenario too. |
Blocked on karma-runner/karma#3154 |
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.
LGTM.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.