diff --git a/docs/generated/packages/express/generators/application.json b/docs/generated/packages/express/generators/application.json index 10336208f37f7f..0b0bce7e959bd7 100644 --- a/docs/generated/packages/express/generators/application.json +++ b/docs/generated/packages/express/generators/application.json @@ -50,11 +50,6 @@ "type": "string", "description": "Frontend project that needs to access this application. This sets up proxy configuration." }, - "babelJest": { - "type": "boolean", - "description": "Use `babel` instead `ts-jest`.", - "default": false - }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", diff --git a/docs/generated/packages/jest/generators/jest-project.json b/docs/generated/packages/jest/generators/jest-project.json index aa49372db0464f..22e23d15d10f8e 100644 --- a/docs/generated/packages/jest/generators/jest-project.json +++ b/docs/generated/packages/jest/generators/jest-project.json @@ -48,7 +48,7 @@ }, "compiler": { "type": "string", - "enum": ["tsc", "babel", "swc"], + "enum": ["tsc", "swc", "babel"], "description": "The compiler to use for source and tests.", "default": "tsc" }, diff --git a/docs/generated/packages/node/generators/application.json b/docs/generated/packages/node/generators/application.json index a2bbe09416a603..422914c92d67b1 100644 --- a/docs/generated/packages/node/generators/application.json +++ b/docs/generated/packages/node/generators/application.json @@ -54,11 +54,6 @@ "description": "Frontend project that needs to access this application. This sets up proxy configuration.", "x-priority": "important" }, - "babelJest": { - "type": "boolean", - "description": "Use `babel` instead of `ts-jest`.", - "default": false - }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", diff --git a/docs/generated/packages/node/generators/library.json b/docs/generated/packages/node/generators/library.json index 47c5f4a86eab81..6da5b3eac7ad24 100644 --- a/docs/generated/packages/node/generators/library.json +++ b/docs/generated/packages/node/generators/library.json @@ -92,11 +92,6 @@ "description": "The test environment to use if `unitTestRunner` is set to `jest`.", "default": "jsdom" }, - "babelJest": { - "type": "boolean", - "description": "Use `babel` instead of `ts-jest`.", - "default": false - }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", diff --git a/docs/generated/packages/react/generators/application.json b/docs/generated/packages/react/generators/application.json index 90006ff44d5d86..976be0866d86d2 100644 --- a/docs/generated/packages/react/generators/application.json +++ b/docs/generated/packages/react/generators/application.json @@ -92,8 +92,8 @@ "default": false, "x-priority": "internal" }, - "skipWorkspaceJson": { - "description": "Skip updating `workspace.json` with default options based on values provided to this app (e.g. babel, style).", + "skipNxJson": { + "description": "Skip updating `nx.json` with default options based on values provided to this app.", "type": "boolean", "default": false, "x-priority": "internal" @@ -155,7 +155,7 @@ "compiler": { "type": "string", "description": "The compiler to use.", - "enum": ["babel", "swc"], + "enum": ["swc", "babel"], "default": "babel" }, "skipPackageJson": { diff --git a/docs/generated/packages/react/generators/host.json b/docs/generated/packages/react/generators/host.json index 3e6ef743992e19..e2ee2454686c81 100644 --- a/docs/generated/packages/react/generators/host.json +++ b/docs/generated/packages/react/generators/host.json @@ -73,7 +73,7 @@ "default": false, "x-priority": "internal" }, - "skipWorkspaceJson": { + "skipNxJson": { "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).", "type": "boolean", "default": false, diff --git a/docs/generated/packages/react/generators/library.json b/docs/generated/packages/react/generators/library.json index 21f89bdf1616f9..ecf86749e7c059 100644 --- a/docs/generated/packages/react/generators/library.json +++ b/docs/generated/packages/react/generators/library.json @@ -169,7 +169,7 @@ }, "compiler": { "type": "string", - "enum": ["babel", "swc"], + "enum": ["swc", "babel"], "default": "babel", "description": "Which compiler to use. Only applies to `bundler: 'rollup'`." }, diff --git a/docs/generated/packages/react/generators/remote.json b/docs/generated/packages/react/generators/remote.json index cd99a9e0f414a4..ae32c075dc0969 100644 --- a/docs/generated/packages/react/generators/remote.json +++ b/docs/generated/packages/react/generators/remote.json @@ -78,7 +78,7 @@ "default": false, "x-priority": "internal" }, - "skipWorkspaceJson": { + "skipNxJson": { "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).", "type": "boolean", "default": false, diff --git a/docs/generated/packages/web/generators/application.json b/docs/generated/packages/web/generators/application.json index d44bd521eaee4e..74f90cd73df607 100644 --- a/docs/generated/packages/web/generators/application.json +++ b/docs/generated/packages/web/generators/application.json @@ -43,8 +43,8 @@ "compiler": { "type": "string", "description": "The compiler to use", - "enum": ["babel", "swc"], - "default": "babel", + "enum": ["swc", "babel"], + "default": "swc", "x-priority": "important" }, "bundler": { diff --git a/packages/express/src/generators/application/schema.d.ts b/packages/express/src/generators/application/schema.d.ts index 1ec7eff6ee7ab0..8c69a1cf11c9a7 100644 --- a/packages/express/src/generators/application/schema.d.ts +++ b/packages/express/src/generators/application/schema.d.ts @@ -10,7 +10,6 @@ export interface Schema { tags?: string; linter: Linter; frontendProject?: string; - babelJest?: boolean; js: boolean; pascalCaseFiles: boolean; standaloneConfig?: boolean; diff --git a/packages/express/src/generators/application/schema.json b/packages/express/src/generators/application/schema.json index db3c743ce5f18b..892ce1bbc91c18 100644 --- a/packages/express/src/generators/application/schema.json +++ b/packages/express/src/generators/application/schema.json @@ -50,11 +50,6 @@ "type": "string", "description": "Frontend project that needs to access this application. This sets up proxy configuration." }, - "babelJest": { - "type": "boolean", - "description": "Use `babel` instead `ts-jest`.", - "default": false - }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", diff --git a/packages/jest/src/generators/jest-project/schema.json b/packages/jest/src/generators/jest-project/schema.json index a39db66f6bfd5e..2065c58350a53d 100644 --- a/packages/jest/src/generators/jest-project/schema.json +++ b/packages/jest/src/generators/jest-project/schema.json @@ -47,7 +47,7 @@ }, "compiler": { "type": "string", - "enum": ["tsc", "babel", "swc"], + "enum": ["tsc", "swc", "babel"], "description": "The compiler to use for source and tests.", "default": "tsc" }, diff --git a/packages/next/src/generators/library/library.ts b/packages/next/src/generators/library/library.ts index b1d6cf2c32b743..cfda6a23a2a926 100644 --- a/packages/next/src/generators/library/library.ts +++ b/packages/next/src/generators/library/library.ts @@ -71,36 +71,6 @@ export async function libraryGenerator(host: Tree, rawOptions: Schema) { ); addTsConfigPath(host, `${options.importPath}/server`, [serverEntryPath]); - updateJson( - host, - joinPathFragments(options.projectRoot, '.babelrc'), - (json) => { - if (options.style === '@emotion/styled') { - json.presets = [ - [ - '@nx/next/babel', - { - 'preset-react': { - runtime: 'automatic', - importSource: '@emotion/react', - }, - }, - ], - ]; - } else if (options.style === 'styled-jsx') { - // next.js doesn't require the `styled-jsx/babel' plugin as it is already - // built-into the `next/babel` preset - json.presets = ['@nx/next/babel']; - json.plugins = (json.plugins || []).filter( - (x) => x !== 'styled-jsx/babel' - ); - } else { - json.presets = ['@nx/next/babel']; - } - return json; - } - ); - updateJson( host, joinPathFragments(options.projectRoot, 'tsconfig.json'), diff --git a/packages/node/src/generators/application/application.spec.ts b/packages/node/src/generators/application/application.spec.ts index d3af66f1d6ed3e..e2af45976adeba 100644 --- a/packages/node/src/generators/application/application.spec.ts +++ b/packages/node/src/generators/application/application.spec.ts @@ -343,31 +343,6 @@ describe('app', () => { }); }); - describe('--babelJest', () => { - it('should use babel for jest', async () => { - await applicationGenerator(tree, { - name: 'myNodeApp', - tags: 'one,two', - babelJest: true, - } as Schema); - - expect(tree.read(`my-node-app/jest.config.ts`, 'utf-8')) - .toMatchInlineSnapshot(` - "/* eslint-disable */ - export default { - displayName: 'my-node-app', - preset: '../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\\\.[tj]s$': 'babel-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../coverage/my-node-app', - }; - " - `); - }); - }); describe('--js flag', () => { it('should generate js files instead of ts files', async () => { await applicationGenerator(tree, { diff --git a/packages/node/src/generators/application/schema.d.ts b/packages/node/src/generators/application/schema.d.ts index aec0248728ffc3..1c2ed3a94bda36 100644 --- a/packages/node/src/generators/application/schema.d.ts +++ b/packages/node/src/generators/application/schema.d.ts @@ -10,7 +10,6 @@ export interface Schema { linter?: Linter; tags?: string; frontendProject?: string; - babelJest?: boolean; js?: boolean; pascalCaseFiles?: boolean; setParserOptionsProject?: boolean; diff --git a/packages/node/src/generators/application/schema.json b/packages/node/src/generators/application/schema.json index 92b9f480109267..d7cafa3e3dd648 100644 --- a/packages/node/src/generators/application/schema.json +++ b/packages/node/src/generators/application/schema.json @@ -54,11 +54,6 @@ "description": "Frontend project that needs to access this application. This sets up proxy configuration.", "x-priority": "important" }, - "babelJest": { - "type": "boolean", - "description": "Use `babel` instead of `ts-jest`.", - "default": false - }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", diff --git a/packages/node/src/generators/library/library.spec.ts b/packages/node/src/generators/library/library.spec.ts index 3b4395165ec5d2..ec9a24d19db002 100644 --- a/packages/node/src/generators/library/library.spec.ts +++ b/packages/node/src/generators/library/library.spec.ts @@ -448,30 +448,6 @@ describe('lib', () => { }); }); - describe(`--babelJest`, () => { - it('should use babel for jest', async () => { - await libraryGenerator(tree, { - name: 'myLib', - babelJest: true, - } as Schema); - - expect(tree.read(`libs/my-lib/jest.config.ts`, 'utf-8')) - .toMatchInlineSnapshot(` - "/* eslint-disable */ - export default { - displayName: 'my-lib', - preset: '../../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\\\.[tj]s$': 'babel-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/my-lib', - }; - " - `); - }); - }); describe('--js flag', () => { it('should generate js files instead of ts files', async () => { await libraryGenerator(tree, { diff --git a/packages/node/src/generators/library/library.ts b/packages/node/src/generators/library/library.ts index f63a6e4f055d0c..b2b3e359c84837 100644 --- a/packages/node/src/generators/library/library.ts +++ b/packages/node/src/generators/library/library.ts @@ -51,7 +51,6 @@ export async function libraryGenerator(tree: Tree, schema: Schema) { const libraryInstall = await jsLibraryGenerator(tree, { ...schema, bundler: schema.buildable ? 'tsc' : 'none', - includeBabelRc: schema.babelJest, importPath: options.importPath, testEnvironment: 'node', skipFormat: true, diff --git a/packages/node/src/generators/library/schema.d.ts b/packages/node/src/generators/library/schema.d.ts index 837f21a69a9cd8..382708c7daf99e 100644 --- a/packages/node/src/generators/library/schema.d.ts +++ b/packages/node/src/generators/library/schema.d.ts @@ -14,7 +14,6 @@ export interface Schema { importPath?: string; testEnvironment?: 'jsdom' | 'node'; rootDir?: string; - babelJest?: boolean; js?: boolean; pascalCaseFiles?: boolean; strict?: boolean; diff --git a/packages/node/src/generators/library/schema.json b/packages/node/src/generators/library/schema.json index c66e679f4d005e..ff01ee207f55d1 100644 --- a/packages/node/src/generators/library/schema.json +++ b/packages/node/src/generators/library/schema.json @@ -92,11 +92,6 @@ "description": "The test environment to use if `unitTestRunner` is set to `jest`.", "default": "jsdom" }, - "babelJest": { - "type": "boolean", - "description": "Use `babel` instead of `ts-jest`.", - "default": false - }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index 04eae30f6480de..d51711c0a48ea3 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -849,12 +849,12 @@ describe('app', () => { ).toBeUndefined(); }); - describe('--skipWorkspaceJson', () => { + describe('--skipNxJson', () => { it('should update workspace with defaults when --skipprojectsConfigurations=false', async () => { await applicationGenerator(appTree, { ...schema, style: 'styled-components', - skipWorkspaceJson: false, + skipNxJson: false, }); const nxJson = readNxJson(appTree); diff --git a/packages/react/src/generators/application/lib/set-defaults.ts b/packages/react/src/generators/application/lib/set-defaults.ts index cad40197967570..0406985f151e77 100644 --- a/packages/react/src/generators/application/lib/set-defaults.ts +++ b/packages/react/src/generators/application/lib/set-defaults.ts @@ -2,7 +2,7 @@ import { readNxJson, Tree, updateNxJson } from '@nx/devkit'; import { NormalizedSchema } from '../schema'; export function setDefaults(host: Tree, options: NormalizedSchema) { - if (options.skipWorkspaceJson) { + if (options.skipNxJson) { return; } diff --git a/packages/react/src/generators/application/schema.d.ts b/packages/react/src/generators/application/schema.d.ts index ab83ef80b1ca71..7b8ae279ddbac1 100644 --- a/packages/react/src/generators/application/schema.d.ts +++ b/packages/react/src/generators/application/schema.d.ts @@ -14,7 +14,7 @@ export interface Schema { pascalCaseFiles?: boolean; classComponent?: boolean; routing?: boolean; - skipWorkspaceJson?: boolean; + skipNxJson?: boolean; js?: boolean; globalCss?: boolean; strict?: boolean; diff --git a/packages/react/src/generators/application/schema.json b/packages/react/src/generators/application/schema.json index 5eb0249f8015dc..b57c3272e9c49f 100644 --- a/packages/react/src/generators/application/schema.json +++ b/packages/react/src/generators/application/schema.json @@ -98,8 +98,8 @@ "default": false, "x-priority": "internal" }, - "skipWorkspaceJson": { - "description": "Skip updating `workspace.json` with default options based on values provided to this app (e.g. babel, style).", + "skipNxJson": { + "description": "Skip updating `nx.json` with default options based on values provided to this app.", "type": "boolean", "default": false, "x-priority": "internal" @@ -161,7 +161,7 @@ "compiler": { "type": "string", "description": "The compiler to use.", - "enum": ["babel", "swc"], + "enum": ["swc", "babel"], "default": "babel" }, "skipPackageJson": { diff --git a/packages/react/src/generators/host/schema.d.ts b/packages/react/src/generators/host/schema.d.ts index e8c63c6e83c032..3a524244ef30a7 100644 --- a/packages/react/src/generators/host/schema.d.ts +++ b/packages/react/src/generators/host/schema.d.ts @@ -15,7 +15,7 @@ export interface Schema { remotes?: string[]; setParserOptionsProject?: boolean; skipFormat?: boolean; - skipWorkspaceJson?: boolean; + skipNxJson?: boolean; ssr?: boolean; strict?: boolean; style: SupportedStyles; diff --git a/packages/react/src/generators/host/schema.json b/packages/react/src/generators/host/schema.json index 628dcc09201646..8f7fc3e742e8e5 100644 --- a/packages/react/src/generators/host/schema.json +++ b/packages/react/src/generators/host/schema.json @@ -79,7 +79,7 @@ "default": false, "x-priority": "internal" }, - "skipWorkspaceJson": { + "skipNxJson": { "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).", "type": "boolean", "default": false, diff --git a/packages/react/src/generators/library/files/common/.babelrc__tmpl__ b/packages/react/src/generators/library/files/common/.babelrc__tmpl__ deleted file mode 100644 index b4962b709b3c56..00000000000000 --- a/packages/react/src/generators/library/files/common/.babelrc__tmpl__ +++ /dev/null @@ -1,16 +0,0 @@ -{ - "presets": [ - [ - "@nx/react/babel", { - "runtime": "automatic", - "useBuiltIns": "usage" - <% if (style === '@emotion/styled') { %>,"importSource": "@emotion/react"<% } %> - } - ] - ], - "plugins": [ - <% if (style === 'styled-components') { %>["styled-components", { "pure": true, "ssr": true }]<% } %> - <% if (style === 'styled-jsx') { %>"styled-jsx/babel"<% } %> - <% if (style === '@emotion/styled') { %>"@emotion/babel-plugin"<% } %> - ] -} diff --git a/packages/react/src/generators/library/lib/create-files.ts b/packages/react/src/generators/library/lib/create-files.ts index 55579e7379bcc8..045e3d231364d1 100644 --- a/packages/react/src/generators/library/lib/create-files.ts +++ b/packages/react/src/generators/library/lib/create-files.ts @@ -5,6 +5,7 @@ import { names, offsetFromRoot, toJS, + writeJson, } from '@nx/devkit'; import { getRelativePathToRootTsConfig } from '@nx/js'; @@ -37,10 +38,34 @@ export function createFiles(host: Tree, options: NormalizedSchema) { options.projectRoot, substitutions ); + } - if (host.exists(joinPathFragments(options.projectRoot, '.babelrc'))) { - host.delete(joinPathFragments(options.projectRoot, '.babelrc')); - } + if (options.bundler === 'rollup' && options.compiler === 'babel') { + host.delete(joinPathFragments(options.projectRoot, '.babelrc')); + writeJson(host, joinPathFragments(options.projectRoot, '.babelrc'), { + presets: [ + [ + '@nx/react/babel', + { + runtime: 'automatic', + useBuiltIns: 'usage', + importSource: + options.style === '@emotion/styled' + ? '@emotion/react' + : undefined, + }, + ], + ], + plugins: [ + options.style === 'styled-components' + ? ['styled-components', { pure: true, ssr: true }] + : undefined, + options.style === 'styled-jsx' ? 'styled-jsx/babel' : undefined, + options.style === '@emotion/styled' + ? '@emotion/babel-plugin' + : undefined, + ].filter(Boolean), + }); } if (!options.publishable && !options.buildable) { diff --git a/packages/react/src/generators/library/schema.json b/packages/react/src/generators/library/schema.json index b8cea3a24e0603..2686b11886adf6 100644 --- a/packages/react/src/generators/library/schema.json +++ b/packages/react/src/generators/library/schema.json @@ -172,7 +172,7 @@ }, "compiler": { "type": "string", - "enum": ["babel", "swc"], + "enum": ["swc", "babel"], "default": "babel", "description": "Which compiler to use. Only applies to `bundler: 'rollup'`." }, diff --git a/packages/react/src/generators/remote/schema.d.ts b/packages/react/src/generators/remote/schema.d.ts index 2fa825a4e5791d..424385aa051bbf 100644 --- a/packages/react/src/generators/remote/schema.d.ts +++ b/packages/react/src/generators/remote/schema.d.ts @@ -17,7 +17,7 @@ export interface Schema { routing?: boolean; setParserOptionsProject?: boolean; skipFormat: boolean; - skipWorkspaceJson?: boolean; + skipNxJson?: boolean; ssr?: boolean; strict?: boolean; style: SupportedStyles; diff --git a/packages/react/src/generators/remote/schema.json b/packages/react/src/generators/remote/schema.json index 7e8b9acb9b4fae..bac051c1864345 100644 --- a/packages/react/src/generators/remote/schema.json +++ b/packages/react/src/generators/remote/schema.json @@ -84,7 +84,7 @@ "default": false, "x-priority": "internal" }, - "skipWorkspaceJson": { + "skipNxJson": { "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).", "type": "boolean", "default": false, diff --git a/packages/web/src/generators/application/schema.json b/packages/web/src/generators/application/schema.json index 5ce0957d30e931..18045d87215da0 100644 --- a/packages/web/src/generators/application/schema.json +++ b/packages/web/src/generators/application/schema.json @@ -46,8 +46,8 @@ "compiler": { "type": "string", "description": "The compiler to use", - "enum": ["babel", "swc"], - "default": "babel", + "enum": ["swc", "babel"], + "default": "swc", "x-priority": "important" }, "bundler": {