Skip to content

build: fix size-test integration tooling #22619

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

Merged
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
1 change: 1 addition & 0 deletions integration/size-test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ts_library(
name = "check-size",
srcs = ["check-size.ts"],
deps = [
"@npm//@bazel/runfiles",
"@npm//@types/node",
"@npm//@types/yaml",
"@npm//chalk",
Expand Down
5 changes: 3 additions & 2 deletions integration/size-test/check-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import * as chalk from 'chalk';
import {readFileSync, statSync, writeFileSync} from 'fs';
import {parse, stringify} from 'yaml';
import {runfiles} from '@bazel/runfiles';

/**
* Absolute byte deviation from the expected value that is allowed. If the
Expand All @@ -30,8 +31,8 @@ type Golden = {[testId: string]: number};
* with the actual measured size.
*/
const [testId, testFileRootpath, isApprove] = process.argv.slice(2);
const testFilePath = require.resolve(`angular_material/${testFileRootpath}`);
const goldenFilePath = require.resolve('../../goldens/size-test.yaml');
const testFilePath = runfiles.resolveWorkspaceRelative(testFileRootpath);
const goldenFilePath = runfiles.resolveWorkspaceRelative('goldens/size-test.yaml');

const golden: Golden = parse(readFileSync(goldenFilePath, 'utf8')) || {};
const fileStat = statSync(testFilePath);
Expand Down
2 changes: 2 additions & 0 deletions integration/size-test/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def size_test(name, file, deps):
"@npm//rollup-plugin-node-resolve",
"@npm//@angular-devkit/build-optimizer",
],
# Link the workspace root so that files can be loaded from the workspace.
link_workspace_root = True,
sourcemap = "false",
)

Expand Down
16 changes: 2 additions & 14 deletions integration/size-test/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const {buildOptimizer} = require('@angular-devkit/build-optimizer');
const {buildOptimizer} = require('@angular-devkit/build-optimizer/src/build-optimizer/build-optimizer');
const node = require('rollup-plugin-node-resolve');
const path = require('path');
const {ivyEnabled} = require(getIvyEnabledHelperPath());
const {ivyEnabled} = require('angular_material/tools/angular_ivy_enabled');

console.info(`Processing rollup bundle in ${ivyEnabled ? 'Ivy' : 'View Engine'} mode.`);

Expand Down Expand Up @@ -37,14 +36,3 @@ module.exports = {
}),
],
};

function getIvyEnabledHelperPath() {
const parts = path.normalize(__dirname).split(path.sep);
const binIndex = parts.indexOf('bin');

if (binIndex === -1) {
throw Error('Cannot resolve Ivy helper path.');
}

return path.join(parts.slice(0, binIndex).join(path.sep), 'bin/tools/angular_ivy_enabled');
}