UNPKG

@nx/react

Version:

The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook. - Generators for applica

35 lines (34 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateSpecConfig = updateSpecConfig; const maybe_js_1 = require("../../../utils/maybe-js"); const jest_utils_1 = require("../../../utils/jest-utils"); const devkit_1 = require("@nx/devkit"); function updateSpecConfig(host, options) { if (options.unitTestRunner === 'none') { return; } (0, devkit_1.updateJson)(host, `${options.appProjectRoot}/tsconfig.spec.json`, (json) => { const compilerOptions = json.compilerOptions ?? {}; const types = compilerOptions.types ?? []; if (options.style === 'styled-jsx') { types.push('@nx/react/typings/styled-jsx.d.ts'); } types.push('@nx/react/typings/cssmodule.d.ts', '@nx/react/typings/image.d.ts'); compilerOptions.types = types; json.compilerOptions = compilerOptions; if (options.isUsingTsSolutionConfig) { // add project reference to the runtime tsconfig.app.json file json.references ??= []; json.references.push({ path: './tsconfig.app.json' }); } return json; }); if (options.unitTestRunner !== 'jest') { return; } const configPath = (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/jest.config.ts`); const originalContent = host.read(configPath, 'utf-8'); const content = (0, jest_utils_1.updateJestConfigContent)(originalContent); host.write(configPath, content); }