fix(bundling): use vite createNodes v2 for add plugin (#26662)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

vite createNodesV1 is used during init

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

vite createNodesV2 is used during init

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jason Jean 2024-06-24 13:33:12 -07:00 committed by GitHub
parent 0e7e4690f2
commit a3322f76ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,10 +7,10 @@ import {
Tree, Tree,
updateNxJson, updateNxJson,
} from '@nx/devkit'; } from '@nx/devkit';
import { addPluginV1 } from '@nx/devkit/src/utils/add-plugin'; import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { setupPathsPlugin } from '../setup-paths-plugin/setup-paths-plugin'; import { setupPathsPlugin } from '../setup-paths-plugin/setup-paths-plugin';
import { createNodes } from '../../plugins/plugin'; import { createNodesV2 } from '../../plugins/plugin';
import { InitGeneratorSchema } from './schema'; import { InitGeneratorSchema } from './schema';
import { checkDependenciesInstalled, moveToDevDependencies } from './lib/utils'; import { checkDependenciesInstalled, moveToDevDependencies } from './lib/utils';
@ -61,11 +61,11 @@ export async function initGeneratorInternal(
schema.addPlugin ??= addPluginDefault; schema.addPlugin ??= addPluginDefault;
if (schema.addPlugin) { if (schema.addPlugin) {
await addPluginV1( await addPlugin(
tree, tree,
await createProjectGraphAsync(), await createProjectGraphAsync(),
'@nx/vite/plugin', '@nx/vite/plugin',
createNodes, createNodesV2,
{ {
buildTargetName: ['build', 'vite:build', 'vite-build'], buildTargetName: ['build', 'vite:build', 'vite-build'],
testTargetName: ['test', 'vite:test', 'vite-test'], testTargetName: ['test', 'vite:test', 'vite-test'],