Skip to content

Commit

Permalink
feat(vite): remove migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Nov 30, 2023
1 parent 03a4eb5 commit 719801a
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 480 deletions.
8 changes: 0 additions & 8 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -9034,14 +9034,6 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Overview of the @nx/vite/plugin",
"path": "/nx-api/vite/documents/vite-nodes-plugin",
"id": "vite-nodes-plugin",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"isExternal": false,
Expand Down
11 changes: 0 additions & 11 deletions docs/generated/manifests/nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2524,17 +2524,6 @@
"path": "/nx-api/vite/documents/overview",
"tags": [],
"originalFilePath": "shared/packages/vite/vite-plugin"
},
"/nx-api/vite/documents/vite-nodes-plugin": {
"id": "vite-nodes-plugin",
"name": "Overview of the @nx/vite/plugin",
"description": "The @nx/vite/plugin adds Vite targets/projects to the Nx project graph. This allows you to run Vite for projects that have a vite.config.ts file without creating a project.json file.",
"file": "generated/packages/vite/documents/vite-nodes-plugin",
"itemList": [],
"isExternal": false,
"path": "/nx-api/vite/documents/vite-nodes-plugin",
"tags": [],
"originalFilePath": "shared/packages/vite/vite-nodes-plugin"
}
},
"root": "/packages/vite",
Expand Down
11 changes: 0 additions & 11 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2497,17 +2497,6 @@
"path": "vite/documents/overview",
"tags": [],
"originalFilePath": "shared/packages/vite/vite-plugin"
},
{
"id": "vite-nodes-plugin",
"name": "Overview of the @nx/vite/plugin",
"description": "The @nx/vite/plugin adds Vite targets/projects to the Nx project graph. This allows you to run Vite for projects that have a vite.config.ts file without creating a project.json file.",
"file": "generated/packages/vite/documents/vite-nodes-plugin",
"itemList": [],
"isExternal": false,
"path": "vite/documents/vite-nodes-plugin",
"tags": [],
"originalFilePath": "shared/packages/vite/vite-nodes-plugin"
}
],
"executors": [
Expand Down
64 changes: 0 additions & 64 deletions docs/generated/packages/vite/documents/vite-nodes-plugin.md

This file was deleted.

7 changes: 0 additions & 7 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2151,13 +2151,6 @@
"name": "Overview of the Nx Vite Plugin",
"description": "The Nx Plugin for Vite contains executors and generators that support building applications using Vite. This page also explains how to configure Vite on your Nx workspace.",
"file": "shared/packages/vite/vite-plugin"
},
{
"id": "vite-nodes-plugin",
"path": "/nx-api/vite-nodes-plugin",
"name": "Overview of the @nx/vite/plugin",
"description": "The @nx/vite/plugin adds Vite targets/projects to the Nx project graph. This allows you to run Vite for projects that have a vite.config.ts file without creating a project.json file.",
"file": "shared/packages/vite/vite-nodes-plugin"
}
]
},
Expand Down
64 changes: 0 additions & 64 deletions docs/shared/packages/vite/vite-nodes-plugin.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/shared/reference/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@
- [vite](/nx-api/vite)
- [documents](/nx-api/vite/documents)
- [Overview of the Nx Vite Plugin](/nx-api/vite/documents/overview)
- [Overview of the @nx/vite/plugin](/nx-api/vite/documents/vite-nodes-plugin)
- [executors](/nx-api/vite/executors)
- [dev-server](/nx-api/vite/executors/dev-server)
- [build](/nx-api/vite/executors/build)
Expand Down
7 changes: 5 additions & 2 deletions packages/react/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
ensurePackage,
getPackageManagerCommand,
joinPathFragments,
readNxJson,
} from '@nx/devkit';
import { webStaticServeGenerator } from '@nx/web';

import { nxVersion } from '../../../utils/versions';
import { hasWebpackPlugin } from '../../../utils/has-webpack-plugin';
import { hasVitePlugin } from '../../../utils/has-vite-plugin';
import { NormalizedSchema } from '../schema';

export async function addE2e(
Expand All @@ -18,7 +18,10 @@ export async function addE2e(
): Promise<GeneratorCallback> {
switch (options.e2eTestRunner) {
case 'cypress': {
if (!hasWebpackPlugin(tree)) {
if (
(options.bundler === 'webpack' && !hasWebpackPlugin(tree)) ||
(options.bundler === 'vite' && !hasVitePlugin(tree))
) {
webStaticServeGenerator(tree, {
buildTarget: `${options.projectName}:build`,
targetName: 'serve-static',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default defineConfig({
// },
test: {
reportsDirectory: '../coverage/my-lib',
globals: true,
cache: { dir: '../node_modules/.vitest' },
environment: 'jsdom',
Expand Down Expand Up @@ -72,7 +71,6 @@ export default defineConfig({
// External packages that should not be bundled into your library.
external: ['react', 'react-dom', 'react/jsx-runtime'],
},
outDir: 'dist/my-lib',
},
test: {
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/utils/has-vite-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { readNxJson, Tree } from '@nx/devkit';

export function hasVitePlugin(tree: Tree) {
const nxJson = readNxJson(tree);
return !!nxJson.plugins?.some((p) =>
typeof p === 'string'
? p === '@nx/vite/plugin'
: p.plugin === '@nx/vite/plugin'
);
}
5 changes: 0 additions & 5 deletions packages/vite/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
"version": "17.2.0-beta.10",
"description": "Update vite config.",
"implementation": "./src/migrations/update-17-2-0/update-vite-config"
},
"add-vite-plugin": {
"version": "17.3.0-beta.0",
"description": "Add @nx/vite/plugin",
"implementation": "./src/migrations/update-17-2-0/add-vite-plugin"
}
},
"packageJsonUpdates": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default defineConfig({
// External packages that should not be bundled into your library.
external: ['react', 'react-dom', 'react/jsx-runtime'],
},
outDir: 'dist/react-lib-nonb-jest',
},
});
"
Expand Down Expand Up @@ -94,7 +93,6 @@ export default defineConfig({
// External packages that should not be bundled into your library.
external: ['react', 'react-dom', 'react/jsx-runtime'],
},
outDir: 'dist/react-lib-nonb-jest',
},
test: {
Expand Down Expand Up @@ -170,7 +168,6 @@ export default defineConfig({
// External packages that should not be bundled into your library.
external: ['react', 'react-dom', 'react/jsx-runtime'],
},
outDir: 'dist/react-lib-nonb-vitest',
},
plugins: [
nxViteTsPaths(),
Expand Down
11 changes: 0 additions & 11 deletions packages/vite/src/generators/init/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ export function createVitestConfig(tree: Tree) {
nxJson.namedInputs.production = Array.from(new Set(productionFileSet));
}

nxJson.targetDefaults ??= {};
nxJson.targetDefaults['@nx/vite:test'] ??= {};
nxJson.targetDefaults['@nx/vite:test'].cache ??= true;
nxJson.targetDefaults['@nx/vite:test'].inputs ??= [
'default',
productionFileSet ? '^production' : '^default',
];
nxJson.targetDefaults['@nx/vite:test'].options ??= {
passWithNoTests: true,
};

updateNxJson(tree, nxJson);
}

Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/generators/vitest/vitest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ describe('vitest generator', () => {
expect(config.targets['test']).toMatchInlineSnapshot(`
{
"executor": "@nx/vite:test",
"options": {
"reportsDirectory": "../../coverage/apps/my-test-react-app",
},
"outputs": [
"{options.reportsDirectory}",
],
Expand Down

0 comments on commit 719801a

Please sign in to comment.