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 012a74c
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 313 deletions.
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
223 changes: 0 additions & 223 deletions packages/vite/src/migrations/update-17-2-0/add-vite-plugin.spec.ts

This file was deleted.

31 changes: 0 additions & 31 deletions packages/vite/src/migrations/update-17-2-0/add-vite-plugin.ts

This file was deleted.

Loading

0 comments on commit 012a74c

Please sign in to comment.