Skip to content
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

fix(common): workaround UMD/webpack limitation #23271

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/bazel/test/ng_package/common_package.spec.ts
Expand Up @@ -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', () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/common/locales/BUILD.bazel
Expand Up @@ -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"],
)