feat(devkit): remove backwards compatibility for Nx 15 (#19572)

This commit is contained in:
Jason Jean 2023-10-12 17:16:10 -04:00 committed by GitHub
parent f5d7d213de
commit 1ffeca9eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 16 additions and 301 deletions

View File

@ -131,8 +131,7 @@ rust-toolchain @nrwl/nx-native-reviewers
/docs/generated/devkit/** @nrwl/nx-devkit-reviewers @nrwl/nx-docs-reviewers
/docs/generated/packages/devkit/** @nrwl/nx-devkit-reviewers @nrwl/nx-docs-reviewers
/packages/devkit/** @nrwl/nx-devkit-reviewers
/packages/devkit/index.js @FrozenPandaz @vsavkin
/packages/devkit/index.d.ts @FrozenPandaz @vsavkin
/packages/devkit/index.ts @FrozenPandaz @vsavkin
/packages/devkit/public-api.ts @FrozenPandaz @vsavkin
/packages/devkit/nx.ts @FrozenPandaz @vsavkin

View File

@ -1,5 +1,5 @@
import type { Tree } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing-pre16';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import removePlatformServerExports from './remove-platform-server-exports';

View File

@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { addProjectConfiguration, stripIndents } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing-pre16';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { Builders } from '@schematics/angular/utility/workspace-models';
import updateKarmaMainFile from './update-karma-main-file';

View File

@ -1,5 +1,5 @@
import type { Tree } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing-pre16';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import migration from './remove-render-module-platform-server-exports';
describe('remove-render-module-platform-server-exports migration', () => {

View File

@ -1,27 +0,0 @@
/**
* The Nx Devkit is the underlying technology used to customize Nx to support
* different technologies and custom use-cases. It contains many utility
* functions for reading and writing files, updating configuration,
* working with Abstract Syntax Trees(ASTs), and more.
*
* As with most things in Nx, the core of Nx Devkit is very simple.
* It only uses language primitives and immutable objects
* (the tree being the only exception).
*
* @module @nx/devkit
*/
try {
// TODO(v17): We will not need to maintain this file anymore, change this to a regular export statement
// This file was introduced in the nx package in v15.7 but devkit is compatible down to v14.1 which doesn't have this file.
module.exports = require('nx/src/devkit-exports');
} catch {
// These are the nx-reexports from before v16
// TODO(v17): This can be removed once the above is done.
module.exports = require('./nx-reexports-pre16');
}
module.exports = {
...module.exports,
...require('./public-api'),
};

View File

@ -11,9 +11,6 @@
* @module @nx/devkit
*/
// TODO(v17): remove this file, we can use the normally generated index.d.ts from index.ts
/* eslint-disable @typescript-eslint/no-restricted-imports */
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
export * from 'nx/src/devkit-exports';
export * from './public-api';

View File

@ -1,225 +0,0 @@
/**
* STOP! Do not change this file!
*
* If you need to export something from nx, it should go into nx/src/devkit-exports
*/
// TODO(v17): Remove this file
/* eslint-disable @typescript-eslint/no-restricted-imports */
/**
* @category Tree
*/
export type { Tree, FileChange } from 'nx/src/generators/tree';
/**
* @category Workspace
*/
export type {
WorkspaceJsonConfiguration,
ProjectsConfigurations,
TargetDependencyConfig,
TargetConfiguration,
ProjectConfiguration,
ProjectType,
Workspace,
} from 'nx/src/config/workspace-json-project-json';
/**
* @category Workspace
*/
export type {
Generator,
GeneratorCallback,
Executor,
ExecutorContext,
TaskGraphExecutor,
GeneratorsJson,
ExecutorsJson,
MigrationsJson,
CustomHasher,
HasherContext,
} from 'nx/src/config/misc-interfaces';
/**
* @category Workspace
*/
export { Workspaces } from 'nx/src/config/workspaces';
export { workspaceLayout } from 'nx/src/config/configuration';
export type {
NxPlugin,
ProjectTargetConfigurator,
} from 'nx/src/utils/nx-plugin';
/**
* @category Workspace
*/
export type { Task, TaskGraph } from 'nx/src/config/task-graph';
/**
* @category Workspace
*/
export type {
ImplicitDependencyEntry,
ImplicitJsonSubsetDependency,
NxJsonConfiguration,
NxAffectedConfig,
} from 'nx/src/config/nx-json';
/**
* @category Logger
*/
export { logger } from 'nx/src/utils/logger';
/**
* @category Utils
*/
export { output } from 'nx/src/utils/output';
/**
* @category Package Manager
*/
export type { PackageManager } from 'nx/src/utils/package-manager';
/**
* @category Package Manager
*/
export {
getPackageManagerCommand,
detectPackageManager,
getPackageManagerVersion,
} from 'nx/src/utils/package-manager';
/**
* @category Commands
*/
export type { Target } from 'nx/src/command-line/run';
/**
* @category Commands
*/
export { runExecutor } from 'nx/src/command-line/run';
/**
* @category Generators
*/
export {
addProjectConfiguration,
readProjectConfiguration,
removeProjectConfiguration,
updateProjectConfiguration,
getProjects,
} from 'nx/src/generators/utils/project-configuration';
/**
* @category Generators
*/
export {
readNxJson,
updateNxJson,
readWorkspaceConfiguration,
updateWorkspaceConfiguration,
isStandaloneProject,
WorkspaceConfiguration,
getWorkspacePath,
} from 'nx/src/generators/utils/project-configuration';
/**
* @category Project Graph
*/
export type {
ProjectFileMap,
FileData,
ProjectGraph,
ProjectGraphDependency,
ProjectGraphNode,
ProjectGraphProjectNode,
ProjectGraphExternalNode,
ProjectGraphProcessorContext,
} from 'nx/src/config/project-graph';
/**
* @category Project Graph
*/
export { DependencyType } from 'nx/src/config/project-graph';
/**
* @category Project Graph
*/
export { ProjectGraphBuilder } from 'nx/src/project-graph/project-graph-builder';
/**
* @category Utils
*/
export { readJson, writeJson, updateJson } from 'nx/src/generators/utils/json';
/**
* @category Utils
*/
export { parseJson, serializeJson, stripJsonComments } from 'nx/src/utils/json';
/**
* @category Utils
*/
export type { JsonParseOptions, JsonSerializeOptions } from 'nx/src/utils/json';
/**
* @category Utils
*/
export { readJsonFile, writeJsonFile } from 'nx/src/utils/fileutils';
/**
* @category Utils
*/
export { stripIndents } from 'nx/src/utils/strip-indents';
/**
* @category Utils
*/
export { joinPathFragments, normalizePath } from 'nx/src/utils/path';
// TODO(v16): Change this to export from 'nx/src/utils/workspace-root'
/**
* @category Utils
*/
export { workspaceRoot, appRootPath } from 'nx/src/utils/app-root';
/**
* @category Utils
*/
export { reverse } from 'nx/src/project-graph/operators';
/**
* @category Utils
*/
export {
createProjectGraphAsync,
readCachedProjectGraph,
} from 'nx/src/project-graph/project-graph';
/**
* @category Utils
*/
export { getOutputsForTargetAndConfiguration } from 'nx/src/tasks-runner/utils';
/**
* @category Utils
*/
export {
defaultTasksRunner,
DefaultTasksRunnerOptions,
RemoteCache,
} from 'nx/src/tasks-runner/default-tasks-runner';
/**
* @category Utils
*/
export { Hash, TaskHasher, Hasher } from 'nx/src/hasher/task-hasher';
/**
* @category Utils
*/
export { cacheDir } from 'nx/src/utils/cache-directory';
// STOP! Do not export any new things from the nx package

View File

@ -3,7 +3,6 @@
// - import {} from 'nx/src/devkit-internals'
export function requireNx(): typeof import('nx/src/devkit-exports') &
Partial<typeof import('nx/src/devkit-internals')> {
try {
let result = { ...require('nx/src/devkit-exports') };
try {
result = {
@ -13,8 +12,4 @@ export function requireNx(): typeof import('nx/src/devkit-exports') &
};
} catch {}
return result;
} catch {
// Remove in Nx V17, devkit should not support Nx < 16 at that point.
return require('./nx-reexports-pre16');
}
}

View File

@ -36,7 +36,7 @@
"semver": "7.5.3"
},
"peerDependencies": {
"nx": ">= 15 <= 17"
"nx": ">= 16 <= 18"
},
"publishConfig": {
"access": "public"

View File

@ -1,6 +0,0 @@
/* eslint-disable @typescript-eslint/no-restricted-imports */
export {
createTreeWithEmptyWorkspace,
createTreeWithEmptyV1Workspace,
} from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace';
export { createTree } from 'nx/src/generators/testing-utils/create-tree';

View File

@ -1,9 +0,0 @@
try {
// TODO(v17): We will not need to maintain this file anymore, change this to a regular export statement
// This file was introduced in the nx package in v15.7 but devkit is compatible down to v14.1 which doesn't have this file.
module.exports = require('nx/src/devkit-testing-exports');
} catch {
// These are the nx-reexports from before v16
// TODO(v17): This can be removed once the above is done.
module.exports = require('./testing-pre16');
}

View File

@ -14,6 +14,5 @@
"internal-testing-utils.ts",
"jest.config.ts"
],
"files": ["./index.d.ts"],
"include": ["**/*.ts"]
}

View File

@ -1,6 +1,6 @@
import { getImportPath } from './get-import-path';
import { Tree, writeJson } from '@nx/devkit';
import { createTree } from '@nx/devkit/testing-pre16';
import { createTree } from '@nx/devkit/testing';
describe('getImportPath', () => {
let tree: Tree;

View File

@ -1,5 +1,5 @@
import update from './remove-root-build-option';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing-pre16';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import {
addProjectConfiguration,
readProjectConfiguration,

View File

@ -82,14 +82,6 @@ module.exports = function (path, options) {
// Fallback to using typescript
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
const { compilerOptions, host } = compilerSetup;
// TODO(v17): Remove this workaround
// We have some weird d.ts + .js business going on for these 2 imports so this is a workaround
if (path === '@nx/devkit') {
return join(__dirname, '../', './packages/devkit/index.js');
} else if (path === '@nx/devkit/testing') {
return join(__dirname, '../', './packages/devkit/testing.js');
}
return ts.resolveModuleName(
path,
join(options.basedir, 'fake-placeholder.ts'),