test(ivy): make sure `goog.getMsg()` is defined before being used (#22998)
PR Close #22998
This commit is contained in:
parent
ab348ee2be
commit
d28ce50067
|
@ -27,7 +27,7 @@
|
|||
"name": "HelloWorld"
|
||||
},
|
||||
{
|
||||
"name": "INeedToExistEvenThoughtIAmNotNeeded"
|
||||
"name": "INeedToExistEvenThoughIAmNotNeeded"
|
||||
},
|
||||
{
|
||||
"name": "Immediate"
|
||||
|
|
|
@ -14,7 +14,7 @@ export class HelloWorld {
|
|||
// TODO(misko): Forgetting to export HelloWorld and not having NgModule fails silently.
|
||||
|
||||
@NgModule({declarations: [HelloWorld]})
|
||||
export class INeedToExistEvenThoughtIAmNotNeeded {
|
||||
export class INeedToExistEvenThoughIAmNotNeeded {
|
||||
}
|
||||
// TODO(misko): Package should not be required to make this work.
|
||||
|
||||
|
|
|
@ -14,7 +14,12 @@ ivy_ng_module(
|
|||
|
||||
ng_rollup_bundle(
|
||||
name = "bundle",
|
||||
# Remove once #22913 lands
|
||||
# TODO(alexeagle): This is inconsistent.
|
||||
# We try to teach users to always have their workspace at the start of a
|
||||
# path, to disambiguate from other workspaces.
|
||||
# Here, the rule implementation is looking in an execroot where the layout
|
||||
# has an "external" directory for external dependencies.
|
||||
# This should probably start with "angular/" and let the rule deal with it.
|
||||
entry_point = "packages/core/test/bundling/hello_world_i18n/index.js",
|
||||
deps = [
|
||||
":hello_world_i18n",
|
||||
|
@ -29,8 +34,5 @@ ts_devserver(
|
|||
":bundle.min.js",
|
||||
"index.html",
|
||||
],
|
||||
deps = [
|
||||
# fix for ibazel until https://github.com/angular/angular/pull/22912 gets merged
|
||||
"//packages/compiler",
|
||||
],
|
||||
deps = [],
|
||||
)
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
<!-- The Angular application will be bootstrapped into this element. -->
|
||||
<hello-world></hello-world>
|
||||
|
||||
<!--
|
||||
<!--
|
||||
Script tag which bootstraps the application. Use `?debug` in URL to select
|
||||
the debug version of the script.
|
||||
|
||||
There are two scripts sources: `bundle.min.js` and `bundle.min_debug.js` You can
|
||||
|
||||
There are two scripts sources: `bundle.min.js` and `bundle.min_debug.js` You can
|
||||
switch between which bundle the browser loads to experiment with the application.
|
||||
|
||||
- `bundle.min.js`: Is what the site would serve to their users. It has gone
|
||||
|
@ -23,9 +23,17 @@
|
|||
property renaming.
|
||||
-->
|
||||
<script>
|
||||
document.write('<script src="' +
|
||||
(document.location.search.endsWith('debug') ? '/bundle.min_debug.js' : '/bundle.min.js') +
|
||||
'"></' + 'script>');
|
||||
// `goog.getMsg()` will be provided by Closure
|
||||
const translations = {
|
||||
'Hello World!': 'Bonjour Monde!',
|
||||
'Hello Title!': 'Bonjour Titre!',
|
||||
};
|
||||
window.goog = window.goog || {};
|
||||
window.goog.getMsg = (key) => translations[key] || key;
|
||||
|
||||
document.write('<script src="' +
|
||||
(document.location.search.endsWith('debug') ? '/bundle.min_debug.js' : '/bundle.min.js') +
|
||||
'"></' + 'script>');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -8,15 +8,6 @@
|
|||
|
||||
import {Component, NgModule, ɵrenderComponent as renderComponent} from '@angular/core';
|
||||
|
||||
// simulate translations for now
|
||||
const translations: {[key: string]: string} = {
|
||||
'Hello World!': 'Bonjour Monde!',
|
||||
'Hello Title!': 'Bonjour Titre!',
|
||||
};
|
||||
|
||||
// simulate Google Closure getMsg for now
|
||||
(window as any).goog = {getMsg: (key: string) => { return translations[key] || key; }};
|
||||
|
||||
@Component({
|
||||
selector: 'hello-world',
|
||||
template: `<div i18n i18n-title title="Hello Title!">Hello World!</div>`
|
||||
|
@ -26,7 +17,7 @@ export class HelloWorld {
|
|||
// TODO(misko): Forgetting to export HelloWorld and not having NgModule fails silently.
|
||||
|
||||
@NgModule({declarations: [HelloWorld]})
|
||||
export class INeedToExistEvenThoughtIAmNotNeeded {
|
||||
export class INeedToExistEvenThoughIAmNotNeeded {
|
||||
}
|
||||
// TODO(misko): Package should not be required to make this work.
|
||||
|
||||
|
|
Loading…
Reference in New Issue