Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/angular/ssr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ ng_package(
"@angular/ssr/node",
"../../third_party/beasties",
],
extra_substitutions = {
# Needed for ssr.d.ts file
"\\./third_party/beasties": "../third_party/beasties",
# Needed for the FESM file.
"\\./(.+)/packages/angular/ssr/third_party/beasties": "../third_party/beasties/index.js",
},
nested_packages = [
"//packages/angular/ssr/schematics:pkg",
# Included directly as the generated types reference the types file in this location.
Expand Down
8 changes: 7 additions & 1 deletion packages/angular/ssr/test/npm_package/package_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ const CRITTERS_ACTUAL_LICENSE_FILE_PATH = join(
);

describe('NPM Package Tests', () => {
it('should not include the contents of third_party/beasties/index.js in the FESM bundle', async () => {
it('should not include the contents of `third_party/beasties/index.js` in the FESM bundle', async () => {
const fesmFilePath = join(ANGULAR_SSR_PACKAGE_PATH, 'fesm2022/ssr.mjs');
const fesmContent = await readFile(fesmFilePath, 'utf-8');
expect(fesmContent).toContain(`import Beasties from '../third_party/beasties/index.js'`);
});

it('should correctly reference `third_party/beasties` in the ssr types bundle', async () => {
const fesmFilePath = join(ANGULAR_SSR_PACKAGE_PATH, 'types/ssr.d.ts');
const fesmContent = await readFile(fesmFilePath, 'utf-8');
expect(fesmContent).toContain(`import Beasties from '../third_party/beasties'`);
});

describe('third_party/beasties/THIRD_PARTY_LICENSES.txt', () => {
it('should exist', () => {
expect(existsSync(CRITTERS_ACTUAL_LICENSE_FILE_PATH)).toBe(true);
Expand Down
9 changes: 6 additions & 3 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ def copy_to_bin(**kwargs):
def js_binary(**kwargs):
_js_binary(**kwargs)

def ng_package(deps = [], **kwargs):
def ng_package(deps = [], extra_substitutions = {}, **kwargs):
nostamp_subs = dict(substitutions["nostamp"], **extra_substitutions)
stamp_subs = dict(substitutions["stamp"], **extra_substitutions)

_ng_package(
deps = deps,
license = "//:LICENSE",
substitutions = select({
"//:stamp": substitutions["stamp"],
"//conditions:default": substitutions["nostamp"],
"//:stamp": stamp_subs,
"//conditions:default": nostamp_subs,
}),
**kwargs
)
Expand Down
2 changes: 0 additions & 2 deletions tools/substitutions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ _stamp_substitutions = {
"0.0.0-NG-PACKAGR-PEER-DEP": NG_PACKAGR_PEER_DEP,
"0.0.0-ANGULAR-FW-VERSION": ANGULAR_FW_VERSION,
"0.0.0-ANGULAR-FW-PEER-DEP": ANGULAR_FW_PEER_DEP,
# The below is needed for @angular/ssr FESM file.
"\\./(.+)/packages/angular/ssr/third_party/beasties": "../third_party/beasties/index.js",
}

_no_stamp_substitutions = dict(_stamp_substitutions, **{
Expand Down