From ffd9bc773dac2107153921371c7233077d22947e Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Mon, 5 Jun 2023 10:56:01 -0400 Subject: [PATCH] Revert "[Do not merge]: feat(bundling): Add support to rollup for babelUpwardRootMode (#17292)" This reverts commit 2d76993e6835983c56b77c029f052557b34f8d56. --- .../packages/rollup/executors/rollup.json | 5 -- .../expo/src/executors/build/build.impl.ts | 2 +- .../library/files/lib/tsconfig.json.template | 2 +- .../library/files/lib/tsconfig.json__tmpl__ | 2 +- packages/rollup/migrations.json | 6 -- .../src/executors/rollup/rollup.impl.ts | 2 +- .../rollup/src/executors/rollup/schema.d.ts | 1 - .../rollup/src/executors/rollup/schema.json | 5 -- ...-1-add-babel-upward-root-mode-flag.spec.ts | 58 ------------------- ...-16-3-1-add-babel-upward-root-mode-flag.ts | 32 ---------- 10 files changed, 4 insertions(+), 111 deletions(-) delete mode 100644 packages/rollup/src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.spec.ts delete mode 100644 packages/rollup/src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.ts diff --git a/docs/generated/packages/rollup/executors/rollup.json b/docs/generated/packages/rollup/executors/rollup.json index 09eb46124dbfe..01e282a911809 100644 --- a/docs/generated/packages/rollup/executors/rollup.json +++ b/docs/generated/packages/rollup/executors/rollup.json @@ -150,11 +150,6 @@ "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 97d42fc12d554..5fbfd16de62aa 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 { unzipBuild } from '../download/download.impl'; +import { copyBuildFile, 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 d9affba903da0..dacf3c7f5e0ac 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-jsx", + "jsx": "react-native", "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 d9affba903da0..dacf3c7f5e0ac 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-jsx", + "jsx": "react-native", "allowJs": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true diff --git a/packages/rollup/migrations.json b/packages/rollup/migrations.json index 35c19e83e6e8b..ad135dd94f011 100644 --- a/packages/rollup/migrations.json +++ b/packages/rollup/migrations.json @@ -11,12 +11,6 @@ "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-1-add-babel-upward-root-mode-flag": { - "cli": "nx", - "version": "16-3-1-beta.0", - "description": "Add babelUpwardRootMode if not already defined", - "implementation": "./src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-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 881dbcd593e3a..423115122e35a 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: options.babelUpwardRootMode ? 'upward' : undefined, + rootMode: 'upward', 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 ffef9aa4be9a3..bcc5d69a6ad6c 100644 --- a/packages/rollup/src/executors/rollup/schema.d.ts +++ b/packages/rollup/src/executors/rollup/schema.d.ts @@ -32,5 +32,4 @@ 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 6510c4c224152..3a1ceef59b38f 100644 --- a/packages/rollup/src/executors/rollup/schema.json +++ b/packages/rollup/src/executors/rollup/schema.json @@ -137,11 +137,6 @@ "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-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.spec.ts b/packages/rollup/src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.spec.ts deleted file mode 100644 index 758106b3351c8..0000000000000 --- a/packages/rollup/src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; -import { - addProjectConfiguration, - readProjectConfiguration, - Tree, -} from '@nx/devkit'; -import addBabelUpwardRootModeFlag from './update-16-3-1-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-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.ts b/packages/rollup/src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.ts deleted file mode 100644 index 35e02941539e5..0000000000000 --- a/packages/rollup/src/migrations/update-16-3-1-add-babel-upward-root-mode-flag/update-16-3-1-add-babel-upward-root-mode-flag.ts +++ /dev/null @@ -1,32 +0,0 @@ -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); -}