test(ngcc): use "module" format property for ES5 bundles (#36089)

The format property for ES5 bundles should be "module" or "es5"/"esm5",
but was "main" instead. The "main" property is appropriate for CommonJS
and UMD bundles, not for ES5 bundles.

PR Close #36089
This commit is contained in:
JoostK
2020-02-23 18:02:13 +01:00
committed by Andrew Kushnir
parent a1e00f82f4
commit 1bc3893c65
2 changed files with 19 additions and 13 deletions

View File

@ -33,6 +33,7 @@ export function compileIntoFlatEs5Package(pkgName: string, sources: PackageSourc
compileIntoFlatPackage(pkgName, sources, {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.ESNext,
formatProperty: 'module',
});
}
@ -46,6 +47,11 @@ export interface FlatLayoutOptions {
* The module kind to use in the compiled result.
*/
module: ts.ModuleKind;
/**
* The name of the property in package.json that refers to the root source file.
*/
formatProperty: string;
}
/**
@ -90,7 +96,7 @@ function compileIntoFlatPackage(
const pkgJson: unknown = {
name: pkgName,
version: '0.0.1',
main: './index.js',
[options.formatProperty]: './index.js',
typings: './index.d.ts',
};