-
Notifications
You must be signed in to change notification settings - Fork 12k
Fix file watching with file replacements #11509
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
Conversation
820ad16
to
971fdeb
Compare
|
||
export function normalizeFileReplacements( |
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.
Nit: file name does not match export name.
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.
Done.
@@ -0,0 +1,31 @@ | |||
import { getGlobalVariable } from '../../utils/env'; |
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.
WDYT of replacing this with a new spec large in replacements_spec_large
?
This is the one I had on my branch:
it('file replacements work with watch mode', (done) => {
const overrides = {
fileReplacements: [
{
replace: normalize('/src/meaning.ts'),
with: normalize('/src/meaning-too.ts'),
},
],
watch: true,
};
let buildNumber = 0;
runTargetSpec(host, browserTargetSpec, overrides, 45000, createConsoleLogger()).pipe(
debounceTime(1000),
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
tap(() => {
const fileName = join(outputPath, 'main.js');
buildNumber += 1;
switch (buildNumber) {
case 1:
expect(virtualFs.fileBufferToString(host.scopedSync().read(fileName)))
.toMatch(/meaning\s*=\s*42/);
expect(virtualFs.fileBufferToString(host.scopedSync().read(fileName)))
.not.toMatch(/meaning\s*=\s*10/);
host.writeMultipleFiles({
'src/meaning-too.ts': 'export var meaning = 84;',
});
break;
case 2:
expect(virtualFs.fileBufferToString(host.scopedSync().read(fileName)))
.toMatch(/meaning\s*=\s*84/);
expect(virtualFs.fileBufferToString(host.scopedSync().read(fileName)))
.not.toMatch(/meaning\s*=\s*42/);
break;
}
}),
take(2),
).toPromise().then(done, done.fail);
});
It should be faster than the e2e and also test the content is correct.
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.
Added.
Also I think this fixes #7305 |
971fdeb
to
838b2f4
Compare
LGTM, great work! |
I fear this doesn't cover the NativeScript case with pattern matching (matching all |
Based on the custom host found here, code similar to the following should work:
Another option with this PR is to try to use the PlatformFSPlugin which appears to be used within the non-Angular demos found in the repository. |
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. |
Fixes #11339