diff --git a/angular/devkit/common/env-options.ts b/angular/devkit/common/env-options.ts index 6ab1300..a3c5260 100644 --- a/angular/devkit/common/env-options.ts +++ b/angular/devkit/common/env-options.ts @@ -12,7 +12,6 @@ export type AngularEnvOptions = { jestConfigPath: string; jestModulePath: string; ngPackagrModulePath: string; - readDefaultTsConfig: string; angularElementsModulePath?: string; webpackConfigFactory?: WebpackConfigFactory; webpackDevServerModulePath?: string; diff --git a/angular/devkit/compiler/ng-packagr/ng-packagr.compiler.ts b/angular/devkit/compiler/ng-packagr/ng-packagr.compiler.ts index d996795..5c04f3c 100644 --- a/angular/devkit/compiler/ng-packagr/ng-packagr.compiler.ts +++ b/angular/devkit/compiler/ng-packagr/ng-packagr.compiler.ts @@ -127,28 +127,21 @@ export class NgPackagrCompiler implements Compiler { this.ngPackagr = require(ngPackagrPath).ngPackagr(); // eslint-disable-next-line global-require,import/no-dynamic-require - const module = require(ngEnvOptions.readDefaultTsConfig); - if (typeof module.readDefaultTsConfig !== 'undefined') { - // Angular v8 to v12 - this.readDefaultTsConfig = module.readDefaultTsConfig; - } else { - // Angular v13+ - this.readDefaultTsConfig = async() => { - const { initializeTsConfig } = module; - const entryPoints: any = [{ - data: { - entryPoint: { - moduleId: '@bitdev/angular.dev-services.compiler.ng-packagr', - entryFilePath: '', - flatModuleFile: '' - }, - tsConfig: null - } - }]; - await initializeTsConfig(undefined, entryPoints); - return entryPoints[0].data.tsConfig; - }; - } + this.readDefaultTsConfig = async() => { + const { initializeTsConfig } = require('ng-packagr/lib/ts/tsconfig'); + const entryPoints: any = [{ + data: { + entryPoint: { + moduleId: '@bitdev/angular.dev-services.compiler.ng-packagr', + entryFilePath: '', + flatModuleFile: '' + }, + tsConfig: null + } + }]; + await initializeTsConfig(undefined, entryPoints); + return entryPoints[0].data.tsConfig; + }; } updatePaths(packageJson: Record) { @@ -182,7 +175,7 @@ export class NgPackagrCompiler implements Compiler { diagnosticsReporter: DiagnosticsReporter, // component ids of other angular components in the workspace componentIds: string[], - isBuild = true, + isBuild = true ): Promise { // check for dependencies other than tslib and move them to peer dependencies // see https://github.com/ng-packagr/ng-packagr/blob/master/docs/dependencies.md#general-recommendation-use-peerdependencies-whenever-possible @@ -248,7 +241,7 @@ export class NgPackagrCompiler implements Compiler { await removeFilesAndEmptyDirsRecursively([resolve(join(pathToOutputFolder, this.distDir, PACKAGE_JSON))]); await removeFilesAndEmptyDirsRecursively([resolve(join(pathToOutputFolder, NG_PACKAGE_JSON))]); // eslint-disable-next-line consistent-return - }, async (err: Error) => { + }, async(err: Error) => { if (err.message === ViewEngineTemplateError && !tsCompilerOptions.fullTemplateTypeCheck) { // eslint-disable-next-line no-console console.warn(chalk.yellow(`\nError "${ err.message }" triggered by the Angular compiler, retrying compilation without "fullTemplateTypeCheck" (you should probably create a custom environment using "bit create ng-env my-custom-angular-env" to set this option by default and avoid this error message)\n`)); diff --git a/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts b/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts index d556ab1..0e7a0c1 100644 --- a/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts +++ b/angular/envs/angular-v13-env/angular-v13-env.bit-env.ts @@ -20,7 +20,6 @@ export class AngularV13Env extends AngularBaseEnv { jestConfigPath: require.resolve('./jest/jest.config'), jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), - readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack diff --git a/angular/envs/angular-v14-env/angular-v14-env.bit-env.ts b/angular/envs/angular-v14-env/angular-v14-env.bit-env.ts index f4bd55b..b8fd203 100644 --- a/angular/envs/angular-v14-env/angular-v14-env.bit-env.ts +++ b/angular/envs/angular-v14-env/angular-v14-env.bit-env.ts @@ -20,7 +20,6 @@ export class AngularV14Env extends AngularBaseEnv { jestConfigPath: require.resolve('./jest/jest.config'), jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), - readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack diff --git a/angular/envs/angular-v15-env/angular-v15-env.bit-env.ts b/angular/envs/angular-v15-env/angular-v15-env.bit-env.ts index 91de21b..ae8f3df 100644 --- a/angular/envs/angular-v15-env/angular-v15-env.bit-env.ts +++ b/angular/envs/angular-v15-env/angular-v15-env.bit-env.ts @@ -20,7 +20,6 @@ export class AngularV15Env extends AngularBaseEnv { jestConfigPath: require.resolve('./jest/jest.config'), jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), - readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack diff --git a/angular/envs/angular-v16-env/angular-v16-env.bit-env.ts b/angular/envs/angular-v16-env/angular-v16-env.bit-env.ts index adecc20..ac13194 100644 --- a/angular/envs/angular-v16-env/angular-v16-env.bit-env.ts +++ b/angular/envs/angular-v16-env/angular-v16-env.bit-env.ts @@ -20,7 +20,6 @@ export class AngularV16Env extends AngularBaseEnv { jestConfigPath: require.resolve('./jest/jest.config'), jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), - readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack diff --git a/angular/envs/angular-v17-env/angular-v17-env.bit-env.ts b/angular/envs/angular-v17-env/angular-v17-env.bit-env.ts index 2988b5b..25fef3c 100644 --- a/angular/envs/angular-v17-env/angular-v17-env.bit-env.ts +++ b/angular/envs/angular-v17-env/angular-v17-env.bit-env.ts @@ -20,7 +20,6 @@ export class AngularV17Env extends AngularBaseEnv { jestConfigPath: require.resolve('./jest/jest.config'), jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), - readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack