Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"chokidar": "1.7.0",
"convert-source-map": "^1.5.1",
"dependency-graph": "^0.7.2",
"diff": "^3.5.0",
"domino": "2.1.0",
"fs-extra": "4.0.2",
"jasmine": "^3.1.0",
Expand Down Expand Up @@ -105,7 +106,6 @@
"conventional-changelog": "^2.0.3",
"core-js": "^2.4.1",
"cors": "2.8.4",
"diff": "^3.5.0",
"entities": "1.1.1",
"firefox-profile": "1.0.3",
"glob": "7.1.2",
Expand Down
16 changes: 11 additions & 5 deletions packages/bazel/src/ng_package/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function main(args: string[]): number {
typeDefinitions.forEach((f: string) => {
const content = fs.readFileSync(f, 'utf-8')
// Strip the named AMD module for compatibility with non-bazel users
.replace(/^\/\/\/ <amd-module name=.*\/>\n/gm, '');
.replace(/^\/\/\/ <amd-module name=.*\/>[\r\n]+/gm, '');
writeFileFromInputPath(f, content);
});

Expand Down Expand Up @@ -235,8 +235,8 @@ function main(args: string[]): number {
* @param file path to a file under the binDir, like bazel-bin/core/testing/generated.js
*/
function srcDirRelative(from: string, file: string) {
const result =
path.relative(path.dirname(from), path.join(srcDir, path.relative(binDir, file)));
const result = normalizeSeparators(
path.relative(path.dirname(from), path.join(srcDir, path.relative(binDir, file))));
if (result.startsWith('..')) return result;
return `./${result}`;
}
Expand Down Expand Up @@ -346,8 +346,8 @@ function main(args: string[]): number {
function createTypingsReexportFile(entryPointName: string, license: string, typingsFile: string) {
const inputPath = path.join(srcDir, `${entryPointName}.d.ts`);
const content = `${license}
export * from '${srcDirRelative(inputPath, typingsFile.replace(/\.d\.tsx?$/, ''))}';
`;
export * from '${srcDirRelative(inputPath, typingsFile.replace(/\.d\.tsx?$/, ''))}';
`;
writeFileFromInputPath(inputPath, content);
}

Expand All @@ -362,6 +362,12 @@ function main(args: string[]): number {
const content = amendPackageJson(pkgJson, {name: entryPointPackageName});
writeFileFromInputPath(pkgJson, content);
}

/**
* Normalizes the specified path by replacing backslash separators with Posix
* forward slash separators.
*/
function normalizeSeparators(path: string): string { return path.replace(/\\/g, '/'); }
}

if (require.main === module) {
Expand Down
13 changes: 8 additions & 5 deletions packages/bazel/test/ng_package/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ts_library(
srcs = ["common_package.spec.ts"],
deps = [
"//packages:types",
"//packages/private/testing",
"@ngdeps//@types/shelljs",
],
)
Expand Down Expand Up @@ -63,19 +64,21 @@ jasmine_node_test(
"example_package.golden",
"//packages/bazel/test/ng_package/example:npm_package",
],
# TODO(alexeagle): re-enable this test
# see https://github.com/angular/angular/pull/22933
tags = ["manual"],
deps = ["@ngdeps//diff"],
# We don't want to run the example_package golden test with Ivy yet. Currently the golden
# file is based on non-ivy output and therefore won't work for ngc and Ivy at the same time.
# TODO: We should be able to have another golden for ivy-aot as well.
tags = ["no-ivy-aot"]
)

nodejs_binary(
name = "example_package.accept",
testonly = True,
data = [
"example_package.golden",
":example_spec_lib",
"//packages/bazel/test/ng_package/example:npm_package",
"@ngdeps//diff",
":example_spec_lib",
"example_package.golden",
],
entry_point = "angular/packages/bazel/test/ng_package/example_package.spec.js",
templated_args = ["--accept"],
Expand Down
14 changes: 13 additions & 1 deletion packages/bazel/test/ng_package/common_package.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/

import {obsoleteInIvy} from '@angular/private/testing';
import * as fs from 'fs';
import * as path from 'path';
import * as shx from 'shelljs';

shx.cd(path.join(process.env['TEST_SRCDIR'] !, 'angular', 'packages', 'common', 'npm_package'));
// Resolve the "npm_package" directory by using the runfile resolution. Note that we need to
// resolve the "package.json" of the package since otherwise NodeJS would resolve the "main"
// file, which is not necessarily at the root of the "npm_package".
shx.cd(path.dirname(require.resolve('angular/packages/common/npm_package/package.json')));

describe('@angular/common ng_package', () => {
describe('should have the locales files', () => {
Expand Down Expand Up @@ -89,6 +93,14 @@ describe('@angular/common ng_package', () => {
.toMatch('//# sourceMappingURL=testing.js.map');
});

describe('secondary entry-point', () => {
obsoleteInIvy(
`now that we don't need metadata files, we don't need these redirects to help resolve paths to them`)
.it('should contain a root type definition re-export', () => {
expect(shx.cat('./testing.d.ts')).toContain(`export * from './testing/testing';`);
});
});


describe('should have module resolution properties in the package.json file for', () => {
// https://github.com/angular/common-builds/blob/master/package.json
Expand Down
14 changes: 8 additions & 6 deletions packages/bazel/test/ng_package/core_package.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {fixmeIvy, ivyEnabled, obsoleteInIvy} from '@angular/private/testing';
import * as path from 'path';
import * as shx from 'shelljs';

const corePackagePath =
path.join(process.env['TEST_SRCDIR'] !, 'angular', 'packages', 'core', 'npm_package');
shx.cd(corePackagePath);
// Resolve the "npm_package" directory by using the runfile resolution. Note that we need to
// resolve the "package.json" of the package since otherwise NodeJS would resolve the "main"
// file, which is not necessarily at the root of the "npm_package".
shx.cd(path.dirname(require.resolve('angular/packages/core/npm_package/package.json')));

/**
* Utility functions that allows me to create fs paths
Expand Down Expand Up @@ -223,12 +224,13 @@ describe('@angular/core ng_package', () => {
describe('typings', () => {
const typingsFile = p `testing/index.d.ts`;
it('should have a typings file',
() => { expect(shx.cat(typingsFile)).toContain('export * from \'./public_api\';'); });
() => { expect(shx.cat(typingsFile)).toContain(`export * from './public_api';`); });

obsoleteInIvy(
'now that we don\'t need metadata files, we don\'t need these redirects to help resolve paths to them')
.it('should have an \'redirect\' d.ts file in the parent dir',
() => { expect(shx.cat('testing.d.ts')).toContain(`export *`); });
.it('should have an \'redirect\' d.ts file in the parent dir', () => {
expect(shx.cat('testing.d.ts')).toContain(`export * from './testing/testing';`);
});
});

obsoleteInIvy('metadata files are no longer needed or produced in Ivy')
Expand Down
Loading