refactor(ivy): ngcc - remove flat-format and use AbsoluteFsPath (#29092)

Now that we are using package.json properties to indicate which
entry-point format to compile, it turns out that we don't really
need to distinguish between flat and non-flat formats, unless we
are compiling `@angular/core`.

PR Close #29092
This commit is contained in:
Pete Bacon Darwin
2019-03-20 13:47:58 +00:00
committed by Matias Niemelä
parent cd449021c1
commit 7b55ba58b9
19 changed files with 276 additions and 283 deletions

View File

@ -9,6 +9,7 @@
import {readFileSync, writeFileSync} from 'fs';
import * as mockFs from 'mock-fs';
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
import {checkMarker, writeMarker} from '../../src/packages/build_marker';
import {EntryPoint} from '../../src/packages/entry_point';
@ -94,11 +95,12 @@ function restoreRealFileSystem() {
}
function createEntryPoint(path: string): EntryPoint {
const absolutePath = AbsoluteFsPath.from(path);
return {
name: 'some-package',
path,
package: path,
typings: '',
path: absolutePath,
package: absolutePath,
typings: AbsoluteFsPath.from('/typings'),
packageJson: JSON.parse(readFileSync(path + '/package.json', 'utf8'))
};
}

View File

@ -9,6 +9,8 @@
import * as path from 'canonical-path';
import * as mockFs from 'mock-fs';
import * as ts from 'typescript';
import {AbsoluteFsPath, PathSegment} from '../../../src/ngtsc/path';
import {DependencyHost} from '../../src/packages/dependency_host';
const Module = require('module');
@ -16,6 +18,8 @@ interface DepMap {
[path: string]: {resolved: string[], missing: string[]};
}
const _ = AbsoluteFsPath.from;
describe('DependencyHost', () => {
let host: DependencyHost;
beforeEach(() => host = new DependencyHost());
@ -27,7 +31,8 @@ describe('DependencyHost', () => {
it('should not generate a TS AST if the source does not contain any imports or re-exports',
() => {
spyOn(ts, 'createSourceFile');
host.computeDependencies('/no/imports/or/re-exports.js', new Set(), new Set(), new Set());
host.computeDependencies(
_('/no/imports/or/re-exports.js'), new Set(), new Set(), new Set());
expect(ts.createSourceFile).not.toHaveBeenCalled();
});
@ -37,7 +42,7 @@ describe('DependencyHost', () => {
const resolved = new Set();
const missing = new Set();
const deepImports = new Set();
host.computeDependencies('/external/imports.js', resolved, missing, deepImports);
host.computeDependencies(_('/external/imports.js'), resolved, missing, deepImports);
expect(resolved.size).toBe(2);
expect(resolved.has('RESOLVED/path/to/x')).toBe(true);
expect(resolved.has('RESOLVED/path/to/y')).toBe(true);
@ -49,7 +54,7 @@ describe('DependencyHost', () => {
const resolved = new Set();
const missing = new Set();
const deepImports = new Set();
host.computeDependencies('/external/re-exports.js', resolved, missing, deepImports);
host.computeDependencies(_('/external/re-exports.js'), resolved, missing, deepImports);
expect(resolved.size).toBe(2);
expect(resolved.has('RESOLVED/path/to/x')).toBe(true);
expect(resolved.has('RESOLVED/path/to/y')).toBe(true);
@ -64,7 +69,7 @@ describe('DependencyHost', () => {
const resolved = new Set();
const missing = new Set();
const deepImports = new Set();
host.computeDependencies('/external/imports-missing.js', resolved, missing, deepImports);
host.computeDependencies(_('/external/imports-missing.js'), resolved, missing, deepImports);
expect(resolved.size).toBe(1);
expect(resolved.has('RESOLVED/path/to/x')).toBe(true);
expect(missing.size).toBe(1);
@ -84,7 +89,7 @@ describe('DependencyHost', () => {
const resolved = new Set();
const missing = new Set();
const deepImports = new Set();
host.computeDependencies('/external/deep-import.js', resolved, missing, deepImports);
host.computeDependencies(_('/external/deep-import.js'), resolved, missing, deepImports);
expect(resolved.size).toBe(0);
expect(missing.size).toBe(0);
expect(deepImports.size).toBe(1);
@ -101,7 +106,7 @@ describe('DependencyHost', () => {
const resolved = new Set();
const missing = new Set();
const deepImports = new Set();
host.computeDependencies('/internal/outer.js', resolved, missing, deepImports);
host.computeDependencies(_('/internal/outer.js'), resolved, missing, deepImports);
expect(getDependenciesSpy)
.toHaveBeenCalledWith('/internal/outer.js', resolved, missing, deepImports);
expect(getDependenciesSpy)
@ -121,7 +126,7 @@ describe('DependencyHost', () => {
const resolved = new Set();
const missing = new Set();
const deepImports = new Set();
host.computeDependencies('/internal/circular-a.js', resolved, missing, deepImports);
host.computeDependencies(_('/internal/circular-a.js'), resolved, missing, deepImports);
expect(resolved.size).toBe(2);
expect(resolved.has('RESOLVED/path/to/x')).toBe(true);
expect(resolved.has('RESOLVED/path/to/y')).toBe(true);
@ -144,14 +149,15 @@ describe('DependencyHost', () => {
describe('resolveInternal', () => {
it('should resolve the dependency via `Module._resolveFilename`', () => {
spyOn(Module, '_resolveFilename').and.returnValue('RESOLVED_PATH');
const result = host.resolveInternal('/SOURCE/PATH/FILE', '../TARGET/PATH/FILE');
expect(result).toEqual('RESOLVED_PATH');
spyOn(Module, '_resolveFilename').and.returnValue('/RESOLVED_PATH');
const result = host.resolveInternal(
_('/SOURCE/PATH/FILE'), PathSegment.fromFsPath('../TARGET/PATH/FILE'));
expect(result).toEqual('/RESOLVED_PATH');
});
it('should first resolve the `to` on top of the `from` directory', () => {
const resolveSpy = spyOn(Module, '_resolveFilename').and.returnValue('RESOLVED_PATH');
host.resolveInternal('/SOURCE/PATH/FILE', '../TARGET/PATH/FILE');
const resolveSpy = spyOn(Module, '_resolveFilename').and.returnValue('/RESOLVED_PATH');
host.resolveInternal(_('/SOURCE/PATH/FILE'), PathSegment.fromFsPath('../TARGET/PATH/FILE'));
expect(resolveSpy)
.toHaveBeenCalledWith('/SOURCE/TARGET/PATH/FILE', jasmine.any(Object), false, undefined);
});
@ -159,37 +165,39 @@ describe('DependencyHost', () => {
describe('tryResolveExternal', () => {
it('should call `tryResolve`, appending `package.json` to the target path', () => {
const tryResolveSpy = spyOn(host, 'tryResolve').and.returnValue('PATH/TO/RESOLVED');
host.tryResolveEntryPoint('SOURCE_PATH', 'TARGET_PATH');
expect(tryResolveSpy).toHaveBeenCalledWith('SOURCE_PATH', 'TARGET_PATH/package.json');
const tryResolveSpy = spyOn(host, 'tryResolve').and.returnValue('/PATH/TO/RESOLVED');
host.tryResolveEntryPoint(_('/SOURCE_PATH'), PathSegment.fromFsPath('TARGET_PATH'));
expect(tryResolveSpy).toHaveBeenCalledWith('/SOURCE_PATH', 'TARGET_PATH/package.json');
});
it('should return the directory containing the result from `tryResolve', () => {
spyOn(host, 'tryResolve').and.returnValue('PATH/TO/RESOLVED');
expect(host.tryResolveEntryPoint('SOURCE_PATH', 'TARGET_PATH')).toEqual('PATH/TO');
spyOn(host, 'tryResolve').and.returnValue('/PATH/TO/RESOLVED');
expect(host.tryResolveEntryPoint(_('/SOURCE_PATH'), PathSegment.fromFsPath('TARGET_PATH')))
.toEqual(_('/PATH/TO'));
});
it('should return null if `tryResolve` returns null', () => {
spyOn(host, 'tryResolve').and.returnValue(null);
expect(host.tryResolveEntryPoint('SOURCE_PATH', 'TARGET_PATH')).toEqual(null);
expect(host.tryResolveEntryPoint(_('/SOURCE_PATH'), PathSegment.fromFsPath('TARGET_PATH')))
.toEqual(null);
});
});
describe('tryResolve()', () => {
it('should resolve the dependency via `Module._resolveFilename`, passing the `from` path to the `paths` option',
() => {
const resolveSpy = spyOn(Module, '_resolveFilename').and.returnValue('RESOLVED_PATH');
const result = host.tryResolve('SOURCE_PATH', 'TARGET_PATH');
const resolveSpy = spyOn(Module, '_resolveFilename').and.returnValue('/RESOLVED_PATH');
const result = host.tryResolve(_('/SOURCE_PATH'), PathSegment.fromFsPath('TARGET_PATH'));
expect(resolveSpy).toHaveBeenCalledWith('TARGET_PATH', jasmine.any(Object), false, {
paths: ['SOURCE_PATH']
paths: ['/SOURCE_PATH']
});
expect(result).toEqual('RESOLVED_PATH');
expect(result).toEqual(_('/RESOLVED_PATH'));
});
it('should return null if `Module._resolveFilename` throws an error', () => {
const resolveSpy =
spyOn(Module, '_resolveFilename').and.throwError(`Cannot find module 'TARGET_PATH'`);
const result = host.tryResolve('SOURCE_PATH', 'TARGET_PATH');
const result = host.tryResolve(_('/SOURCE_PATH'), PathSegment.fromFsPath('TARGET_PATH'));
expect(result).toBe(null);
});
});

View File

@ -6,10 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
import {resolve} from 'canonical-path';
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
import {DependencyHost} from '../../src/packages/dependency_host';
import {DependencyResolver, SortedEntryPointsInfo} from '../../src/packages/dependency_resolver';
import {EntryPoint} from '../../src/packages/entry_point';
const _ = AbsoluteFsPath.from;
describe('DependencyResolver', () => {
let host: DependencyHost;
let resolver: DependencyResolver;
@ -18,18 +23,18 @@ describe('DependencyResolver', () => {
resolver = new DependencyResolver(host);
});
describe('sortEntryPointsByDependency()', () => {
const first = { path: 'first', fesm2015: 'first/index.ts' } as EntryPoint;
const second = { path: 'second', esm2015: 'second/index.ts' } as EntryPoint;
const third = { path: 'third', fesm2015: 'third/index.ts' } as EntryPoint;
const fourth = { path: 'fourth', esm2015: 'fourth/index.ts' } as EntryPoint;
const fifth = { path: 'fifth', fesm2015: 'fifth/index.ts' } as EntryPoint;
const first = { path: _('/first'), packageJson: {esm5: 'index.ts'} } as EntryPoint;
const second = { path: _('/second'), packageJson: {esm2015: 'sub/index.ts'} } as EntryPoint;
const third = { path: _('/third'), packageJson: {esm5: 'index.ts'} } as EntryPoint;
const fourth = { path: _('/fourth'), packageJson: {esm2015: 'sub2/index.ts'} } as EntryPoint;
const fifth = { path: _('/fifth'), packageJson: {esm5: 'index.ts'} } as EntryPoint;
const dependencies = {
'first/index.ts': {resolved: ['second', 'third', 'ignored-1'], missing: []},
'second/index.ts': {resolved: ['third', 'fifth'], missing: []},
'third/index.ts': {resolved: ['fourth', 'ignored-2'], missing: []},
'fourth/index.ts': {resolved: ['fifth'], missing: []},
'fifth/index.ts': {resolved: [], missing: []},
[_('/first/index.ts')]: {resolved: [second.path, third.path, '/ignored-1'], missing: []},
[_('/second/sub/index.ts')]: {resolved: [third.path, fifth.path], missing: []},
[_('/third/index.ts')]: {resolved: [fourth.path, '/ignored-2'], missing: []},
[_('/fourth/sub2/index.ts')]: {resolved: [fifth.path], missing: []},
[_('/fifth/index.ts')]: {resolved: [], missing: []},
};
it('should order the entry points by their dependency on each other', () => {
@ -40,58 +45,58 @@ describe('DependencyResolver', () => {
it('should remove entry-points that have missing direct dependencies', () => {
spyOn(host, 'computeDependencies').and.callFake(createFakeComputeDependencies({
'first/index.ts': {resolved: [], missing: ['missing']},
'second/index.ts': {resolved: [], missing: []},
[_('/first/index.ts')]: {resolved: [], missing: ['/missing']},
[_('/second/sub/index.ts')]: {resolved: [], missing: []},
}));
const result = resolver.sortEntryPointsByDependency([first, second]);
expect(result.entryPoints).toEqual([second]);
expect(result.invalidEntryPoints).toEqual([
{entryPoint: first, missingDependencies: ['missing']},
{entryPoint: first, missingDependencies: ['/missing']},
]);
});
it('should remove entry points that depended upon an invalid entry-point', () => {
spyOn(host, 'computeDependencies').and.callFake(createFakeComputeDependencies({
'first/index.ts': {resolved: ['second'], missing: []},
'second/index.ts': {resolved: [], missing: ['missing']},
'third/index.ts': {resolved: [], missing: []},
[_('/first/index.ts')]: {resolved: [second.path], missing: []},
[_('/second/sub/index.ts')]: {resolved: [], missing: ['/missing']},
[_('/third/index.ts')]: {resolved: [], missing: []},
}));
// Note that we will process `first` before `second`, which has the missing dependency.
const result = resolver.sortEntryPointsByDependency([first, second, third]);
expect(result.entryPoints).toEqual([third]);
expect(result.invalidEntryPoints).toEqual([
{entryPoint: second, missingDependencies: ['missing']},
{entryPoint: first, missingDependencies: ['missing']},
{entryPoint: second, missingDependencies: ['/missing']},
{entryPoint: first, missingDependencies: ['/missing']},
]);
});
it('should remove entry points that will depend upon an invalid entry-point', () => {
spyOn(host, 'computeDependencies').and.callFake(createFakeComputeDependencies({
'first/index.ts': {resolved: ['second'], missing: []},
'second/index.ts': {resolved: [], missing: ['missing']},
'third/index.ts': {resolved: [], missing: []},
[_('/first/index.ts')]: {resolved: [second.path], missing: []},
[_('/second/sub/index.ts')]: {resolved: [], missing: ['/missing']},
[_('/third/index.ts')]: {resolved: [], missing: []},
}));
// Note that we will process `first` after `second`, which has the missing dependency.
const result = resolver.sortEntryPointsByDependency([second, first, third]);
expect(result.entryPoints).toEqual([third]);
expect(result.invalidEntryPoints).toEqual([
{entryPoint: second, missingDependencies: ['missing']},
{entryPoint: first, missingDependencies: ['second']},
{entryPoint: second, missingDependencies: ['/missing']},
{entryPoint: first, missingDependencies: [second.path]},
]);
});
it('should error if the entry point does not have either the fesm2015 nor esm2015 formats',
() => {
expect(() => resolver.sortEntryPointsByDependency([{ path: 'first' } as EntryPoint]))
.toThrowError(`There is no format with import statements in 'first' entry-point.`);
});
it('should error if the entry point does not have either the esm5 nor esm2015 formats', () => {
expect(() => resolver.sortEntryPointsByDependency([
{ path: '/first', packageJson: {} } as EntryPoint
])).toThrowError(`There is no format with import statements in '/first' entry-point.`);
});
it('should capture any dependencies that were ignored', () => {
spyOn(host, 'computeDependencies').and.callFake(createFakeComputeDependencies(dependencies));
const result = resolver.sortEntryPointsByDependency([fifth, first, fourth, second, third]);
expect(result.ignoredDependencies).toEqual([
{entryPoint: first, dependencyPath: 'ignored-1'},
{entryPoint: third, dependencyPath: 'ignored-2'},
{entryPoint: first, dependencyPath: '/ignored-1'},
{entryPoint: third, dependencyPath: '/ignored-2'},
]);
});
@ -116,10 +121,14 @@ describe('DependencyResolver', () => {
[path: string]: {resolved: string[], missing: string[]};
}
function createFakeComputeDependencies(dependencies: DepMap) {
return (entryPoint: string, resolved: Set<string>, missing: Set<string>) => {
dependencies[entryPoint].resolved.forEach(dep => resolved.add(dep));
dependencies[entryPoint].missing.forEach(dep => missing.add(dep));
function createFakeComputeDependencies(deps: DepMap) {
return (entryPoint: string) => {
const dependencies = new Set();
const missing = new Set();
const deepImports = new Set();
deps[entryPoint].resolved.forEach(dep => dependencies.add(dep));
deps[entryPoint].missing.forEach(dep => missing.add(dep));
return {dependencies, missing, deepImports};
};
}
});

View File

@ -7,11 +7,15 @@
*/
import * as mockFs from 'mock-fs';
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
import {DependencyHost} from '../../src/packages/dependency_host';
import {DependencyResolver} from '../../src/packages/dependency_resolver';
import {EntryPoint} from '../../src/packages/entry_point';
import {EntryPointFinder} from '../../src/packages/entry_point_finder';
const _ = AbsoluteFsPath.from;
describe('findEntryPoints()', () => {
let resolver: DependencyResolver;
let finder: EntryPointFinder;
@ -26,56 +30,56 @@ describe('findEntryPoints()', () => {
afterEach(restoreRealFileSystem);
it('should find sub-entry-points within a package', () => {
const {entryPoints} = finder.findEntryPoints('/sub_entry_points');
const {entryPoints} = finder.findEntryPoints(_('/sub_entry_points'));
const entryPointPaths = entryPoints.map(x => [x.package, x.path]);
expect(entryPointPaths).toEqual([
['/sub_entry_points/common', '/sub_entry_points/common'],
['/sub_entry_points/common', '/sub_entry_points/common/http'],
['/sub_entry_points/common', '/sub_entry_points/common/http/testing'],
['/sub_entry_points/common', '/sub_entry_points/common/testing'],
[_('/sub_entry_points/common'), _('/sub_entry_points/common')],
[_('/sub_entry_points/common'), _('/sub_entry_points/common/http')],
[_('/sub_entry_points/common'), _('/sub_entry_points/common/http/testing')],
[_('/sub_entry_points/common'), _('/sub_entry_points/common/testing')],
]);
});
it('should find packages inside a namespace', () => {
const {entryPoints} = finder.findEntryPoints('/namespaced');
const {entryPoints} = finder.findEntryPoints(_('/namespaced'));
const entryPointPaths = entryPoints.map(x => [x.package, x.path]);
expect(entryPointPaths).toEqual([
['/namespaced/@angular/common', '/namespaced/@angular/common'],
['/namespaced/@angular/common', '/namespaced/@angular/common/http'],
['/namespaced/@angular/common', '/namespaced/@angular/common/http/testing'],
['/namespaced/@angular/common', '/namespaced/@angular/common/testing'],
[_('/namespaced/@angular/common'), _('/namespaced/@angular/common')],
[_('/namespaced/@angular/common'), _('/namespaced/@angular/common/http')],
[_('/namespaced/@angular/common'), _('/namespaced/@angular/common/http/testing')],
[_('/namespaced/@angular/common'), _('/namespaced/@angular/common/testing')],
]);
});
it('should return an empty array if there are no packages', () => {
const {entryPoints} = finder.findEntryPoints('/no_packages');
const {entryPoints} = finder.findEntryPoints(_('/no_packages'));
expect(entryPoints).toEqual([]);
});
it('should return an empty array if there are no valid entry-points', () => {
const {entryPoints} = finder.findEntryPoints('/no_valid_entry_points');
const {entryPoints} = finder.findEntryPoints(_('/no_valid_entry_points'));
expect(entryPoints).toEqual([]);
});
it('should ignore folders starting with .', () => {
const {entryPoints} = finder.findEntryPoints('/dotted_folders');
const {entryPoints} = finder.findEntryPoints(_('/dotted_folders'));
expect(entryPoints).toEqual([]);
});
it('should ignore folders that are symlinked', () => {
const {entryPoints} = finder.findEntryPoints('/symlinked_folders');
const {entryPoints} = finder.findEntryPoints(_('/symlinked_folders'));
expect(entryPoints).toEqual([]);
});
it('should handle nested node_modules folders', () => {
const {entryPoints} = finder.findEntryPoints('/nested_node_modules');
const {entryPoints} = finder.findEntryPoints(_('/nested_node_modules'));
const entryPointPaths = entryPoints.map(x => [x.package, x.path]);
expect(entryPointPaths).toEqual([
['/nested_node_modules/outer', '/nested_node_modules/outer'],
[_('/nested_node_modules/outer'), _('/nested_node_modules/outer')],
// Note that the inner entry point does not get included as part of the outer package
[
'/nested_node_modules/outer/node_modules/inner',
'/nested_node_modules/outer/node_modules/inner'
_('/nested_node_modules/outer/node_modules/inner'),
_('/nested_node_modules/outer/node_modules/inner'),
],
]);
});

View File

@ -6,84 +6,76 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AbsoluteFsPath} from '@angular/compiler-cli/src/ngtsc/path';
import {readFileSync} from 'fs';
import * as mockFs from 'mock-fs';
import {getEntryPointInfo} from '../../src/packages/entry_point';
describe('getEntryPointInfo()', () => {
beforeEach(createMockFileSystem);
afterEach(restoreRealFileSystem);
const _ = AbsoluteFsPath.from;
const SOME_PACKAGE = _('/some_package');
it('should return an object containing absolute paths to the formats of the specified entry-point',
() => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/valid_entry_point');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/valid_entry_point'));
expect(entryPoint).toEqual({
name: 'some-package/valid_entry_point',
package: '/some_package',
path: '/some_package/valid_entry_point',
typings: `/some_package/valid_entry_point/valid_entry_point.d.ts`,
fesm2015: `/some_package/valid_entry_point/fesm2015/valid_entry_point.js`,
esm2015: `/some_package/valid_entry_point/esm2015/valid_entry_point.js`,
fesm5: `/some_package/valid_entry_point/fesm2015/valid_entry_point.js`,
esm5: `/some_package/valid_entry_point/esm2015/valid_entry_point.js`,
umd: `/some_package/valid_entry_point/bundles/valid_entry_point.umd.js`,
package: SOME_PACKAGE,
path: _('/some_package/valid_entry_point'),
typings: _(`/some_package/valid_entry_point/valid_entry_point.d.ts`),
packageJson: loadPackageJson('/some_package/valid_entry_point'),
});
});
it('should return null if there is no package.json at the entry-point path', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/missing_package_json');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/missing_package_json'));
expect(entryPoint).toBe(null);
});
it('should return null if there is no typings or types field in the package.json', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/missing_typings');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/missing_typings'));
expect(entryPoint).toBe(null);
});
it('should return null if there is no esm2015 nor fesm2015 field in the package.json', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/missing_esm2015');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/missing_esm2015'));
expect(entryPoint).toBe(null);
});
it('should return null if there is no metadata.json file next to the typing file', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/missing_metadata.json');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/missing_metadata.json'));
expect(entryPoint).toBe(null);
});
it('should work if the typings field is named `types', () => {
const entryPoint =
getEntryPointInfo('/some_package', '/some_package/types_rather_than_typings');
getEntryPointInfo(SOME_PACKAGE, _('/some_package/types_rather_than_typings'));
expect(entryPoint).toEqual({
name: 'some-package/types_rather_than_typings',
package: '/some_package',
path: '/some_package/types_rather_than_typings',
typings: `/some_package/types_rather_than_typings/types_rather_than_typings.d.ts`,
fesm2015: `/some_package/types_rather_than_typings/fesm2015/types_rather_than_typings.js`,
esm2015: `/some_package/types_rather_than_typings/esm2015/types_rather_than_typings.js`,
fesm5: `/some_package/types_rather_than_typings/fesm2015/types_rather_than_typings.js`,
esm5: `/some_package/types_rather_than_typings/esm2015/types_rather_than_typings.js`,
umd: `/some_package/types_rather_than_typings/bundles/types_rather_than_typings.umd.js`,
package: SOME_PACKAGE,
path: _('/some_package/types_rather_than_typings'),
typings: _(`/some_package/types_rather_than_typings/types_rather_than_typings.d.ts`),
packageJson: loadPackageJson('/some_package/types_rather_than_typings'),
});
});
it('should work with Angular Material style package.json', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/material_style');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/material_style'));
expect(entryPoint).toEqual({
name: 'some_package/material_style',
package: '/some_package',
path: '/some_package/material_style',
typings: `/some_package/material_style/material_style.d.ts`,
fesm2015: `/some_package/material_style/esm2015/material_style.js`,
fesm5: `/some_package/material_style/esm5/material_style.es5.js`,
umd: `/some_package/material_style/bundles/material_style.umd.js`,
packageJson: loadPackageJson('/some_package/material_style'),
package: SOME_PACKAGE,
path: _('/some_package/material_style'),
typings: _(`/some_package/material_style/material_style.d.ts`),
packageJson: JSON.parse(readFileSync('/some_package/material_style/package.json', 'utf8')),
});
});
it('should return null if the package.json is not valid JSON', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/unexpected_symbols');
const entryPoint = getEntryPointInfo(SOME_PACKAGE, _('/some_package/unexpected_symbols'));
expect(entryPoint).toBe(null);
});
});