fix(packages): use ES modules for primary build (#11120)
This commit is contained in:

committed by
Victor Berchet

parent
8cb1046ce9
commit
979657989b
@ -28,6 +28,12 @@ export function main(
|
||||
ngOptions.basePath = basePath;
|
||||
|
||||
const host = ts.createCompilerHost(parsed.options, true);
|
||||
|
||||
// HACK: patch the realpath to solve symlink issue here:
|
||||
// https://github.com/Microsoft/TypeScript/issues/9552
|
||||
// todo(misko): remove once facade symlinks are removed
|
||||
host.realpath = (path) => path;
|
||||
|
||||
const program = ts.createProgram(parsed.fileNames, parsed.options, host);
|
||||
const errors = program.getOptionsDiagnostics();
|
||||
check(errors);
|
||||
|
@ -167,7 +167,7 @@ export interface MetadataGlobalReferenceExpression extends MetadataSymbolicExpre
|
||||
}
|
||||
export function isMetadataGlobalReferenceExpression(value: any):
|
||||
value is MetadataGlobalReferenceExpression {
|
||||
return isMetadataSymbolicReferenceExpression(value) && value.name && !value.module;
|
||||
return value && value.name && !value.module && isMetadataSymbolicReferenceExpression(value);
|
||||
}
|
||||
|
||||
export interface MetadataModuleReferenceExpression extends MetadataSymbolicExpression {
|
||||
@ -176,8 +176,8 @@ export interface MetadataModuleReferenceExpression extends MetadataSymbolicExpre
|
||||
}
|
||||
export function isMetadataModuleReferenceExpression(value: any):
|
||||
value is MetadataModuleReferenceExpression {
|
||||
return isMetadataSymbolicReferenceExpression(value) && value.module && !value.name &&
|
||||
!value.default;
|
||||
return value && value.module && !value.name && !value.default &&
|
||||
isMetadataSymbolicReferenceExpression(value);
|
||||
}
|
||||
|
||||
export interface MetadataImportedSymbolReferenceExpression extends MetadataSymbolicExpression {
|
||||
@ -188,7 +188,7 @@ export interface MetadataImportedSymbolReferenceExpression extends MetadataSymbo
|
||||
}
|
||||
export function isMetadataImportedSymbolReferenceExpression(value: any):
|
||||
value is MetadataImportedSymbolReferenceExpression {
|
||||
return isMetadataSymbolicReferenceExpression(value) && value.module && !!value.name;
|
||||
return value && value.module && !!value.name && isMetadataSymbolicReferenceExpression(value);
|
||||
}
|
||||
|
||||
export interface MetadataImportedDefaultReferenceExpression extends MetadataSymbolicExpression {
|
||||
@ -200,7 +200,7 @@ export interface MetadataImportedDefaultReferenceExpression extends MetadataSymb
|
||||
}
|
||||
export function isMetadataImportDefaultReference(value: any):
|
||||
value is MetadataImportedDefaultReferenceExpression {
|
||||
return isMetadataSymbolicReferenceExpression(value) && value.module && value.default;
|
||||
return value.module && value.default && isMetadataSymbolicReferenceExpression(value);
|
||||
}
|
||||
|
||||
export type MetadataSymbolicReferenceExpression = MetadataGlobalReferenceExpression |
|
||||
@ -259,4 +259,4 @@ export interface MetadataError {
|
||||
}
|
||||
export function isMetadataError(value: any): value is MetadataError {
|
||||
return value && value.__symbolic === 'error';
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import {existsSync} from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
@ -66,8 +67,17 @@ export class Tsc implements CompilerInterface {
|
||||
const {config, error} = ts.readConfigFile(project, this.readFile);
|
||||
check([error]);
|
||||
|
||||
this.parsed =
|
||||
ts.parseJsonConfigFileContent(config, {readDirectory: this.readDirectory}, basePath);
|
||||
// Do not inline `host` into `parseJsonConfigFileContent` until after
|
||||
// g3 is updated to the latest TypeScript.
|
||||
// The issue is that old typescript only has `readDirectory` while
|
||||
// the newer TypeScript has additional `useCaseSensitiveFileNames` and
|
||||
// `fileExists`. Inlining will trigger an error of extra parameters.
|
||||
let host = {
|
||||
useCaseSensitiveFileNames: true,
|
||||
fileExists: existsSync,
|
||||
readDirectory: this.readDirectory
|
||||
};
|
||||
this.parsed = ts.parseJsonConfigFileContent(config, host, basePath);
|
||||
|
||||
check(this.parsed.errors);
|
||||
|
||||
|
Reference in New Issue
Block a user