diff --git a/.eslintrc.json b/.eslintrc.json index 556554a795..4cf7f347f6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,7 +18,7 @@ "files": ["./package.json", "./generators.json", "./executors.json"], "parser": "jsonc-eslint-parser", "rules": { - "@nrwl/nx/nx-plugin-checks": "error" + "@nx/nx-plugin-checks": "error" } } ] diff --git a/README.md b/README.md index 0e43fea55a..0246d31b25 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ npx nx g @nrwl/rspack:rspack-project --skipValidation The `@nrwl/rspack` executor support importing workspace libs into the app. ```bash -npx nx g @nrwl/react:lib mylib +npx nx g @nx/react:lib mylib ``` Import the new library in your app. diff --git a/package.json b/package.json index eb6755f792..e352b6fa0d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@nrwl/rspack", + "name": "@nx/rspack", "version": "0.0.1", "type": "commonjs", "repository": { @@ -19,9 +19,9 @@ "generators": "./generators.json", "executors": "./executors.json", "dependencies": { - "@nrwl/js": "^15.8.1", - "@nrwl/linter": "^15.8.1", - "@nrwl/devkit": "^15.8.1", + "@nx/js": "^16.0.0", + "@nx/linter": "^16.0.0", + "@nx/devkit": "^16.0.0", "@phenomnomnominal/tsquery": "~5.0.1", "ajv": "^8.12.0", "ajv-keywords": "5.1.0", diff --git a/project.json b/project.json index 8cd47ed61a..193c2dc521 100644 --- a/project.json +++ b/project.json @@ -5,7 +5,7 @@ "projectType": "library", "targets": { "build": { - "executor": "@nrwl/js:tsc", + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/packages/rspack", @@ -37,7 +37,7 @@ } }, "lint": { - "executor": "@nrwl/linter:eslint", + "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { "lintFilePatterns": [ @@ -49,7 +49,7 @@ } }, "test": { - "executor": "@nrwl/jest:jest", + "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { "jestConfig": "packages/rspack/jest.config.ts", diff --git a/src/executors/dev-server/dev-server.impl.ts b/src/executors/dev-server/dev-server.impl.ts index d7d6c59e7f..8c192be408 100644 --- a/src/executors/dev-server/dev-server.impl.ts +++ b/src/executors/dev-server/dev-server.impl.ts @@ -2,8 +2,8 @@ import { ExecutorContext, parseTargetString, readTargetOptions, -} from '@nrwl/devkit'; -import { createAsyncIterable } from '@nrwl/devkit/src/utils/async-iterable'; +} from '@nx/devkit'; +import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable'; import { DevServer } from '@rspack/core/dist/config'; import { RspackDevServer } from '@rspack/dev-server'; import { createCompiler } from '../../utils/create-compiler'; diff --git a/src/executors/dev-server/schema.json b/src/executors/dev-server/schema.json index 7c0b6fc91f..178eb12faf 100644 --- a/src/executors/dev-server/schema.json +++ b/src/executors/dev-server/schema.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/schema", "version": 2, - "cli": "nx", "title": "Rspack dev-server executor", "description": "", "type": "object", diff --git a/src/executors/rspack/rspack.impl.ts b/src/executors/rspack/rspack.impl.ts index 8fa1f1ff3f..c550cd232d 100644 --- a/src/executors/rspack/rspack.impl.ts +++ b/src/executors/rspack/rspack.impl.ts @@ -1,5 +1,5 @@ -import { ExecutorContext, logger } from '@nrwl/devkit'; -import { createAsyncIterable } from '@nrwl/devkit/src/utils/async-iterable'; +import { ExecutorContext, logger } from '@nx/devkit'; +import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable'; import { Stats } from '@rspack/core'; import Watching from '@rspack/core/dist/watching'; import { rmSync } from 'fs'; diff --git a/src/executors/rspack/schema.json b/src/executors/rspack/schema.json index aaa282ccf5..0337f7a24e 100644 --- a/src/executors/rspack/schema.json +++ b/src/executors/rspack/schema.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/schema", "version": 2, - "cli": "nx", "title": "Rspack build executor", "description": "", "type": "object", diff --git a/src/generators/application/application.ts b/src/generators/application/application.ts index 05a6c44ddd..bd41490e3d 100644 --- a/src/generators/application/application.ts +++ b/src/generators/application/application.ts @@ -1,9 +1,4 @@ -import { - ensurePackage, - formatFiles, - runTasksInSerial, - Tree, -} from '@nrwl/devkit'; +import { ensurePackage, formatFiles, runTasksInSerial, Tree } from '@nx/devkit'; import { version as nxVersion } from 'nx/package.json'; import configurationGenerator from '../configuration/configuration'; import rspackInitGenerator from '../init/init'; @@ -24,7 +19,7 @@ export default async function ( if (options.framework === 'nest') { const { applicationGenerator: nestAppGenerator } = ensurePackage( - '@nrwl/nest', + '@nx/nest', nxVersion ); const createAppTask = await nestAppGenerator(tree, { @@ -70,7 +65,7 @@ export default async function ( } else { // default to react const { applicationGenerator: reactAppGenerator } = ensurePackage( - '@nrwl/react', + '@nx/react', nxVersion ); const createAppTask = await reactAppGenerator(tree, { diff --git a/src/generators/application/lib/create-ts-config.ts b/src/generators/application/lib/create-ts-config.ts index bb1e49877a..4bbfa2b836 100644 --- a/src/generators/application/lib/create-ts-config.ts +++ b/src/generators/application/lib/create-ts-config.ts @@ -1,4 +1,4 @@ -import { Tree, workspaceRoot, writeJson } from '@nrwl/devkit'; +import { Tree, workspaceRoot, writeJson } from '@nx/devkit'; import { relative } from 'path'; import { Framework } from '../../init/schema'; @@ -8,12 +8,12 @@ export function editTsConfig( framework: Framework, relativePathToRootTsConfig: string ) { - // Nx 15.8 moved util to @nrwl/js, but it is in @nrwl/workspace in 15.7 + // Nx 15.8 moved util to @nx/js, but it is in @nx/workspace in 15.7 let shared: any; try { - shared = require('@nrwl/js/src/utils/typescript/create-ts-config'); + shared = require('@nx/js/src/utils/typescript/create-ts-config'); } catch { - shared = require('@nrwl/workspace/src/utils/create-ts-config'); + shared = require('@nx/workspace/src/utils/create-ts-config'); } if (framework === 'react') { diff --git a/src/generators/application/lib/normalize-options.spec.ts b/src/generators/application/lib/normalize-options.spec.ts index 208f091cf5..3e560296fc 100644 --- a/src/generators/application/lib/normalize-options.spec.ts +++ b/src/generators/application/lib/normalize-options.spec.ts @@ -1,5 +1,5 @@ -import { Tree } from '@nrwl/devkit'; -import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; +import { Tree } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { normalizeOptions } from './normalize-options'; describe('normalizeOptions', () => { diff --git a/src/generators/application/lib/normalize-options.ts b/src/generators/application/lib/normalize-options.ts index a21f25900f..72c03ffec8 100644 --- a/src/generators/application/lib/normalize-options.ts +++ b/src/generators/application/lib/normalize-options.ts @@ -4,7 +4,7 @@ import { names, normalizePath, Tree, -} from '@nrwl/devkit'; +} from '@nx/devkit'; import { ApplicationGeneratorSchema, NormalizedSchema } from '../schema'; export function normalizeDirectory(options: ApplicationGeneratorSchema) { @@ -23,7 +23,7 @@ export function normalizeOptions( options: ApplicationGeneratorSchema ): NormalizedSchema { // --monorepo takes precedence over --rootProject - // This won't be needed once we add --bundler=rspack to the @nrwl/react:app preset + // This won't be needed once we add --bundler=rspack to the @nx/react:app preset const rootProject = !options.monorepo && options.rootProject; const appDirectory = normalizeDirectory(options); const appProjectName = normalizeProjectName(options); diff --git a/src/generators/application/schema.json b/src/generators/application/schema.json index 60451adaf0..b193d1b330 100644 --- a/src/generators/application/schema.json +++ b/src/generators/application/schema.json @@ -1,6 +1,5 @@ { "$schema": "http://json-schema.org/schema", - "cli": "nx", "$id": "Application", "title": "Application generator for React + rspack", "type": "object", diff --git a/src/generators/configuration/configuration.ts b/src/generators/configuration/configuration.ts index 4f2970bc56..4ea1ac7e6b 100644 --- a/src/generators/configuration/configuration.ts +++ b/src/generators/configuration/configuration.ts @@ -4,7 +4,7 @@ import { offsetFromRoot, readProjectConfiguration, Tree, -} from '@nrwl/devkit'; +} from '@nx/devkit'; import { addOrChangeBuildTarget, addOrChangeServeTarget, @@ -72,8 +72,8 @@ export async function configurationGenerator( options.framework === 'nest') ) { throw new Error( - `The project ${options.project} is already configured to use the @nrwl/rspack executors. - Please try a different project, or remove the existing targets + `The project ${options.project} is already configured to use the @nx/rspack executors. + Please try a different project, or remove the existing targets and re-run this generator to reset the existing Rspack Configuration. ` ); @@ -81,7 +81,7 @@ export async function configurationGenerator( if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) { throw new Error( - `The project ${options.project} cannot be converted to use the @nrwl/rspack executors.` + `The project ${options.project} cannot be converted to use the @nx/rspack executors.` ); } diff --git a/src/generators/configuration/schema.json b/src/generators/configuration/schema.json index 7b1899ccb7..d2593ae47e 100644 --- a/src/generators/configuration/schema.json +++ b/src/generators/configuration/schema.json @@ -1,6 +1,5 @@ { "$schema": "http://json-schema.org/schema", - "cli": "nx", "$id": "Rspack", "title": "", "type": "object", diff --git a/src/generators/init/init.ts b/src/generators/init/init.ts index 11484900bd..96c8dfd632 100644 --- a/src/generators/init/init.ts +++ b/src/generators/init/init.ts @@ -1,12 +1,11 @@ import { addDependenciesToPackageJson, convertNxGenerator, - ensurePackage, GeneratorCallback, runTasksInSerial, Tree, -} from '@nrwl/devkit'; -import { version as nxVersion } from 'nx/package.json'; +} from '@nx/devkit'; +import { initGenerator } from '@nx/js'; import { rspackCoreVersion, rspackDevServerVersion, @@ -20,10 +19,6 @@ export async function rspackInitGenerator( schema: InitGeneratorSchema ) { const tasks: GeneratorCallback[] = []; - const { initGenerator } = ensurePackage( - '@nrwl/js', - nxVersion - ); const jsInitTask = await initGenerator(tree, { ...schema, tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json', @@ -41,7 +36,7 @@ export async function rspackInitGenerator( const version = require('../../../package.json').version; if (version !== '0.0.1') { // Ignored for local dev / e2e tests. - devDependencies['@nrwl/rspack'] = version; + devDependencies['@nx/rspack'] = version; } if (schema.style === 'less') { diff --git a/src/generators/init/schema.json b/src/generators/init/schema.json index 81c9bfa02e..b53f45eeea 100644 --- a/src/generators/init/schema.json +++ b/src/generators/init/schema.json @@ -1,6 +1,5 @@ { "$schema": "http://json-schema.org/schema", - "cli": "nx", "$id": "Init", "title": "", "type": "object", diff --git a/src/generators/preset/preset.ts b/src/generators/preset/preset.ts index a12b16c7da..69bec32baa 100644 --- a/src/generators/preset/preset.ts +++ b/src/generators/preset/preset.ts @@ -1,4 +1,4 @@ -import { Tree, updateJson } from '@nrwl/devkit'; +import { Tree, updateJson } from '@nx/devkit'; import applicationGenerator from '../application/application'; import { PresetGeneratorSchema } from './schema'; diff --git a/src/generators/preset/schema.json b/src/generators/preset/schema.json index f7118466c1..45b542f2d2 100644 --- a/src/generators/preset/schema.json +++ b/src/generators/preset/schema.json @@ -1,6 +1,5 @@ { "$schema": "http://json-schema.org/schema", - "cli": "nx", "$id": "Preset", "title": "Standalone React and rspack preset", "type": "object", diff --git a/src/utils/create-compiler.ts b/src/utils/create-compiler.ts index 5ba7ca1442..fbb0b1c4d1 100644 --- a/src/utils/create-compiler.ts +++ b/src/utils/create-compiler.ts @@ -1,4 +1,4 @@ -import { ExecutorContext } from '@nrwl/devkit'; +import { ExecutorContext } from '@nx/devkit'; import { Compiler, createCompiler as _createCompiler } from '@rspack/core'; import * as path from 'path'; import { RspackExecutorSchema } from '../executors/rspack/schema'; diff --git a/src/utils/generator-utils.ts b/src/utils/generator-utils.ts index 2a8a089226..a89a4d5e9c 100644 --- a/src/utils/generator-utils.ts +++ b/src/utils/generator-utils.ts @@ -5,8 +5,8 @@ import { TargetConfiguration, Tree, updateProjectConfiguration, -} from '@nrwl/devkit'; -import { ensureTypescript } from '@nrwl/js/src/utils/typescript/ensure-typescript'; +} from '@nx/devkit'; +import { ensureTypescript } from '@nx/js/src/utils/typescript/ensure-typescript'; import { RspackExecutorSchema } from '../executors/rspack/schema'; import { ConfigurationSchema } from '../generators/configuration/schema'; import { Framework } from '../generators/init/schema'; @@ -41,24 +41,40 @@ export function findExistingTargetsInProject( '@nrwl/rollup:rollup', '@nrwl/web:rollup', '@nrwl/vite:build', + '@nx/webpack:webpack', + '@nx/rollup:rollup', + '@nx/web:rollup', + '@nx/vite:build', ], serve: [ '@nxext/vite:dev', '@nrwl/webpack:dev-server', '@nrwl/vite:dev-server', + '@nx/webpack:dev-server', + '@nx/vite:dev-server', ], }; const unsupportedExecutors = [ + '@nx/js:babel', + '@nx/js:node', + '@nx/js:swc', + '@nx/react-native:run-ios', + '@nx/react-native:start', + '@nx/react-native:run-android', + '@nx/react-native:bundle', + '@nx/react-native:build-android', + '@nx/react-native:bundle', + '@nx/next:build', + '@nx/next:server', + '@nx/js:tsc', + '@nx/angular:ng-packagr-lite', + '@nx/angular:package', + '@nx/angular:webpack-browser', + '@nx/esbuild:esbuild', '@nrwl/js:babel', '@nrwl/js:node', '@nrwl/js:swc', - '@nrwl/js:tsc', - '@nrwl/angular:ng-packagr-lite', - '@nrwl/angular:package', - '@nrwl/angular:webpack-browser', - '@angular-devkit/build-angular:browser', - '@angular-devkit/build-angular:dev-server', '@nrwl/react-native:run-ios', '@nrwl/react-native:start', '@nrwl/react-native:run-android', @@ -67,7 +83,13 @@ export function findExistingTargetsInProject( '@nrwl/react-native:bundle', '@nrwl/next:build', '@nrwl/next:server', + '@nrwl/js:tsc', + '@nrwl/angular:ng-packagr-lite', + '@nrwl/angular:package', + '@nrwl/angular:webpack-browser', '@nrwl/esbuild:esbuild', + '@angular-devkit/build-angular:browser', + '@angular-devkit/build-angular:dev-server', ]; // First, we check if the user has provided a target @@ -102,8 +124,8 @@ export function findExistingTargetsInProject( const executorName = targets[target].executor; const hasRspackTargets = output.alreadyHasNxRspackTargets; - hasRspackTargets.build ||= executorName === '@nrwl/rspack:rspack'; - hasRspackTargets.serve ||= executorName === '@nrwl/rspack:dev-server'; + hasRspackTargets.build ||= executorName === '@nx/rspack:rspack'; + hasRspackTargets.serve ||= executorName === '@nx/rspack:dev-server'; const foundTargets = output.validFoundTargetName; if ( @@ -159,7 +181,7 @@ export function addOrChangeBuildTarget( project.targets ??= {}; project.targets[target] = { - executor: '@nrwl/rspack:rspack', + executor: '@nx/rspack:rspack', outputs: ['{options.outputPath}'], defaultConfiguration: 'production', options: buildOptions, @@ -188,7 +210,7 @@ export function addOrChangeServeTarget( project.targets ??= {}; project.targets[target] = { - executor: '@nrwl/rspack:dev-server', + executor: '@nx/rspack:dev-server', options: { buildTarget: `${options.project}:build:development`, }, @@ -222,7 +244,7 @@ function createConfig( ) { if (options.framework === 'react') { return ` - const { composePlugins, withNx, withReact } = require('@nrwl/rspack'); + const { composePlugins, withNx, withReact } = require('@nx/rspack'); module.exports = composePlugins(withNx(), withReact(${ stylePreprocessorOptions @@ -238,7 +260,7 @@ function createConfig( `; } else if (options.framework === 'web' || options.target === 'web') { return ` - const { composePlugins, withNx, withWeb } = require('@nrwl/rspack'); + const { composePlugins, withNx, withWeb } = require('@nx/rspack'); module.exports = composePlugins(withNx(), withWeb(${ stylePreprocessorOptions @@ -254,7 +276,7 @@ function createConfig( `; } else if (options.framework === 'nest') { return ` - const { composePlugins, withNx } = require('@nrwl/rspack'); + const { composePlugins, withNx } = require('@nx/rspack'); module.exports = composePlugins(withNx(), (config) => { return config; @@ -264,7 +286,7 @@ function createConfig( return ` const { composePlugins, withNx${ stylePreprocessorOptions ? ', withWeb' : '' - } } = require('@nrwl/rspack'); + } } = require('@nx/rspack'); module.exports = composePlugins(withNx()${ stylePreprocessorOptions @@ -392,7 +414,7 @@ export function getViteConfigPathForProject( viteConfigPath = targets?.[target]?.options?.configFile; } else { const config = Object.values(targets).find( - (config) => config.executor === '@nrwl/rspack:build' + (config) => config.executor === '@nx/rspack:build' ); viteConfigPath = config?.options?.configFile; } @@ -436,7 +458,7 @@ async function handleUnsupportedUserProvidedTargetsErrors( executor: 'rspack' | 'dev-server' ) { logger.warn( - `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nrwl/rspack:${executor} executor. + `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/rspack:${executor} executor. However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName} Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit @@ -447,13 +469,13 @@ async function handleUnsupportedUserProvidedTargetsErrors( const { Confirm } = require('enquirer'); const prompt = new Confirm({ name: 'question', - message: `Should we convert the ${validFoundTargetName} target to use the @nrwl/rspack:${executor} executor?`, + message: `Should we convert the ${validFoundTargetName} target to use the @nx/rspack:${executor} executor?`, initial: true, }); const shouldConvert = await prompt.run(); if (!shouldConvert) { throw new Error( - `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nrwl/rspack:${executor} executor. + `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/rspack:${executor} executor. Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will convert the first one it finds, most probably this one: ${validFoundTargetName}) @@ -467,14 +489,14 @@ async function handleUnsupportedUserProvidedTargetsErrors( export async function handleUnknownExecutors(projectName: string) { logger.warn( ` - We could not find any targets in project ${projectName} that use executors which - can be converted to the @nrwl/rspack executors. + We could not find any targets in project ${projectName} that use executors which + can be converted to the @nx/rspack executors. - This either means that your project may not have a target - for building, serving, or testing at all, or that your targets are + This either means that your project may not have a target + for building, serving, or testing at all, or that your targets are using executors that are not known to Nx. - - If you still want to convert your project to use the @nrwl/rspack executors, + + If you still want to convert your project to use the @nx/rspack executors, please make sure to commit your changes before running this generator. ` ); @@ -483,13 +505,13 @@ export async function handleUnknownExecutors(projectName: string) { const { Confirm } = require('enquirer'); const prompt = new Confirm({ name: 'question', - message: `Should Nx convert your project to use the @nrwl/rspack executors?`, + message: `Should Nx convert your project to use the @nx/rspack executors?`, initial: true, }); const shouldConvert = await prompt.run(); if (!shouldConvert) { throw new Error(` - Nx could not verify that the executors you are using can be converted to the @nrwl/rspack executors. + Nx could not verify that the executors you are using can be converted to the @nx/rspack executors. Please try again with a different project. `); } @@ -512,7 +534,7 @@ export function determineFrameworkAndTarget( // Try to infer from jest config if the env is node let jestConfigPath: string; if ( - targets?.test?.executor !== '@nrwl/jest:jest' && + targets?.test?.executor !== '@nx/jest:jest' && targets?.test?.options?.jestConfig ) { jestConfigPath = targets?.test?.options?.jestConfig; diff --git a/src/utils/jest-utils.ts b/src/utils/jest-utils.ts index c44bc73429..2000cede46 100644 --- a/src/utils/jest-utils.ts +++ b/src/utils/jest-utils.ts @@ -2,10 +2,10 @@ export function updateJestConfigContent(content: string) { return content .replace( 'transform: {', - "transform: {\n '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest'," + "transform: {\n '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest'," ) .replace( `'babel-jest'`, - `['babel-jest', { presets: ['@nrwl/react/babel'] }]` + `['babel-jest', { presets: ['@nx/react/babel'] }]` ); } diff --git a/src/utils/model.ts b/src/utils/model.ts index 999f4ef3d8..3ca89adaaa 100644 --- a/src/utils/model.ts +++ b/src/utils/model.ts @@ -1,4 +1,4 @@ -import { ExecutorContext } from '@nrwl/devkit'; +import { ExecutorContext } from '@nx/devkit'; import { RspackExecutorSchema } from '../executors/rspack/schema'; export interface SharedConfigContext { diff --git a/src/utils/normalize-assets.ts b/src/utils/normalize-assets.ts index 3bb3c2d623..2eae341f3e 100644 --- a/src/utils/normalize-assets.ts +++ b/src/utils/normalize-assets.ts @@ -1,4 +1,4 @@ -import { normalizePath } from '@nrwl/devkit'; +import { normalizePath } from '@nx/devkit'; import { statSync } from 'fs'; import { basename, dirname, relative, resolve } from 'path';