diff --git a/packages/bazel/test/ng_package/common_package.spec.ts b/packages/bazel/test/ng_package/common_package.spec.ts index f64b10b0af..81d8b32012 100644 --- a/packages/bazel/test/ng_package/common_package.spec.ts +++ b/packages/bazel/test/ng_package/common_package.spec.ts @@ -24,6 +24,10 @@ describe('@angular/common ng_package', () => { expect(files.some(n => n.endsWith('.d.ts'))).toBe(true, `.d.ts files don't exist`); expect(files.some(n => n.endsWith('.js'))).toBe(true, `.js files don't exist`); }); + // regression test for https://github.com/angular/angular/issues/23217 + // Note, we don't have an e2e test that covers this + it('doesn\'t pass require in a way that breaks webpack static analysis', + () => { expect(shx.cat('locales/fr.js')).not.toContain('factory(require, exports)'); }); }); it('should have right bundle files', () => { diff --git a/packages/common/locales/BUILD.bazel b/packages/common/locales/BUILD.bazel index c061c1b6f7..8691c75962 100644 --- a/packages/common/locales/BUILD.bazel +++ b/packages/common/locales/BUILD.bazel @@ -13,5 +13,14 @@ ts_library( npm_package( name = "package", + replacements = { + # Workaround for https://github.com/angular/angular/issues/23217 + # Webpack will detect that the UMD outputs from TypeScript pass the + # `require` function into the module, and cannot accurately track + # dependencies in case require was called. + # We don't actually import anything in the locale code so we can + # null out the require reference passed into the module. + "factory\(require, exports\)": "factory(null, exports)", + }, deps = [":locales"], )