feat(rsbuild): move plugin export to root of package (#29415)
## Current Behavior The Rsbuild plugin is exported at `@nx/rsbuild/plugin` ## Expected Behavior Export the plugin from `@nx/rsbuild` i.e. the root of the package.
This commit is contained in:
parent
656d69b466
commit
2db82dd36d
@ -27,7 +27,8 @@ export async function addE2e(
|
||||
const hasNxBuildPlugin =
|
||||
(options.bundler === 'webpack' && hasWebpackPlugin(tree)) ||
|
||||
(options.bundler === 'rspack' && hasRspackPlugin(tree)) ||
|
||||
(options.bundler === 'rsbuild' && hasRsbuildPlugin(tree)) ||
|
||||
(options.bundler === 'rsbuild' &&
|
||||
(await hasRsbuildPlugin(tree, options.appProjectRoot))) ||
|
||||
(options.bundler === 'vite' && hasVitePlugin(tree));
|
||||
|
||||
let e2eWebServerInfo: E2EWebServerDetails = {
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import { readNxJson, Tree } from '@nx/devkit';
|
||||
import { ensurePackage, Tree } from '@nx/devkit';
|
||||
import { nxVersion } from './versions';
|
||||
|
||||
export function hasRsbuildPlugin(tree: Tree) {
|
||||
const nxJson = readNxJson(tree);
|
||||
return !!nxJson.plugins?.some((p) =>
|
||||
typeof p === 'string'
|
||||
? p === '@nx/rsbuild/plugin'
|
||||
: p.plugin === '@nx/rsbuild/plugin'
|
||||
);
|
||||
export async function hasRsbuildPlugin(tree: Tree, projectPath?: string) {
|
||||
ensurePackage('@nx/rsbuild', nxVersion);
|
||||
const { hasRsbuildPlugin } = await import('@nx/rsbuild/config-utils');
|
||||
return hasRsbuildPlugin(tree, projectPath);
|
||||
}
|
||||
|
||||
@ -6,3 +6,4 @@ export {
|
||||
} from './src/utils/ast-utils';
|
||||
export * as versions from './src/utils/versions';
|
||||
export { getRsbuildE2EWebServerInfo } from './src/utils/e2e-web-server-info-utils';
|
||||
export { hasRsbuildPlugin } from './src/utils/has-rsbuild-plugin';
|
||||
|
||||
@ -0,0 +1 @@
|
||||
export { createNodesV2, RsbuildPluginOptions } from './src/plugins/plugin';
|
||||
@ -55,10 +55,6 @@
|
||||
"./config-utils": {
|
||||
"types": "./config-utils.d.ts",
|
||||
"default": "./config-utils.js"
|
||||
},
|
||||
"./plugin": {
|
||||
"types": "./plugin.d.ts",
|
||||
"default": "./plugin.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
export { createNodesV2, RsbuildPluginOptions } from './src/plugins/plugin';
|
||||
@ -43,7 +43,7 @@ export async function initGeneratorInternal(
|
||||
await addPlugin(
|
||||
tree,
|
||||
await createProjectGraphAsync(),
|
||||
'@nx/rsbuild/plugin',
|
||||
'@nx/rsbuild',
|
||||
createNodesV2,
|
||||
{
|
||||
buildTargetName: ['build', 'rsbuild:build', 'rsbuild-build'],
|
||||
|
||||
@ -15,7 +15,7 @@ jest.mock('@nx/js/src/utils/typescript/ts-solution-setup', () => ({
|
||||
isUsingTsSolutionSetup: jest.fn().mockReturnValue(false),
|
||||
}));
|
||||
|
||||
describe('@nx/rsbuild/plugin', () => {
|
||||
describe('@nx/rsbuild', () => {
|
||||
let createNodesFunction = createNodesV2[1];
|
||||
let context: CreateNodesContext;
|
||||
let tempFs: TempFs;
|
||||
|
||||
@ -22,7 +22,7 @@ export async function getRsbuildE2EWebServerInfo(
|
||||
tree,
|
||||
projectName,
|
||||
{
|
||||
plugin: '@nx/rsbuild/plugin',
|
||||
plugin: '@nx/rsbuild',
|
||||
serveTargetName: 'devTargetName',
|
||||
serveStaticTargetName: 'previewTargetName',
|
||||
configFilePath,
|
||||
|
||||
33
packages/rsbuild/src/utils/has-rsbuild-plugin.ts
Normal file
33
packages/rsbuild/src/utils/has-rsbuild-plugin.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { type Tree, readNxJson } from '@nx/devkit';
|
||||
import { minimatch } from 'minimatch';
|
||||
|
||||
export function hasRsbuildPlugin(tree: Tree, projectPath?: string) {
|
||||
const nxJson = readNxJson(tree);
|
||||
if (!projectPath) {
|
||||
return !!nxJson.plugins?.some((p) =>
|
||||
typeof p === 'string' ? p === '@nx/rsbuild' : p.plugin === '@nx/rsbuild'
|
||||
);
|
||||
}
|
||||
return !!nxJson.plugins?.some((p) => {
|
||||
if (typeof p === 'string') {
|
||||
return p === '@nx/rsbuild';
|
||||
}
|
||||
if (p.exclude) {
|
||||
for (const exclude of p.exclude) {
|
||||
if (minimatch(projectPath, exclude)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p.include) {
|
||||
for (const include of p.include) {
|
||||
if (minimatch(projectPath, include)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no include or exclude, then it's a match
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -114,7 +114,7 @@ describe('application generator', () => {
|
||||
expect(listFiles(tree)).toMatchSnapshot();
|
||||
expect(
|
||||
readNxJson(tree).plugins.find(
|
||||
(p) => typeof p !== 'string' && p.plugin === '@nx/rsbuild/plugin'
|
||||
(p) => typeof p !== 'string' && p.plugin === '@nx/rsbuild'
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
@ -125,7 +125,7 @@ describe('application generator', () => {
|
||||
"previewTargetName": "preview",
|
||||
"typecheckTargetName": "typecheck",
|
||||
},
|
||||
"plugin": "@nx/rsbuild/plugin",
|
||||
"plugin": "@nx/rsbuild",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
import { webStaticServeGenerator } from '@nx/web';
|
||||
|
||||
import { nxVersion } from '../../../utils/versions';
|
||||
import { hasRsbuildPlugin } from '../../../utils/has-rsbuild-plugin';
|
||||
import { NormalizedSchema } from '../schema';
|
||||
import { findPluginForConfigFile } from '@nx/devkit/src/utils/find-plugin-for-config-file';
|
||||
import { addE2eCiTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
|
||||
@ -20,11 +21,7 @@ export async function addE2e(
|
||||
const nxJson = readNxJson(tree);
|
||||
const hasPlugin =
|
||||
options.bundler === 'rsbuild'
|
||||
? nxJson.plugins?.find((p) =>
|
||||
typeof p === 'string'
|
||||
? p === '@nx/rsbuild/plugin'
|
||||
: p.plugin === '@nx/rsbuild/plugin'
|
||||
)
|
||||
? await hasRsbuildPlugin(tree, options.appProjectRoot)
|
||||
: nxJson.plugins?.find((p) =>
|
||||
typeof p === 'string'
|
||||
? p === '@nx/vite/plugin'
|
||||
|
||||
8
packages/vue/src/utils/has-rsbuild-plugin.ts
Normal file
8
packages/vue/src/utils/has-rsbuild-plugin.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { ensurePackage, Tree } from '@nx/devkit';
|
||||
import { nxVersion } from './versions';
|
||||
|
||||
export async function hasRsbuildPlugin(tree: Tree, projectPath?: string) {
|
||||
ensurePackage('@nx/rsbuild', nxVersion);
|
||||
const { hasRsbuildPlugin } = await import('@nx/rsbuild/config-utils');
|
||||
return hasRsbuildPlugin(tree, projectPath);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user