fix(angular): fix incremental builds with angular 13 (#7770)
This commit is contained in:
parent
446ef6e552
commit
2566a81802
@ -0,0 +1,22 @@
|
|||||||
|
import { InjectionToken, Provider } from 'injection-js';
|
||||||
|
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||||
|
import { provideTransform } from 'ng-packagr/lib/graph/transform.di';
|
||||||
|
import { OPTIONS_TOKEN } from 'ng-packagr/lib/ng-package/options.di';
|
||||||
|
import {
|
||||||
|
STYLESHEET_PROCESSOR,
|
||||||
|
STYLESHEET_PROCESSOR_TOKEN,
|
||||||
|
} from 'ng-packagr/lib/styles/stylesheet-processor.di';
|
||||||
|
import { nxCompileNgcTransformFactory } from './compile-ngc.transform';
|
||||||
|
|
||||||
|
export const NX_COMPILE_NGC_TOKEN = new InjectionToken<Transform>(
|
||||||
|
`nx.v1.compileNgc`
|
||||||
|
);
|
||||||
|
export const NX_COMPILE_NGC_TRANSFORM = provideTransform({
|
||||||
|
provide: NX_COMPILE_NGC_TOKEN,
|
||||||
|
useFactory: nxCompileNgcTransformFactory,
|
||||||
|
deps: [STYLESHEET_PROCESSOR_TOKEN, OPTIONS_TOKEN],
|
||||||
|
});
|
||||||
|
export const NX_COMPILE_NGC_PROVIDERS: Provider[] = [
|
||||||
|
STYLESHEET_PROCESSOR,
|
||||||
|
NX_COMPILE_NGC_TRANSFORM,
|
||||||
|
];
|
||||||
@ -5,27 +5,18 @@
|
|||||||
* since these libraries will be compiled by the ngtsc.
|
* since these libraries will be compiled by the ngtsc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { InjectionToken, Provider } from 'injection-js';
|
|
||||||
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||||
import { transformFromPromise } from 'ng-packagr/lib/graph/transform';
|
import { transformFromPromise } from 'ng-packagr/lib/graph/transform';
|
||||||
import { provideTransform } from 'ng-packagr/lib/graph/transform.di';
|
|
||||||
import {
|
import {
|
||||||
isEntryPoint,
|
isEntryPoint,
|
||||||
isEntryPointInProgress,
|
isEntryPointInProgress,
|
||||||
} from 'ng-packagr/lib/ng-package/nodes';
|
} from 'ng-packagr/lib/ng-package/nodes';
|
||||||
import {
|
import { NgPackagrOptions } from 'ng-packagr/lib/ng-package/options.di';
|
||||||
NgPackagrOptions,
|
|
||||||
OPTIONS_TOKEN,
|
|
||||||
} from 'ng-packagr/lib/ng-package/options.di';
|
|
||||||
import { compileSourceFiles } from './compile-source-files';
|
|
||||||
import type { StylesheetProcessor as StylesheetProcessorClass } from 'ng-packagr/lib/styles/stylesheet-processor';
|
import type { StylesheetProcessor as StylesheetProcessorClass } from 'ng-packagr/lib/styles/stylesheet-processor';
|
||||||
import {
|
|
||||||
STYLESHEET_PROCESSOR,
|
|
||||||
STYLESHEET_PROCESSOR_TOKEN,
|
|
||||||
} from 'ng-packagr/lib/styles/stylesheet-processor.di';
|
|
||||||
import { setDependenciesTsConfigPaths } from 'ng-packagr/lib/ts/tsconfig';
|
import { setDependenciesTsConfigPaths } from 'ng-packagr/lib/ts/tsconfig';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
import { compileSourceFiles } from '../../ngc/compile-source-files';
|
||||||
|
|
||||||
export const nxCompileNgcTransformFactory = (
|
export const nxCompileNgcTransformFactory = (
|
||||||
StylesheetProcessor: typeof StylesheetProcessorClass,
|
StylesheetProcessor: typeof StylesheetProcessorClass,
|
||||||
@ -75,16 +66,3 @@ export const nxCompileNgcTransformFactory = (
|
|||||||
return graph;
|
return graph;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NX_COMPILE_NGC_TOKEN = new InjectionToken<Transform>(
|
|
||||||
`nx.v1.compileNgc`
|
|
||||||
);
|
|
||||||
export const NX_COMPILE_NGC_TRANSFORM = provideTransform({
|
|
||||||
provide: NX_COMPILE_NGC_TOKEN,
|
|
||||||
useFactory: nxCompileNgcTransformFactory,
|
|
||||||
deps: [STYLESHEET_PROCESSOR_TOKEN, OPTIONS_TOKEN],
|
|
||||||
});
|
|
||||||
export const NX_COMPILE_NGC_PROVIDERS: Provider[] = [
|
|
||||||
STYLESHEET_PROCESSOR,
|
|
||||||
NX_COMPILE_NGC_TRANSFORM,
|
|
||||||
];
|
|
||||||
@ -1,15 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* Wires everything together and provides it to the DI system, taking what
|
* Adapted from the original ng-packagr source.
|
||||||
* we still want from the original ng-packagr library and replacing those
|
*
|
||||||
* where Nx takes over with Nx specific functions
|
* Changes made:
|
||||||
|
* - Provide our own entryPointTransformFactory function.
|
||||||
|
* - Use NX_COMPILE_NGC_TOKEN instead of COMPILE_NGC_TOKEN.
|
||||||
|
* - Use NX_COMPILE_NGC_PROVIDERS instead of COMPILE_NGC_PROVIDERS.
|
||||||
|
* - Removed usage of WRITE_BUNDLES_TRANSFORM_TOKEN and WRITE_BUNDLES_TRANSFORM.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Provider } from 'injection-js';
|
import type { Provider } from 'injection-js';
|
||||||
import { InjectionToken } from 'injection-js';
|
import { InjectionToken } from 'injection-js';
|
||||||
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||||
import { provideTransform } from 'ng-packagr/lib/graph/transform.di';
|
import { provideTransform } from 'ng-packagr/lib/graph/transform.di';
|
||||||
import { NX_COMPILE_NGC_PROVIDERS, NX_COMPILE_NGC_TOKEN } from './compile-ngc';
|
import {
|
||||||
import { nxEntryPointTransformFactory } from './entry-point';
|
NX_COMPILE_NGC_PROVIDERS,
|
||||||
|
NX_COMPILE_NGC_TOKEN,
|
||||||
|
} from './compile-ngc.di';
|
||||||
|
import { nxEntryPointTransformFactory } from './entry-point.transform';
|
||||||
import {
|
import {
|
||||||
NX_WRITE_PACKAGE_TRANSFORM,
|
NX_WRITE_PACKAGE_TRANSFORM,
|
||||||
NX_WRITE_PACKAGE_TRANSFORM_TOKEN,
|
NX_WRITE_PACKAGE_TRANSFORM_TOKEN,
|
||||||
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Adapted from original ng-packagr source
|
* Adapted from the original ng-packagr source.
|
||||||
*
|
*
|
||||||
* Remove writing bundles as they are not needed
|
* Changes made:
|
||||||
* for incremental builds.
|
* - Removed writing bundles as we don't generate them for incremental builds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { logger } from '@nrwl/devkit';
|
import { logger } from '@nrwl/devkit';
|
||||||
@ -26,8 +26,8 @@ import { pipe } from 'rxjs';
|
|||||||
* - downlevelTs
|
* - downlevelTs
|
||||||
* - relocateSourceMaps
|
* - relocateSourceMaps
|
||||||
* - writePackage
|
* - writePackage
|
||||||
* - copyStagedFiles (esm, dts, sourcemaps)
|
* - copyStagedFiles (esm, dts, sourcemaps)
|
||||||
* - writePackageJson
|
* - writePackageJson
|
||||||
*
|
*
|
||||||
* The transformation pipeline is pluggable through the dependency injection system.
|
* The transformation pipeline is pluggable through the dependency injection system.
|
||||||
* Sub-transformations are passed to this factory function as arguments.
|
* Sub-transformations are passed to this factory function as arguments.
|
||||||
@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Adapted from the original ng-packagr source.
|
||||||
|
*
|
||||||
|
* Changes made:
|
||||||
|
* - Provide our own writePackageTransform function.
|
||||||
|
*/
|
||||||
|
|
||||||
import { InjectionToken } from 'injection-js';
|
import { InjectionToken } from 'injection-js';
|
||||||
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||||
import {
|
import {
|
||||||
@ -5,7 +12,7 @@ import {
|
|||||||
TransformProvider,
|
TransformProvider,
|
||||||
} from 'ng-packagr/lib/graph/transform.di';
|
} from 'ng-packagr/lib/graph/transform.di';
|
||||||
import { OPTIONS_TOKEN } from 'ng-packagr/lib/ng-package/options.di';
|
import { OPTIONS_TOKEN } from 'ng-packagr/lib/ng-package/options.di';
|
||||||
import { nxWritePackageTransform } from './write-package';
|
import { nxWritePackageTransform } from './write-package.transform';
|
||||||
|
|
||||||
export const NX_WRITE_PACKAGE_TRANSFORM_TOKEN = new InjectionToken<Transform>(
|
export const NX_WRITE_PACKAGE_TRANSFORM_TOKEN = new InjectionToken<Transform>(
|
||||||
`nx.v1.writePackageTransform`
|
`nx.v1.writePackageTransform`
|
||||||
@ -1,8 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Adapted from original ng-packagr
|
* Adapted from the original ng-packagr.
|
||||||
*
|
*
|
||||||
* Change the package.json metadata to only use
|
* Changes made:
|
||||||
* the ESM2015 output as it's the only one generated.
|
* - Change the package.json metadata to only use the ESM2020 output as it's the only one generated.
|
||||||
|
* - Remove package exports.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { logger } from '@nrwl/devkit';
|
import { logger } from '@nrwl/devkit';
|
||||||
@ -18,13 +19,7 @@ import {
|
|||||||
} from 'ng-packagr/lib/ng-package/nodes';
|
} from 'ng-packagr/lib/ng-package/nodes';
|
||||||
import { NgPackagrOptions } from 'ng-packagr/lib/ng-package/options.di';
|
import { NgPackagrOptions } from 'ng-packagr/lib/ng-package/options.di';
|
||||||
import { NgPackage } from 'ng-packagr/lib/ng-package/package';
|
import { NgPackage } from 'ng-packagr/lib/ng-package/package';
|
||||||
import {
|
import { copyFile, rmdir, stat, writeFile } from 'ng-packagr/lib/utils/fs';
|
||||||
copyFile,
|
|
||||||
exists,
|
|
||||||
rmdir,
|
|
||||||
stat,
|
|
||||||
writeFile,
|
|
||||||
} from 'ng-packagr/lib/utils/fs';
|
|
||||||
import { globFiles } from 'ng-packagr/lib/utils/glob';
|
import { globFiles } from 'ng-packagr/lib/utils/glob';
|
||||||
import { ensureUnixPath } from 'ng-packagr/lib/utils/path';
|
import { ensureUnixPath } from 'ng-packagr/lib/utils/path';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -110,7 +105,8 @@ export const nxWritePackageTransform = (options: NgPackagrOptions) =>
|
|||||||
ngEntryPoint,
|
ngEntryPoint,
|
||||||
ngPackage,
|
ngPackage,
|
||||||
{
|
{
|
||||||
module: relativeUnixFromDestPath(destinationFiles.fesm2015),
|
module: relativeUnixFromDestPath(destinationFiles.esm2020),
|
||||||
|
es2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
||||||
esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
||||||
typings: relativeUnixFromDestPath(destinationFiles.declarations),
|
typings: relativeUnixFromDestPath(destinationFiles.declarations),
|
||||||
// webpack v4+ specific flag to enable advanced optimizations and code splitting
|
// webpack v4+ specific flag to enable advanced optimizations and code splitting
|
||||||
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Adapted from the original ng-packagr
|
* Adapted from the original ng-packagr.
|
||||||
*
|
*
|
||||||
* Wires everything together and provides it to the DI, but exchanges the parts
|
* Changes made:
|
||||||
* we want to implement with Nx specific functions
|
* - Use NX_ENTRY_POINT_TRANSFORM_TOKEN instead of ENTRY_POINT_TRANSFORM_TOKEN.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Provider } from 'injection-js';
|
import type { Provider } from 'injection-js';
|
||||||
@ -23,7 +23,7 @@ import {
|
|||||||
} from 'ng-packagr/lib/ng-package/options.di';
|
} from 'ng-packagr/lib/ng-package/options.di';
|
||||||
import { packageTransformFactory } from 'ng-packagr/lib/ng-package/package.transform';
|
import { packageTransformFactory } from 'ng-packagr/lib/ng-package/package.transform';
|
||||||
import { PROJECT_TOKEN } from 'ng-packagr/lib/project.di';
|
import { PROJECT_TOKEN } from 'ng-packagr/lib/project.di';
|
||||||
import { NX_ENTRY_POINT_TRANSFORM_TOKEN } from './entry-point.di';
|
import { NX_ENTRY_POINT_TRANSFORM_TOKEN } from './entry-point/entry-point.di';
|
||||||
|
|
||||||
export const NX_PACKAGE_TRANSFORM_TOKEN = new InjectionToken<Transform>(
|
export const NX_PACKAGE_TRANSFORM_TOKEN = new InjectionToken<Transform>(
|
||||||
`nx.v1.packageTransform`
|
`nx.v1.packageTransform`
|
||||||
@ -7,11 +7,11 @@ import * as buildableLibsUtils from '@nrwl/workspace/src/utilities/buildable-lib
|
|||||||
import * as ngPackagr from 'ng-packagr';
|
import * as ngPackagr from 'ng-packagr';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import type { BuildAngularLibraryExecutorOptions } from '../package/schema';
|
import type { BuildAngularLibraryExecutorOptions } from '../package/schema';
|
||||||
import { NX_ENTRY_POINT_PROVIDERS } from './ng-packagr-adjustments/entry-point.di';
|
import { NX_ENTRY_POINT_PROVIDERS } from './ng-packagr-adjustments/ng-package/entry-point/entry-point.di';
|
||||||
import {
|
import {
|
||||||
NX_PACKAGE_PROVIDERS,
|
NX_PACKAGE_PROVIDERS,
|
||||||
NX_PACKAGE_TRANSFORM,
|
NX_PACKAGE_TRANSFORM,
|
||||||
} from './ng-packagr-adjustments/package.di';
|
} from './ng-packagr-adjustments/ng-package/package.di';
|
||||||
import ngPackagrLiteExecutor from './ng-packagr-lite.impl';
|
import ngPackagrLiteExecutor from './ng-packagr-lite.impl';
|
||||||
|
|
||||||
describe('NgPackagrLite executor', () => {
|
describe('NgPackagrLite executor', () => {
|
||||||
|
|||||||
@ -7,11 +7,11 @@ import { NgPackagr } from 'ng-packagr';
|
|||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { createLibraryExecutor } from '../package/package.impl';
|
import { createLibraryExecutor } from '../package/package.impl';
|
||||||
import type { BuildAngularLibraryExecutorOptions } from '../package/schema';
|
import type { BuildAngularLibraryExecutorOptions } from '../package/schema';
|
||||||
import { NX_ENTRY_POINT_PROVIDERS } from './ng-packagr-adjustments/entry-point.di';
|
import { NX_ENTRY_POINT_PROVIDERS } from './ng-packagr-adjustments/ng-package/entry-point/entry-point.di';
|
||||||
import {
|
import {
|
||||||
NX_PACKAGE_PROVIDERS,
|
NX_PACKAGE_PROVIDERS,
|
||||||
NX_PACKAGE_TRANSFORM,
|
NX_PACKAGE_TRANSFORM,
|
||||||
} from './ng-packagr-adjustments/package.di';
|
} from './ng-packagr-adjustments/ng-package/package.di';
|
||||||
|
|
||||||
async function initializeNgPackgrLite(
|
async function initializeNgPackgrLite(
|
||||||
options: BuildAngularLibraryExecutorOptions,
|
options: BuildAngularLibraryExecutorOptions,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user