Class private methods are not enabled. Please add `@babel/plugin-transform-private-methods` to your configuration
Хоть я и определил плагин @babel/plugin-transform-private-methods
, он почему-то не заработал
vite.config.mts
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/apps/web',
server: {
port: 4200,
host: 'localhost',
},
preview: {
port: 4300,
host: 'localhost',
},
optimizeDeps: {
include: [
'@emotion/react',
'@emotion/styled',
'@mui/material/Tooltip'
],
},
plugins: [react({
jsxImportSource: '@emotion/react',
babel: {
plugins: ['@emotion/babel-plugin', "@babel/plugin-transform-private-methods"],
},
}), nxViteTsPaths()],
// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },
build: {
outDir: '../../dist/apps/web',
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
},
test: {
globals: true,
cache: {
dir: '../../node_modules/.vitest',
},
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/apps/web',
provider: 'v8',
exclude: [
'server.ts', // Added these to be excluded from coverage
'handler.ts',
],
},
},
});
jest.config.ts
import { getJestProjects } from '@nx/jest';
export default {
projects: getJestProjects(),
transformIgnorePatterns: [
"[/\\\\]node_modules[/\\\\].+[^esm]\\.(js|jsx|mjs|cjs|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$",
],
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] },],
},
moduleNameMapper: {
'@diary-app/shared': '<rootDir>/libs/web/shared/src/index.ts',
'shared-backend': '<rootDir>/libs/backend/shared/src/index.ts'
},
testEnvironment: "jsdom",
setupFilesAfterEnv: ["@testing-library/jest-dom", "./jest.setup.ts"],
setupFiles: ['./jest.polyfills.js'],
testEnvironmentOptions: {
customExportConditions: [''],
},
};