0
ts_devserver(
    name = "devserver",
    additional_root_paths = ["project/src/_"],
    entry_module = "project/src/main.dev",
    port = 4200,
    scripts = [
        "@npm//:node_modules/tslib/tslib.js",
        "@npm//:node_modules/@angular/localize/bundles/localize-init.umd.js",
        "@npm//:node_modules/@angular/common/locales/es-MX.js",
        "@npm//date-fns:date-fns.umd.js",
        "@npm//immutable:immutable.umd.js",
        ":date_fns_locale_umd",
    ],
    serving_path = "/bundle.min.js",
    static_files = [
        "@npm//:node_modules/zone.js/dist/zone.min.js",
        ":global_stylesheet",
        ":asset_injected_index_html",
        "favicon.ico",
        "manifest.json"
    ],
    deps = [
        ":polyfills",
        ":bazel_umd_modules",
        ":src"
        ],
)

我收到以下错误

Uncaught Error: It looks like your application or one of its dependencies is using i18n.
Angular 9 introduced a global `$localize()` function that needs to be loaded.
Please run `ng add @angular/localize` from the Angular CLI.
(For non-CLI projects, add `import '@angular/localize/init';` to your `polyfills.ts` file.
For server-side rendering applications add the import to your `main.server.ts` file.)
    at _global.$localize (core.umd.js:32815)
    at Object.eval (ng-bootstrap.umd.js:63)
    at Object.execCb (es-MX.ts:78)
    at Module.check (es-MX.ts:78)
    at Module.enable (es-MX.ts:78)
    at Object.enable (es-MX.ts:78)
    at Module.<anonymous> (es-MX.ts:78)
    at es-MX.ts:78
    at each (es-MX.ts:53)
    at Module.enable (es-MX.ts:78)

polyfills.ts 是一个 ts_library()

import '@angular/localize/init';

我现在不知道为什么在应用程序启动之前如何初始化......在测试中,我通过添加//src:polyfills到 runtime_deps 并在 srcs 中本地化 init 来做到这一点。

有任何想法吗?

4

1 回答 1

0

我解决了这个问题,将此脚本添加到 ts_devserver 引导程序

ts_devserver(
    name = "devserver",
    additional_root_paths = ["project/src/_"],
    bootstrap = [
        "@npm//:node_modules/@angular/localize/bundles/localize-init.umd.js",
    ]
)
于 2021-01-07T10:38:40.093 回答