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.
|
||||
*/
|
||||
|
||||
import { InjectionToken, Provider } from 'injection-js';
|
||||
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||
import { transformFromPromise } from 'ng-packagr/lib/graph/transform';
|
||||
import { provideTransform } from 'ng-packagr/lib/graph/transform.di';
|
||||
import {
|
||||
isEntryPoint,
|
||||
isEntryPointInProgress,
|
||||
} from 'ng-packagr/lib/ng-package/nodes';
|
||||
import {
|
||||
NgPackagrOptions,
|
||||
OPTIONS_TOKEN,
|
||||
} from 'ng-packagr/lib/ng-package/options.di';
|
||||
import { compileSourceFiles } from './compile-source-files';
|
||||
import { NgPackagrOptions } from 'ng-packagr/lib/ng-package/options.di';
|
||||
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 * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
import { compileSourceFiles } from '../../ngc/compile-source-files';
|
||||
|
||||
export const nxCompileNgcTransformFactory = (
|
||||
StylesheetProcessor: typeof StylesheetProcessorClass,
|
||||
@ -75,16 +66,3 @@ export const nxCompileNgcTransformFactory = (
|
||||
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
|
||||
* we still want from the original ng-packagr library and replacing those
|
||||
* where Nx takes over with Nx specific functions
|
||||
* Adapted from the original ng-packagr source.
|
||||
*
|
||||
* 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 { InjectionToken } from 'injection-js';
|
||||
import type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||
import { provideTransform } from 'ng-packagr/lib/graph/transform.di';
|
||||
import { NX_COMPILE_NGC_PROVIDERS, NX_COMPILE_NGC_TOKEN } from './compile-ngc';
|
||||
import { nxEntryPointTransformFactory } from './entry-point';
|
||||
import {
|
||||
NX_COMPILE_NGC_PROVIDERS,
|
||||
NX_COMPILE_NGC_TOKEN,
|
||||
} from './compile-ngc.di';
|
||||
import { nxEntryPointTransformFactory } from './entry-point.transform';
|
||||
import {
|
||||
NX_WRITE_PACKAGE_TRANSFORM,
|
||||
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
|
||||
* for incremental builds.
|
||||
* Changes made:
|
||||
* - Removed writing bundles as we don't generate them for incremental builds.
|
||||
*/
|
||||
|
||||
import { logger } from '@nrwl/devkit';
|
||||
@ -26,8 +26,8 @@ import { pipe } from 'rxjs';
|
||||
* - downlevelTs
|
||||
* - relocateSourceMaps
|
||||
* - writePackage
|
||||
* - copyStagedFiles (esm, dts, sourcemaps)
|
||||
* - writePackageJson
|
||||
* - copyStagedFiles (esm, dts, sourcemaps)
|
||||
* - writePackageJson
|
||||
*
|
||||
* The transformation pipeline is pluggable through the dependency injection system.
|
||||
* 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 type { Transform } from 'ng-packagr/lib/graph/transform';
|
||||
import {
|
||||
@ -5,7 +12,7 @@ import {
|
||||
TransformProvider,
|
||||
} from 'ng-packagr/lib/graph/transform.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>(
|
||||
`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
|
||||
* the ESM2015 output as it's the only one generated.
|
||||
* Changes made:
|
||||
* - 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';
|
||||
@ -18,13 +19,7 @@ import {
|
||||
} from 'ng-packagr/lib/ng-package/nodes';
|
||||
import { NgPackagrOptions } from 'ng-packagr/lib/ng-package/options.di';
|
||||
import { NgPackage } from 'ng-packagr/lib/ng-package/package';
|
||||
import {
|
||||
copyFile,
|
||||
exists,
|
||||
rmdir,
|
||||
stat,
|
||||
writeFile,
|
||||
} from 'ng-packagr/lib/utils/fs';
|
||||
import { copyFile, rmdir, stat, writeFile } from 'ng-packagr/lib/utils/fs';
|
||||
import { globFiles } from 'ng-packagr/lib/utils/glob';
|
||||
import { ensureUnixPath } from 'ng-packagr/lib/utils/path';
|
||||
import * as path from 'path';
|
||||
@ -110,7 +105,8 @@ export const nxWritePackageTransform = (options: NgPackagrOptions) =>
|
||||
ngEntryPoint,
|
||||
ngPackage,
|
||||
{
|
||||
module: relativeUnixFromDestPath(destinationFiles.fesm2015),
|
||||
module: relativeUnixFromDestPath(destinationFiles.esm2020),
|
||||
es2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
||||
esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),
|
||||
typings: relativeUnixFromDestPath(destinationFiles.declarations),
|
||||
// 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
|
||||
* we want to implement with Nx specific functions
|
||||
* Changes made:
|
||||
* - Use NX_ENTRY_POINT_TRANSFORM_TOKEN instead of ENTRY_POINT_TRANSFORM_TOKEN.
|
||||
*/
|
||||
|
||||
import type { Provider } from 'injection-js';
|
||||
@ -23,7 +23,7 @@ import {
|
||||
} from 'ng-packagr/lib/ng-package/options.di';
|
||||
import { packageTransformFactory } from 'ng-packagr/lib/ng-package/package.transform';
|
||||
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>(
|
||||
`nx.v1.packageTransform`
|
||||
@ -7,11 +7,11 @@ import * as buildableLibsUtils from '@nrwl/workspace/src/utilities/buildable-lib
|
||||
import * as ngPackagr from 'ng-packagr';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
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 {
|
||||
NX_PACKAGE_PROVIDERS,
|
||||
NX_PACKAGE_TRANSFORM,
|
||||
} from './ng-packagr-adjustments/package.di';
|
||||
} from './ng-packagr-adjustments/ng-package/package.di';
|
||||
import ngPackagrLiteExecutor from './ng-packagr-lite.impl';
|
||||
|
||||
describe('NgPackagrLite executor', () => {
|
||||
|
||||
@ -7,11 +7,11 @@ import { NgPackagr } from 'ng-packagr';
|
||||
import { resolve } from 'path';
|
||||
import { createLibraryExecutor } from '../package/package.impl';
|
||||
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 {
|
||||
NX_PACKAGE_PROVIDERS,
|
||||
NX_PACKAGE_TRANSFORM,
|
||||
} from './ng-packagr-adjustments/package.di';
|
||||
} from './ng-packagr-adjustments/ng-package/package.di';
|
||||
|
||||
async function initializeNgPackgrLite(
|
||||
options: BuildAngularLibraryExecutorOptions,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user