Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc): respect useInferencePlugin in nx.json when generating apps and libs #26703

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/rollup/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
createProjectGraphAsync,
formatFiles,
GeneratorCallback,
readNxJson,
Tree,
} from '@nx/devkit';
import { nxVersion, rollupVersion } from '../../utils/versions';
Expand All @@ -12,7 +13,10 @@ import { createNodes } from '../../plugins/plugin';

export async function rollupInitGenerator(tree: Tree, schema: Schema) {
let task: GeneratorCallback = () => {};
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
const nxJson = readNxJson(tree);
schema.addPlugin ??=
process.env.NX_ADD_PLUGINS !== 'false' &&
nxJson.useInferencePlugins !== false;

if (!schema.skipPackageJson) {
const devDependencies = { '@nx/rollup': nxVersion };
Expand Down
7 changes: 6 additions & 1 deletion packages/vue/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
addProjectConfiguration,
formatFiles,
GeneratorCallback,
readNxJson,
runTasksInSerial,
toJS,
Tree,
Expand All @@ -28,7 +29,11 @@ export async function applicationGeneratorInternal(
_options: Schema
): Promise<GeneratorCallback> {
const options = await normalizeOptions(tree, _options);
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
const nxJson = readNxJson(tree);

options.addPlugin ??=
process.env.NX_ADD_PLUGINS !== 'false' &&
nxJson.useInferencePlugins !== false;

const tasks: GeneratorCallback[] = [];

Expand Down
15 changes: 13 additions & 2 deletions packages/vue/src/generators/library/lib/normalize-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { getProjects, logger, normalizePath, Tree } from '@nx/devkit';
import {
getProjects,
logger,
normalizePath,
readNxJson,
Tree,
} from '@nx/devkit';
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
import { NormalizedSchema, Schema } from '../schema';

Expand Down Expand Up @@ -36,9 +42,14 @@ export async function normalizeOptions(
bundler = 'vite';
}
}
const nxJson = readNxJson(host);

const addPlugin =
process.env.NX_ADD_PLUGINS !== 'false' &&
nxJson.useInferencePlugins !== false;

const normalized = {
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
addPlugin,
...options,
bundler,
fileName,
Expand Down