From e87bd5c8f3c08a44b2d03b716001724c974947be Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Wed, 18 Dec 2024 08:59:43 -0700 Subject: [PATCH] fix(js): Configure typescript plugin to handle non-buildable libs --- packages/js/src/generators/library/library.ts | 14 +-- .../js/src/plugins/typescript/plugin.spec.ts | 91 +++++++++----- packages/js/src/plugins/typescript/plugin.ts | 111 +++++++++++++++++- .../react/src/generators/library/library.ts | 5 - .../src/generators/library/library.spec.ts | 43 ------- .../vue/src/generators/library/library.ts | 7 -- 6 files changed, 173 insertions(+), 98 deletions(-) diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index 00ecf12eaf330..aa48b57982ec9 100644 --- a/packages/js/src/generators/library/library.ts +++ b/packages/js/src/generators/library/library.ts @@ -43,10 +43,7 @@ import { addSwcConfig } from '../../utils/swc/add-swc-config'; import { getSwcDependencies } from '../../utils/swc/add-swc-dependencies'; import { getNeededCompilerOptionOverrides } from '../../utils/typescript/configuration'; import { tsConfigBaseOptions } from '../../utils/typescript/create-ts-config'; -import { - ensureProjectIsExcludedFromPluginRegistrations, - ensureProjectIsIncludedInPluginRegistrations, -} from '../../utils/typescript/plugin'; +import { ensureProjectIsIncludedInPluginRegistrations } from '../../utils/typescript/plugin'; import { addTsConfigPath, getRelativePathToRootTsConfig, @@ -255,14 +252,7 @@ async function configureProject( ) { if (options.hasPlugin) { const nxJson = readNxJson(tree); - if (options.bundler === 'none') { - ensureProjectIsExcludedFromPluginRegistrations( - nxJson, - options.projectRoot - ); - } else { - ensureProjectIsIncludedInPluginRegistrations(nxJson, options.projectRoot); - } + ensureProjectIsIncludedInPluginRegistrations(nxJson, options.projectRoot); updateNxJson(tree, nxJson); } diff --git a/packages/js/src/plugins/typescript/plugin.spec.ts b/packages/js/src/plugins/typescript/plugin.spec.ts index a425dffa7c862..4f6292092abcc 100644 --- a/packages/js/src/plugins/typescript/plugin.spec.ts +++ b/packages/js/src/plugins/typescript/plugin.spec.ts @@ -1794,9 +1794,9 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { // Sibling package.json await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/tsconfig.lib.json': `{}`, + 'libs/my-lib/tsconfig.lib.json': `{"compilerOptions": {"rootDir": "src"}}`, 'libs/my-lib/tsconfig.build.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -1855,8 +1855,8 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { // Sibling project.json await applyFilesToTempFsAndContext(tempFs, context, { - 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/tsconfig.lib.json': `{}`, + 'libs/my-lib/tsconfig.json': `{"compilerOptions": {"rootDir": "src"}}`, + 'libs/my-lib/tsconfig.lib.json': `{"compilerOptions": {"rootDir": "src"}}`, 'libs/my-lib/tsconfig.build.json': `{}`, 'libs/my-lib/project.json': `{}`, }); @@ -1920,9 +1920,9 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { // Sibling package.json await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/tsconfig.lib.json': `{}`, + 'libs/my-lib/tsconfig.lib.json': `{"compilerOptions": {"rootDir": "src"}}`, 'libs/my-lib/tsconfig.build.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{ "main": "dist/index.js" }`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -1987,7 +1987,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': `{}`, 'libs/my-lib/tsconfig.lib.json': `{}`, - 'libs/my-lib/tsconfig.build.json': `{}`, + 'libs/my-lib/tsconfig.build.json': `{"compilerOptions": {"rootDir": "src"}}`, 'libs/my-lib/project.json': `{}`, }); expect( @@ -2069,11 +2069,14 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { it('should add the config file and the `include` and `exclude` patterns', async () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { + rootDir: 'src', + }, include: ['src/**/*.ts'], exclude: ['src/**/*.spec.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2132,7 +2135,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { `); }); - it('should add extended config files', async () => { + it('should be able to extended config files', async () => { await applyFilesToTempFsAndContext(tempFs, context, { 'tsconfig.base.json': JSON.stringify({ exclude: ['node_modules', 'tmp'], @@ -2144,8 +2147,11 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ extends: '../../tsconfig.foo.json', include: ['src/**/*.ts'], + compilerOptions: { + rootDir: 'src', + }, }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2219,9 +2225,12 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ extends: '../../tsconfig.foo.json', + compilerOptions: { + rootDir: 'src', + }, include: ['src/**/*.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); // simulate @tsconfig/strictest package tempFs.createFilesSync({ @@ -2293,6 +2302,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, include: ['src/**/*.ts'], exclude: ['src/**/foo.ts'], // should be ignored because a referenced internal project includes this same pattern references: [ @@ -2306,7 +2316,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/other-lib/tsconfig.json': JSON.stringify({ include: ['**/*.ts'], // different pattern that should not be included because it's an external project }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, // Should be defined so that the project is considered buildable }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2374,6 +2384,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, // rootDir is required to determine if the project is buildable include: ['src/**/*.ts'], exclude: ['src/**/foo.ts'], // should be ignored references: [{ path: './tsconfig.other.json' }], @@ -2381,7 +2392,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.other.json': JSON.stringify({ include: ['other/**/*.ts', 'src/**/foo.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js" }`, }); let result = await invokeCreateNodesOnMatchingFiles(context, { @@ -2409,6 +2420,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, include: ['**/*.ts'], exclude: ['**/foo.ts'], // should be ignored references: [{ path: './tsconfig.other.json' }], @@ -2416,7 +2428,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.other.json': JSON.stringify({ include: ['other/**/*.ts', 'src/**/foo.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); result = await invokeCreateNodesOnMatchingFiles(context, { typecheck: false, @@ -2443,6 +2455,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, // rooDir is required to determine if the project is buildable include: ['src/**/*.ts'], exclude: ['src/**/foo.ts'], // should be ignored references: [{ path: './tsconfig.other.json' }], @@ -2450,7 +2463,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.other.json': JSON.stringify({ include: ['other/**/*.ts', '**/foo.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js" }`, // Should be defined so that the project is considered buildable }); result = await invokeCreateNodesOnMatchingFiles(context, { typecheck: false, @@ -2477,6 +2490,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, include: ['src/**/*.ts'], exclude: ['src/**/foo.ts'], // should be ignored references: [{ path: './tsconfig.other.json' }], @@ -2484,7 +2498,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.other.json': JSON.stringify({ include: ['./other/**/*.ts', './**/foo.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js" }`, }); result = await invokeCreateNodesOnMatchingFiles(context, { typecheck: false, @@ -2511,6 +2525,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, include: ['src/**/*.ts'], exclude: [ 'src/**/foo.ts', // should be ignored @@ -2521,7 +2536,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.other.json': JSON.stringify({ include: ['other/**/*.ts', 'src/**/foo.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js" }`, }); result = await invokeCreateNodesOnMatchingFiles(context, { typecheck: false, @@ -2549,10 +2564,11 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { it('should fall back to named inputs when not using include', async () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, files: ['main.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2628,11 +2644,14 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { it('should add the `outFile`', async () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ - compilerOptions: { outFile: '../../dist/libs/my-lib/index.js' }, + compilerOptions: { + outFile: '../../dist/libs/my-lib/index.js', + rootDir: 'src', + }, files: ['main.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/libs/my-lib/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2698,11 +2717,14 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { it('should add the `outDir`', async () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ - compilerOptions: { outDir: '../../dist/libs/my-lib' }, + compilerOptions: { + outDir: '../../dist/libs/my-lib', + rootDir: 'src', + }, files: ['main.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/libs/my-lib/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2764,6 +2786,7 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { it('should add the inline output files when `outDir` is not defined', async () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ + compilerOptions: { rootDir: 'src' }, files: ['main.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, @@ -2842,15 +2865,21 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ - compilerOptions: { outFile: '../../dist/libs/my-lib/lib.js' }, + compilerOptions: { + outFile: '../../dist/libs/my-lib/lib.js', + rootDir: 'src', + }, files: ['main.ts'], references: [{ path: './tsconfig.other.json' }], }), 'libs/my-lib/tsconfig.other.json': JSON.stringify({ - compilerOptions: { outDir: '../../dist/libs/my-lib/other' }, + compilerOptions: { + outDir: '../../dist/libs/my-lib/other', + rootDir: 'src', + }, include: ['other/**/*.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/libs/my-lib/lib.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2923,11 +2952,12 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ compilerOptions: { outFile: '../../dist/libs/my-lib/index.js', + rootDir: 'src', tsBuildInfoFile: '../../dist/libs/my-lib/my-lib.tsbuildinfo', }, files: ['main.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/libs/my-lib/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -2994,11 +3024,12 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.json': '{}', 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ compilerOptions: { + rootDir: 'src', tsBuildInfoFile: '../../dist/libs/my-lib/my-lib.tsbuildinfo', }, files: ['main.ts'], }), - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/libs/my-lib/index.js"}`, }); expect( await invokeCreateNodesOnMatchingFiles(context, { @@ -3073,13 +3104,14 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { await applyFilesToTempFsAndContext(tempFs, context, { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ compilerOptions: { + rootDir: 'src', outDir: 'dist', tsBuildInfoFile: 'my-lib.tsbuildinfo', }, files: ['main.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); expect( @@ -3145,12 +3177,13 @@ describe(`Plugin: ${PLUGIN_NAME}`, () => { 'libs/my-lib/tsconfig.lib.json': JSON.stringify({ compilerOptions: { outDir: 'dist', + rootDir: 'src', tsBuildInfoFile: 'dist/my-lib.tsbuildinfo', }, files: ['main.ts'], }), 'libs/my-lib/tsconfig.json': `{}`, - 'libs/my-lib/package.json': `{}`, + 'libs/my-lib/package.json': `{"main": "dist/index.js"}`, }); expect( diff --git a/packages/js/src/plugins/typescript/plugin.ts b/packages/js/src/plugins/typescript/plugin.ts index 9c4cb22397ed7..aada7857a9040 100644 --- a/packages/js/src/plugins/typescript/plugin.ts +++ b/packages/js/src/plugins/typescript/plugin.ts @@ -19,7 +19,15 @@ import { import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs'; import { minimatch } from 'minimatch'; import { existsSync, readdirSync, statSync } from 'node:fs'; -import { basename, dirname, join, normalize, relative, sep } from 'node:path'; +import { + basename, + dirname, + join, + normalize, + relative, + resolve, + sep, +} from 'node:path'; import { hashArray, hashFile, hashObject } from 'nx/src/hasher/file-hasher'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports import { getLockFileName } from 'nx/src/plugins/js/lock-file/lock-file'; @@ -201,6 +209,7 @@ async function createNodesInternal( context.workspaceRoot, projectRoot ); + const nodeHash = hashArray([ ...[ fullConfigPath, @@ -313,7 +322,16 @@ function buildTscTargets( } // Build target - if (options.build && basename(configFilePath) === options.build.configName) { + if ( + options.build && + basename(configFilePath) === options.build.configName && + isValidPackageJsonBuildConfig( + tsConfig, + context.workspaceRoot, + projectRoot, + configFilePath + ) + ) { internalProjectReferences ??= resolveInternalProjectReferences( tsConfig, context.workspaceRoot, @@ -578,6 +596,95 @@ function getOutputs( return Array.from(outputs); } +/** + * Checks whether a `package.json` file has a valid build configuration by ensuring + * that the `main`, `module`, or `exports` do not include paths from the `rootDir`. + * Or if `outFile` is defined, it should not be within the `rootDir`. + * + * @param tsConfig The TypeScript configuration object. + * @param workspaceRoot The workspace root path. + * @param projectRoot The project root path. + * @param tsConfigPath The path to the TypeScript configuration file. + * @returns `true` if the package has a valid build configuration; otherwise, `false`. + */ +function isValidPackageJsonBuildConfig( + tsConfig, + workspaceRoot: string, + projectRoot: string, + tsConfigPath: string +): boolean { + if (!existsSync(joinPathFragments(projectRoot, 'package.json'))) { + // If the package.json file does not exist. + // Assume it's valid because it would be using `project.json` instead. + return true; + } + const packageJson = readJsonFile( + joinPathFragments(projectRoot, 'package.json') + ); + const { rootDir, outFile } = tsConfig.options; + if (!rootDir) { + console.error( + `The 'rootDir' option is not defined in the ${tsConfigPath}.` + ); + return false; + } + + const isPathWithinSrc = (path: string): boolean => { + const resolvedRootDir = resolve(workspaceRoot, projectRoot, rootDir); + const pathToCheck = resolve(workspaceRoot, projectRoot, path); + + return pathToCheck.startsWith(resolvedRootDir); + }; + + // If `outFile` is defined, check the validity of the path. + if (outFile) { + if (isPathWithinSrc(outFile)) { + return false; + } + } + + const buildPaths = ['main', 'module']; + for (const field of buildPaths) { + if (packageJson[field] && isPathWithinSrc(packageJson[field])) { + return false; + } + } + + const exports = packageJson?.exports; + + // Checks if the value is a path within the `src` directory. + const containsInvalidPath = ( + value: string | Record + ): boolean => { + if (typeof value === 'string') { + return isPathWithinSrc(value); + } else if (typeof value === 'object') { + return Object.values(value).some((subValue) => { + if (typeof subValue === 'string') { + return isPathWithinSrc(subValue); + } + return false; + }); + } + return false; + }; + + if (typeof exports === 'string' && isPathWithinSrc(exports)) { + return false; + } + + // Check nested exports if `exports` is an object. + if (typeof exports === 'object') { + for (const key in exports) { + if (containsInvalidPath(exports[key])) { + return false; + } + } + } + + return true; +} + function pathToInputOrOutput( path: string, workspaceRoot: string, diff --git a/packages/react/src/generators/library/library.ts b/packages/react/src/generators/library/library.ts index 2e09bb44edbbe..968f47e917d19 100644 --- a/packages/react/src/generators/library/library.ts +++ b/packages/react/src/generators/library/library.ts @@ -32,7 +32,6 @@ import { extractTsConfigBase } from '../../utils/create-ts-config'; import { installCommonDependencies } from './lib/install-common-dependencies'; import { setDefaults } from './lib/set-defaults'; import { updateTsconfigFiles } from '@nx/js/src/utils/typescript/ts-solution-setup'; -import { ensureProjectIsExcludedFromPluginRegistrations } from '@nx/js/src/utils/typescript/plugin'; export async function libraryGenerator(host: Tree, schema: Schema) { return await libraryGeneratorInternal(host, { @@ -142,10 +141,6 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) { } else if (options.buildable && options.bundler === 'rollup') { const rollupTask = await addRollupBuildTarget(host, options); tasks.push(rollupTask); - } else if (options.bundler === 'none' && options.addPlugin) { - const nxJson = readNxJson(host); - ensureProjectIsExcludedFromPluginRegistrations(nxJson, options.projectRoot); - updateNxJson(host, nxJson); } // Set up test target diff --git a/packages/vue/src/generators/library/library.spec.ts b/packages/vue/src/generators/library/library.spec.ts index 723041f9d083f..75e883d9fdf68 100644 --- a/packages/vue/src/generators/library/library.spec.ts +++ b/packages/vue/src/generators/library/library.spec.ts @@ -605,48 +605,5 @@ module.exports = [ } `); }); - - it('should exclude non-buildable libraries from TS plugin registration', async () => { - updateJson(tree, 'nx.json', (json) => { - json.plugins = ['@nx/js/typescript']; - return json; - }); - await libraryGenerator(tree, { - ...defaultSchema, - addPlugin: true, - setParserOptionsProject: true, - linter: 'eslint', - bundler: 'none', - }); - - const nxJson = readJson(tree, 'nx.json'); - expect(nxJson.plugins).toMatchInlineSnapshot(` - [ - { - "exclude": [ - "my-lib/*", - ], - "plugin": "@nx/js/typescript", - }, - { - "options": { - "targetName": "lint", - }, - "plugin": "@nx/eslint/plugin", - }, - { - "options": { - "buildTargetName": "build", - "previewTargetName": "preview", - "serveStaticTargetName": "serve-static", - "serveTargetName": "serve", - "testTargetName": "test", - "typecheckTargetName": "typecheck", - }, - "plugin": "@nx/vite/plugin", - }, - ] - `); - }); }); }); diff --git a/packages/vue/src/generators/library/library.ts b/packages/vue/src/generators/library/library.ts index 6b286ae765240..a53c9ac699ce6 100644 --- a/packages/vue/src/generators/library/library.ts +++ b/packages/vue/src/generators/library/library.ts @@ -27,7 +27,6 @@ import { getRelativeCwd } from '@nx/devkit/src/generators/artifact-name-and-dire import { relative } from 'path'; import { getImportPath } from '@nx/js/src/utils/get-import-path'; import { updateTsconfigFiles } from '@nx/js/src/utils/typescript/ts-solution-setup'; -import { ensureProjectIsExcludedFromPluginRegistrations } from '@nx/js/src/utils/typescript/plugin'; export function libraryGenerator(tree: Tree, schema: Schema) { return libraryGeneratorInternal(tree, { addPlugin: false, ...schema }); @@ -130,12 +129,6 @@ export async function libraryGeneratorInternal(tree: Tree, schema: Schema) { }); } - if (options.bundler === 'none') { - const nxJson = readNxJson(tree); - ensureProjectIsExcludedFromPluginRegistrations(nxJson, options.projectRoot); - updateNxJson(tree, nxJson); - } - if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) { addTsConfigPath(tree, options.importPath, [ joinPathFragments(