diff --git a/docs/generated/packages/rollup/executors/rollup.json b/docs/generated/packages/rollup/executors/rollup.json index 01e282a911809..09eb46124dbfe 100644 --- a/docs/generated/packages/rollup/executors/rollup.json +++ b/docs/generated/packages/rollup/executors/rollup.json @@ -150,6 +150,11 @@ "default": "babel", "description": "Which compiler to use." }, + "babelUpwardRootMode": { + "type": "boolean", + "description": "Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode", + "default": false + }, "javascriptEnabled": { "type": "boolean", "description": "Sets `javascriptEnabled` option for less loader", diff --git a/packages/expo/src/executors/build/build.impl.ts b/packages/expo/src/executors/build/build.impl.ts index 0df58debaca87..6b12fa6331204 100644 --- a/packages/expo/src/executors/build/build.impl.ts +++ b/packages/expo/src/executors/build/build.impl.ts @@ -3,7 +3,7 @@ import { join, normalize, sep } from 'path'; import { ChildProcess, fork } from 'child_process'; import { ensureNodeModulesSymlink } from '../../utils/ensure-node-modules-symlink'; -import { copyBuildFile, unzipBuild } from '../download/download.impl'; +import { unzipBuild } from '../download/download.impl'; import { ExpoEasBuildOptions } from './schema'; import { removeSync } from 'fs-extra'; diff --git a/packages/expo/src/generators/library/files/lib/tsconfig.json.template b/packages/expo/src/generators/library/files/lib/tsconfig.json.template index dacf3c7f5e0ac..d9affba903da0 100644 --- a/packages/expo/src/generators/library/files/lib/tsconfig.json.template +++ b/packages/expo/src/generators/library/files/lib/tsconfig.json.template @@ -1,7 +1,7 @@ { "extends": "<%= rootTsConfigPath %>", "compilerOptions": { - "jsx": "react-native", + "jsx": "react-jsx", "allowJs": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true diff --git a/packages/react-native/src/generators/library/files/lib/tsconfig.json__tmpl__ b/packages/react-native/src/generators/library/files/lib/tsconfig.json__tmpl__ index dacf3c7f5e0ac..d9affba903da0 100644 --- a/packages/react-native/src/generators/library/files/lib/tsconfig.json__tmpl__ +++ b/packages/react-native/src/generators/library/files/lib/tsconfig.json__tmpl__ @@ -1,7 +1,7 @@ { "extends": "<%= rootTsConfigPath %>", "compilerOptions": { - "jsx": "react-native", + "jsx": "react-jsx", "allowJs": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true diff --git a/packages/rollup/migrations.json b/packages/rollup/migrations.json index ad135dd94f011..eb151def3ad9b 100644 --- a/packages/rollup/migrations.json +++ b/packages/rollup/migrations.json @@ -11,6 +11,12 @@ "version": "16.0.0-beta.1", "description": "Replace @nrwl/rollup with @nx/rollup", "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages" + }, + "update-16-3-3-add-babel-upward-root-mode-flag": { + "cli": "nx", + "version": "16-3-3-beta.0", + "description": "Add babelUpwardRootMode if not already defined", + "implementation": "./src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag" } }, "packageJsonUpdates": {} diff --git a/packages/rollup/src/executors/rollup/rollup.impl.ts b/packages/rollup/src/executors/rollup/rollup.impl.ts index 423115122e35a..881dbcd593e3a 100644 --- a/packages/rollup/src/executors/rollup/rollup.impl.ts +++ b/packages/rollup/src/executors/rollup/rollup.impl.ts @@ -255,7 +255,7 @@ export function createRollupOptions( isModern: true, }, cwd: join(context.root, sourceRoot), - rootMode: 'upward', + rootMode: options.babelUpwardRootMode ? 'upward' : undefined, babelrc: true, extensions: fileExtensions, babelHelpers: 'bundled', diff --git a/packages/rollup/src/executors/rollup/schema.d.ts b/packages/rollup/src/executors/rollup/schema.d.ts index bcc5d69a6ad6c..ffef9aa4be9a3 100644 --- a/packages/rollup/src/executors/rollup/schema.d.ts +++ b/packages/rollup/src/executors/rollup/schema.d.ts @@ -32,4 +32,5 @@ export interface RollupExecutorOptions { javascriptEnabled?: boolean; generateExportsField?: boolean; skipTypeCheck?: boolean; + babelUpwardRootMode?: boolean; } diff --git a/packages/rollup/src/executors/rollup/schema.json b/packages/rollup/src/executors/rollup/schema.json index 3a1ceef59b38f..6510c4c224152 100644 --- a/packages/rollup/src/executors/rollup/schema.json +++ b/packages/rollup/src/executors/rollup/schema.json @@ -137,6 +137,11 @@ "default": "babel", "description": "Which compiler to use." }, + "babelUpwardRootMode": { + "type": "boolean", + "description": "Whether to set rootmode to upward. See https://babeljs.io/docs/en/options#rootmode", + "default": false + }, "javascriptEnabled": { "type": "boolean", "description": "Sets `javascriptEnabled` option for less loader", diff --git a/packages/rollup/src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.spec.ts b/packages/rollup/src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.spec.ts new file mode 100644 index 0000000000000..d041cd5fac4be --- /dev/null +++ b/packages/rollup/src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.spec.ts @@ -0,0 +1,58 @@ +import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; +import { + addProjectConfiguration, + readProjectConfiguration, + Tree, +} from '@nx/devkit'; +import addBabelUpwardRootModeFlag from './update-16-3-3-add-babel-upward-root-mode-flag'; + +describe('16.3.0 migration (add babelUpwardRootMode flag)', () => { + let tree: Tree; + + beforeEach(async () => { + tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); + }); + + it('should add the babelUpwardRootMode flag to rollup projects', async () => { + addProjectConfiguration(tree, 'app1', { + root: 'apps/app1', + targets: { + build: { + executor: '@nx/rollup:rollup', + options: {}, + }, + }, + }); + addProjectConfiguration(tree, 'app2', { + root: 'apps/app2', + targets: { + build: { + executor: '@nx/rollup:rollup', + options: { + babelUpwardRootMode: false, + }, + }, + }, + }); + + addProjectConfiguration(tree, 'app3', { + root: 'apps/app3', + targets: { + build: { + executor: '@nx/esbuild:esbuild', + options: {}, + }, + }, + }); + + await addBabelUpwardRootModeFlag(tree); + + const app1 = readProjectConfiguration(tree, 'app1'); + const app2 = readProjectConfiguration(tree, 'app2'); + const app3 = readProjectConfiguration(tree, 'app3'); + + expect(app1.targets['build'].options.babelUpwardRootMode).toBeTruthy(); + expect(app2.targets['build'].options.babelUpwardRootMode).toBeFalsy(); + expect(app3.targets['build'].options.babelUpwardRootMode).toBeUndefined(); + }); +}); diff --git a/packages/rollup/src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.ts b/packages/rollup/src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.ts new file mode 100644 index 0000000000000..35e02941539e5 --- /dev/null +++ b/packages/rollup/src/migrations/update-16-3-3-add-babel-upward-root-mode-flag/update-16-3-3-add-babel-upward-root-mode-flag.ts @@ -0,0 +1,32 @@ +import { + formatFiles, + readProjectConfiguration, + Tree, + updateProjectConfiguration, +} from '@nx/devkit'; +import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils'; +import { RollupExecutorOptions } from '../../executors/rollup/schema'; + +export default async function (tree: Tree) { + forEachExecutorOptions( + tree, + '@nx/rollup:rollup', + ( + options: RollupExecutorOptions, + projectName, + targetName, + _configurationName + ) => { + if (options.babelUpwardRootMode !== undefined) { + return; + } + + const projectConfiguration = readProjectConfiguration(tree, projectName); + projectConfiguration.targets[targetName].options.babelUpwardRootMode = + true; + updateProjectConfiguration(tree, projectName, projectConfiguration); + } + ); + + await formatFiles(tree); +}