From ee88d28e4490aa58f0de5a4fe9b4348e97d4d2e0 Mon Sep 17 00:00:00 2001 From: Miroslav Jonas Date: Wed, 12 Apr 2023 10:58:54 +0200 Subject: [PATCH] feat(core): use barell import --- e2e/node/src/node.test.ts | 2 +- .../src/rules/enforce-module-boundaries.spec.ts | 2 +- .../src/rules/enforce-module-boundaries.ts | 2 +- .../eslint-plugin-nx/src/utils/runtime-lint-utils.ts | 2 +- packages/js/src/index.ts | 4 ++-- .../js/src/utils/package-json/update-package-json.ts | 7 ++----- packages/next/src/executors/build/build.impl.ts | 2 +- packages/nx/src/command-line/format.ts | 5 +---- packages/nx/src/devkit-exports.ts | 4 ++-- packages/nx/src/hasher/hasher.spec.ts | 4 ++-- packages/nx/src/hasher/hasher.ts | 2 +- packages/nx/src/plugins/js/index.ts | 10 +++++++++- .../project-graph/affected/affected-project-graph.ts | 2 +- packages/nx/src/project-graph/build-project-graph.ts | 2 +- packages/nx/src/utils/register.ts | 2 +- .../src/plugins/generate-package-json-plugin.ts | 2 +- 16 files changed, 28 insertions(+), 26 deletions(-) diff --git a/e2e/node/src/node.test.ts b/e2e/node/src/node.test.ts index 8d10299dcf683e..211ed7a05efaa4 100644 --- a/e2e/node/src/node.test.ts +++ b/e2e/node/src/node.test.ts @@ -26,7 +26,7 @@ import { } from '@nrwl/e2e/utils'; import { exec, execSync } from 'child_process'; import * as http from 'http'; -import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file'; +import { getLockFileName } from 'nx/src/plugins/js'; import { satisfies } from 'semver'; function getData(port, path = '/api'): Promise { diff --git a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.spec.ts b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.spec.ts index 42d13c85aafe4c..935d0d58411ffa 100644 --- a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.spec.ts +++ b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.spec.ts @@ -9,7 +9,7 @@ import { DependencyType } from '@nrwl/devkit'; import * as parser from '@typescript-eslint/parser'; import { TSESLint } from '@typescript-eslint/utils'; import { vol } from 'memfs'; -import { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator'; +import { TargetProjectLocator } from 'nx/src/plugins/js'; import enforceModuleBoundaries, { RULE_NAME as enforceModuleBoundariesRuleName, } from '../../src/rules/enforce-module-boundaries'; diff --git a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts index e7bf5c51319266..bc44be3bd87d64 100644 --- a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts +++ b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts @@ -33,7 +33,7 @@ import { isComboDepConstraint, } from '../utils/runtime-lint-utils'; import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils'; -import { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator'; +import { TargetProjectLocator } from 'nx/src/plugins/js'; import { basename, dirname, relative } from 'path'; import { getBarrelEntryPointByImportScope, diff --git a/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts b/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts index 63a599b1ad5e53..11b876430a5b14 100644 --- a/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts +++ b/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts @@ -13,7 +13,7 @@ import { } from '@nrwl/devkit'; import { getPath, pathExists } from './graph-utils'; import { readFileIfExisting } from 'nx/src/utils/fileutils'; -import { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator'; +import { TargetProjectLocator } from 'nx/src/plugins/js'; import { findProjectForPath, ProjectRootMappings, diff --git a/packages/js/src/index.ts b/packages/js/src/index.ts index 2597abbff3e5c6..da0fd72d39a763 100644 --- a/packages/js/src/index.ts +++ b/packages/js/src/index.ts @@ -11,5 +11,5 @@ export * from './utils/assets'; export * from './utils/package-json/update-package-json'; export { libraryGenerator } from './generators/library/library'; export { initGenerator } from './generators/init/init'; -export { createLockFile } from 'nx/src/plugins/js/lock-file/lock-file'; -export { createPackageJson } from 'nx/src/plugins/js/package-json/create-package-json'; +export { createLockFile } from 'nx/src/plugins/js'; +export { createPackageJson } from 'nx/src/plugins/js'; diff --git a/packages/js/src/utils/package-json/update-package-json.ts b/packages/js/src/utils/package-json/update-package-json.ts index 8cd01317508d8d..11d79dad91d8e2 100644 --- a/packages/js/src/utils/package-json/update-package-json.ts +++ b/packages/js/src/utils/package-json/update-package-json.ts @@ -1,8 +1,5 @@ -import { - createLockFile, - getLockFileName, -} from 'nx/src/plugins/js/lock-file/lock-file'; -import { createPackageJson } from 'nx/src/plugins/js/package-json/create-package-json'; +import { createLockFile, getLockFileName } from 'nx/src/plugins/js'; +import { createPackageJson } from 'nx/src/plugins/js'; import { ExecutorContext, getOutputsForTargetAndConfiguration, diff --git a/packages/next/src/executors/build/build.impl.ts b/packages/next/src/executors/build/build.impl.ts index c81f2e540fdf85..23ef4fd8ff3ca8 100644 --- a/packages/next/src/executors/build/build.impl.ts +++ b/packages/next/src/executors/build/build.impl.ts @@ -18,7 +18,7 @@ import { createNextConfigFile } from './lib/create-next-config-file'; import { checkPublicDirectory } from './lib/check-project'; import { NextBuildBuilderOptions } from '../../utils/types'; -import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file'; +import { getLockFileName } from 'nx/src/plugins/js'; export default async function buildExecutor( options: NextBuildBuilderOptions, diff --git a/packages/nx/src/command-line/format.ts b/packages/nx/src/command-line/format.ts index bcb801314ab3f0..7543209508ce21 100644 --- a/packages/nx/src/command-line/format.ts +++ b/packages/nx/src/command-line/format.ts @@ -12,10 +12,7 @@ import * as yargs from 'yargs'; import * as prettier from 'prettier'; import { sortObjectByKeys } from '../utils/object-sort'; -import { - getRootTsConfigFileName, - getRootTsConfigPath, -} from '../plugins/js/utils/typescript'; +import { getRootTsConfigFileName, getRootTsConfigPath } from '../plugins/js'; import { createProjectGraphAsync } from '../project-graph/project-graph'; import { filterAffected } from '../project-graph/affected/affected-project-graph'; import { readNxJson } from '../config/configuration'; diff --git a/packages/nx/src/devkit-exports.ts b/packages/nx/src/devkit-exports.ts index 9919f56218c641..2082225c551aa9 100644 --- a/packages/nx/src/devkit-exports.ts +++ b/packages/nx/src/devkit-exports.ts @@ -226,8 +226,8 @@ export { Hash, Hasher } from './hasher/hasher'; */ export { cacheDir } from './utils/cache-directory'; -import { createLockFile as _createLockFile } from './plugins/js/lock-file/lock-file'; -import { createPackageJson as _createPackageJson } from './plugins/js/package-json/create-package-json'; +import { createLockFile as _createLockFile } from './plugins/js'; +import { createPackageJson as _createPackageJson } from './plugins/js'; /** * @category Package Manager diff --git a/packages/nx/src/hasher/hasher.spec.ts b/packages/nx/src/hasher/hasher.spec.ts index 2330b38be169d8..f1ee0e1b592929 100644 --- a/packages/nx/src/hasher/hasher.spec.ts +++ b/packages/nx/src/hasher/hasher.spec.ts @@ -8,10 +8,10 @@ jest.doMock('../utils/workspace-root', () => { }); jest.mock('fs', () => require('memfs').fs); -jest.mock('../plugins/js/utils/typescript'); +jest.mock('../plugins/js'); import { vol } from 'memfs'; -import tsUtils = require('../plugins/js/utils/typescript'); +import tsUtils = require('../plugins/js'); import { expandNamedInput, filterUsingGlobPatterns, diff --git a/packages/nx/src/hasher/hasher.ts b/packages/nx/src/hasher/hasher.ts index f0b41672245d70..350b4427e79172 100644 --- a/packages/nx/src/hasher/hasher.ts +++ b/packages/nx/src/hasher/hasher.ts @@ -1,6 +1,6 @@ import { exec } from 'child_process'; import * as minimatch from 'minimatch'; -import { getRootTsConfigFileName } from '../plugins/js/utils/typescript'; +import { getRootTsConfigFileName } from '../plugins/js'; import { defaultHashing, HashingImpl } from './hashing-impl'; import { FileData, diff --git a/packages/nx/src/plugins/js/index.ts b/packages/nx/src/plugins/js/index.ts index 33c1fcf4bdef29..cfe78770a8b42b 100644 --- a/packages/nx/src/plugins/js/index.ts +++ b/packages/nx/src/plugins/js/index.ts @@ -16,14 +16,22 @@ import { projectGraphCacheDirectory } from '../../utils/cache-directory'; import { readFileSync, writeFileSync } from 'fs'; import { workspaceRoot } from '../../utils/workspace-root'; import { ensureDirSync } from 'fs-extra'; -import { removeNpmNodes } from 'nx/src/plugins/js/lock-file/remove-npm-nodes'; +import { removeNpmNodes } from './lock-file/remove-npm-nodes'; +/** + * Exports section + */ export { findNodes, getRootTsConfigPath, getRootTsConfigFileName, + readTsConfig, resolveModuleByImport, } from './utils/typescript'; +export { getLockFileName, createLockFile } from './lock-file/lock-file'; +export { createPackageJson } from './package-json/create-package-json'; +export { TargetProjectLocator } from './project-graph/build-dependencies/target-project-locator'; +export { getTouchedProjects } from './project-graph/affected/touched-projects'; export const processProjectGraph: ProjectGraphProcessor = async ( graph, diff --git a/packages/nx/src/project-graph/affected/affected-project-graph.ts b/packages/nx/src/project-graph/affected/affected-project-graph.ts index 7bbfd3c731a1d8..6936fc0411695b 100644 --- a/packages/nx/src/project-graph/affected/affected-project-graph.ts +++ b/packages/nx/src/project-graph/affected/affected-project-graph.ts @@ -3,7 +3,7 @@ import { getImplicitlyTouchedProjects, getTouchedProjects, } from './locators/workspace-projects'; -import { getTouchedProjects as getJSTouchedProjects } from '../../plugins/js/project-graph/affected/touched-projects'; +import { getTouchedProjects as getJSTouchedProjects } from '../../plugins/js'; import { AffectedProjectGraphContext, TouchedProjectLocator, diff --git a/packages/nx/src/project-graph/build-project-graph.ts b/packages/nx/src/project-graph/build-project-graph.ts index 8e525fcb9c09e4..9f6a950fa140d6 100644 --- a/packages/nx/src/project-graph/build-project-graph.ts +++ b/packages/nx/src/project-graph/build-project-graph.ts @@ -16,7 +16,7 @@ import { buildWorkspaceProjectNodes } from './build-nodes'; import { loadNxPlugins } from '../utils/nx-plugin'; import { defaultFileHasher } from '../hasher/file-hasher'; import { createProjectFileMap } from './file-map-utils'; -import { getRootTsConfigPath } from '../plugins/js/utils/typescript'; +import { getRootTsConfigPath } from '../plugins/js'; import { ProjectFileMap, ProjectGraph, diff --git a/packages/nx/src/utils/register.ts b/packages/nx/src/utils/register.ts index c727339f7677fa..77a442f8fc4e69 100644 --- a/packages/nx/src/utils/register.ts +++ b/packages/nx/src/utils/register.ts @@ -1,5 +1,5 @@ import { dirname, join } from 'path'; -import type { CompilerOptions, ModuleResolutionKind } from 'typescript'; +import type { CompilerOptions } from 'typescript'; import { logger, NX_PREFIX, stripIndent } from './logger'; const swcNodeInstalled = packageIsInstalled('@swc-node/register'); diff --git a/packages/webpack/src/plugins/generate-package-json-plugin.ts b/packages/webpack/src/plugins/generate-package-json-plugin.ts index dbfbe40a6471b3..b2675d0af73213 100644 --- a/packages/webpack/src/plugins/generate-package-json-plugin.ts +++ b/packages/webpack/src/plugins/generate-package-json-plugin.ts @@ -10,7 +10,7 @@ import { HelperDependency, readTsConfig, } from '@nrwl/js'; -import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file'; +import { getLockFileName } from 'nx/src/plugins/js'; const pluginName = 'GeneratePackageJsonPlugin';