-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): localized bundle generation fails…
… in watch mode Previously, we used to delete the temporary emitted JS and map files. However this causes a problem in watch mode, as Webpack will not re-emit these deleted files during the next incremental re-build. With this change we now delete the entire temporary directory when the process is being terminated instead of a file by file bases. Closes #22395
- Loading branch information
1 parent
08152f7
commit 0d68ed5
Showing
5 changed files
with
135 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...s/angular_devkit/build_angular/src/builders/browser/tests/behavior/localize_watch_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { concatMap, count, take, timeout } from 'rxjs/operators'; | ||
import { BUILD_TIMEOUT, buildWebpackBrowser } from '../../index'; | ||
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "localize works in watch mode"', () => { | ||
beforeEach(() => { | ||
harness.useProject('test', { | ||
root: '.', | ||
sourceRoot: 'src', | ||
cli: { | ||
cache: { | ||
enabled: false, | ||
}, | ||
}, | ||
i18n: { | ||
locales: { | ||
'fr': 'src/locales/messages.fr.xlf', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('localize works in watch mode', async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
watch: true, | ||
localize: true, | ||
}); | ||
|
||
await harness.writeFile( | ||
'src/app/app.component.html', | ||
` | ||
<p id="hello" i18n="An introduction header for this sample">Hello {{ title }}! </p> | ||
`, | ||
); | ||
|
||
await harness.writeFile('src/locales/messages.fr.xlf', TRANSLATION_FILE_CONTENT); | ||
|
||
const buildCount = await harness | ||
.execute() | ||
.pipe( | ||
timeout(BUILD_TIMEOUT), | ||
concatMap(async ({ result }, index) => { | ||
expect(result?.success).toBe(true); | ||
|
||
switch (index) { | ||
case 0: { | ||
harness.expectFile('dist/fr/main.js').content.toContain('Bonjour'); | ||
|
||
// Trigger rebuild | ||
await harness.appendToFile('src/app/app.component.html', '\n\n'); | ||
break; | ||
} | ||
case 1: { | ||
harness.expectFile('dist/fr/main.js').content.toContain('Bonjour'); | ||
break; | ||
} | ||
} | ||
}), | ||
take(2), | ||
count(), | ||
) | ||
.toPromise(); | ||
|
||
expect(buildCount).toBe(2); | ||
}); | ||
}); | ||
}); | ||
|
||
const TRANSLATION_FILE_CONTENT = ` | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> | ||
<file target-language="en-US" datatype="plaintext" original="ng2.template"> | ||
<body> | ||
<trans-unit id="4286451273117902052" datatype="html"> | ||
<target>Bonjour <x id="INTERPOLATION" equiv-text="{{ title }}"/>! </target> | ||
<context-group purpose="location"> | ||
<context context-type="targetfile">src/app/app.component.html</context> | ||
<context context-type="linenumber">2,3</context> | ||
</context-group> | ||
<note priority="1" from="description">An introduction header for this sample</note> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters