@nx/react-native 17.0.3 → 17.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +7 -1
- package/LICENSE +1 -1
- package/README.md +9 -4
- package/executors.json +5 -0
- package/generators.json +12 -11
- package/migrations.json +126 -0
- package/package.json +11 -15
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +162 -0
- package/plugins/with-nx-metro.js +6 -2
- package/src/executors/build-android/build-android.impl.js +2 -6
- package/src/executors/build-android/build-android.impl.ts +2 -6
- package/src/executors/build-android/schema.json +1 -1
- package/src/executors/build-ios/schema.json +1 -1
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/bundle/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +4 -0
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/pod-install/schema.json +1 -1
- package/src/executors/run-android/run-android.impl.js +5 -17
- package/src/executors/run-android/run-android.impl.ts +9 -18
- package/src/executors/run-android/schema.json +1 -1
- package/src/executors/run-ios/run-ios.impl.js +4 -16
- package/src/executors/run-ios/run-ios.impl.ts +9 -18
- package/src/executors/run-ios/schema.json +1 -1
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +11 -26
- package/src/executors/start/start.impl.ts +14 -28
- package/src/executors/storybook/storybook.impl.d.ts +4 -0
- package/src/executors/storybook/storybook.impl.js +15 -2
- package/src/executors/storybook/storybook.impl.ts +26 -7
- package/src/executors/sync-deps/schema.d.ts +1 -0
- package/src/executors/sync-deps/schema.json +6 -1
- package/src/executors/sync-deps/sync-deps.impl.d.ts +2 -1
- package/src/executors/sync-deps/sync-deps.impl.js +33 -11
- package/src/executors/sync-deps/sync-deps.impl.ts +57 -18
- package/src/executors/upgrade/schema.d.ts +1 -0
- package/src/executors/upgrade/schema.json +11 -0
- package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
- package/src/executors/upgrade/upgrade.impl.js +47 -0
- package/src/executors/upgrade/upgrade.impl.ts +64 -0
- package/src/generators/application/application.js +52 -8
- package/src/generators/application/application.spec.ts +29 -2
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/Gemfile.template +2 -1
- package/src/generators/application/files/app/android/app/build.gradle.template +12 -28
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +2 -6
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
- package/src/generators/application/files/app/android/build.gradle.template +7 -20
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/src/generators/application/files/app/android/gradle.properties +0 -3
- package/src/generators/application/files/app/android/gradlew.template +12 -7
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/ios/Podfile.template +0 -7
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +5 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +5 -8
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +11 -33
- package/src/generators/application/files/app/metro.config.js.template +1 -5
- package/src/generators/application/files/app/src/app/App.tsx.template +50 -13
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +46 -0
- package/src/generators/application/lib/add-project.js +18 -18
- package/src/generators/application/lib/normalize-options.d.ts +7 -0
- package/src/generators/application/lib/normalize-options.js +35 -3
- package/src/generators/application/lib/normalize-options.spec.ts +70 -7
- package/src/generators/application/schema.d.ts +5 -3
- package/src/generators/application/schema.json +14 -6
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +4 -4
- package/src/generators/component-story/component-story.d.ts +5 -8
- package/src/generators/component-story/component-story.js +8 -69
- package/src/generators/component-story/schema.d.ts +1 -0
- package/src/generators/component-story/schema.json +11 -3
- package/src/generators/init/init.d.ts +2 -1
- package/src/generators/init/init.js +55 -56
- package/src/generators/init/init.spec.ts +7 -6
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +13 -18
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +5 -0
- package/src/generators/library/library.js +48 -38
- package/src/generators/library/library.spec.ts +12 -60
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +2 -2
- package/src/generators/stories/schema.d.ts +2 -0
- package/src/generators/stories/schema.json +15 -2
- package/src/generators/stories/stories.d.ts +5 -2
- package/src/generators/stories/stories.js +7 -50
- package/src/generators/storybook-configuration/configuration.d.ts +7 -2
- package/src/generators/storybook-configuration/configuration.js +18 -48
- package/src/generators/storybook-configuration/schema.d.ts +4 -2
- package/src/generators/storybook-configuration/schema.json +22 -12
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.json +3 -3
- package/src/generators/upgrade-native/upgrade-native.d.ts +2 -0
- package/src/generators/upgrade-native/upgrade-native.js +3 -0
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
- package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +14 -0
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
- package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
- package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
- package/src/generators/web-configuration/schema.d.ts +6 -0
- package/src/generators/web-configuration/schema.json +42 -0
- package/src/generators/web-configuration/web-configuration.d.ts +12 -0
- package/src/generators/web-configuration/web-configuration.js +87 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +1 -5
- package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
- package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-block-list.js +28 -0
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
- package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
- package/src/migrations/update-18-0-0/remove-metro.js +29 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +13 -1
- package/src/utils/add-linting.d.ts +1 -0
- package/src/utils/add-linting.js +1 -1
- package/src/utils/add-linting.spec.ts +4 -6
- package/src/utils/chmod-android-gradle-files.js +6 -2
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +30 -0
- package/src/utils/find-all-npm-dependencies.js +5 -3
- package/src/utils/find-all-npm-dependencies.spec.ts +17 -9
- package/src/utils/testing-generators.js +1 -0
- package/src/utils/versions.d.ts +10 -13
- package/src/utils/versions.js +11 -14
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -75
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +0 -32
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +0 -62
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -20
- package/src/generators/application/files/app/babel.config.json.template +0 -3
- package/src/generators/application/lib/add-detox.d.ts +0 -3
- package/src/generators/application/lib/add-detox.js +0 -23
- package/src/generators/component-story/component-story.spec.ts +0 -428
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
- package/src/generators/library/files/lib/babel.config.json.template +0 -17
- package/src/generators/stories/stories-app.spec.ts +0 -128
- package/src/generators/stories/stories-lib.spec.ts +0 -105
- package/src/generators/storybook-configuration/configuration.spec.ts +0 -135
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +0 -9
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +0 -74
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +0 -5
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +0 -25
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +0 -161
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +0 -42
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +0 -7
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +0 -29
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +0 -65
- package/src/utils/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
|
@@ -1,56 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storybookConfigurationGenerator = void 0;
|
|
3
|
+
exports.storybookConfigurationGeneratorInternal = exports.storybookConfigurationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
async function generateStories(host, schema) {
|
|
11
|
-
await (0, stories_1.default)(host, {
|
|
12
|
-
project: schema.name,
|
|
13
|
-
ignorePaths: schema.ignorePaths,
|
|
14
|
-
skipFormat: true,
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
function storybookConfigurationGenerator(tree, schema) {
|
|
7
|
+
return storybookConfigurationGeneratorInternal(tree, {
|
|
8
|
+
addPlugin: false,
|
|
9
|
+
...schema,
|
|
15
10
|
});
|
|
16
11
|
}
|
|
17
|
-
async function storybookConfigurationGenerator(host, schema) {
|
|
18
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
|
|
19
|
-
const installTask = await configurationGenerator(host, {
|
|
20
|
-
name: schema.name,
|
|
21
|
-
uiFramework: '@storybook/react-native',
|
|
22
|
-
configureCypress: false,
|
|
23
|
-
js: false,
|
|
24
|
-
linter: schema.linter,
|
|
25
|
-
standaloneConfig: schema.standaloneConfig,
|
|
26
|
-
tsConfiguration: schema.tsConfiguration,
|
|
27
|
-
skipFormat: true,
|
|
28
|
-
});
|
|
29
|
-
const installRequiredPackagesTask = await (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
30
|
-
'@react-native-async-storage/async-storage': versions_1.reactNativeAsyncStorageVersion,
|
|
31
|
-
'react-native-safe-area-context': versions_1.reactNativeSafeAreaContextVersion,
|
|
32
|
-
});
|
|
33
|
-
addStorybookTask(host, schema.name);
|
|
34
|
-
(0, create_storybook_files_1.createStorybookFiles)(host, schema);
|
|
35
|
-
(0, replace_app_import_with_storybook_toggle_1.replaceAppImportWithStorybookToggle)(host, schema);
|
|
36
|
-
(0, add_resolver_main_fields_to_metro_config_1.addResolverMainFieldsToMetroConfig)(host, schema);
|
|
37
|
-
if (schema.generateStories) {
|
|
38
|
-
await generateStories(host, schema);
|
|
39
|
-
}
|
|
40
|
-
await (0, devkit_1.formatFiles)(host);
|
|
41
|
-
return (0, devkit_1.runTasksInSerial)(installTask, installRequiredPackagesTask);
|
|
42
|
-
}
|
|
43
12
|
exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(0,
|
|
13
|
+
/**
|
|
14
|
+
* This would be a direct pass through to @nx/react:storybook-configuration generator.
|
|
15
|
+
* @TODO (@xiongemi): remove this generator for v19
|
|
16
|
+
*/
|
|
17
|
+
async function storybookConfigurationGeneratorInternal(host, schema) {
|
|
18
|
+
devkit_1.logger.warn(`Please run 'nx run @nx/react:storybook-configuration ${schema.project}' instead.`);
|
|
19
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
20
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
21
|
+
nxJson.useInferencePlugins !== false;
|
|
22
|
+
schema.addPlugin ??= addPluginDefault;
|
|
23
|
+
return (0, react_1.storybookConfigurationGenerator)(host, schema);
|
|
55
24
|
}
|
|
25
|
+
exports.storybookConfigurationGeneratorInternal = storybookConfigurationGeneratorInternal;
|
|
56
26
|
exports.default = storybookConfigurationGenerator;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Linter } from '@nx/eslint';
|
|
2
2
|
|
|
3
3
|
export interface StorybookConfigureSchema {
|
|
4
|
-
|
|
4
|
+
project: string;
|
|
5
|
+
interactionTests?: boolean;
|
|
5
6
|
generateStories?: boolean;
|
|
6
7
|
js?: boolean;
|
|
7
8
|
tsConfiguration?: boolean;
|
|
8
9
|
linter?: Linter;
|
|
9
|
-
standaloneConfig?: boolean;
|
|
10
10
|
ignorePaths?: string[];
|
|
11
|
+
configureStaticServe?: boolean;
|
|
12
|
+
addPlugin?: boolean;
|
|
11
13
|
}
|
|
@@ -1,29 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeStorybookConfigure",
|
|
5
5
|
"title": "React native Storybook configuration",
|
|
6
6
|
"description": "Set up Storybook for a React-Native app or library.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"project": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"aliases": ["
|
|
11
|
+
"aliases": ["name", "projectName"],
|
|
12
12
|
"description": "Project for which to generate Storybook configuration.",
|
|
13
13
|
"$default": {
|
|
14
14
|
"$source": "argv",
|
|
15
15
|
"index": 0
|
|
16
16
|
},
|
|
17
17
|
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
18
|
-
"x-dropdown": "projects"
|
|
18
|
+
"x-dropdown": "projects",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"interactionTests": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Set up Storybook interaction tests.",
|
|
24
|
+
"x-prompt": "Do you want to set up Storybook interaction tests?",
|
|
25
|
+
"x-priority": "important",
|
|
26
|
+
"alias": ["configureTestRunner"],
|
|
27
|
+
"default": true
|
|
19
28
|
},
|
|
20
29
|
"generateStories": {
|
|
21
30
|
"type": "boolean",
|
|
22
|
-
"description": "Automatically generate
|
|
31
|
+
"description": "Automatically generate `*.stories.ts` files for components declared in this project?",
|
|
23
32
|
"x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
24
33
|
"default": true,
|
|
25
34
|
"x-priority": "important"
|
|
26
35
|
},
|
|
36
|
+
"configureStaticServe": {
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
39
|
+
"x-prompt": "Configure a static file server for the storybook instance?",
|
|
40
|
+
"default": true,
|
|
41
|
+
"x-priority": "important"
|
|
42
|
+
},
|
|
27
43
|
"js": {
|
|
28
44
|
"type": "boolean",
|
|
29
45
|
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
@@ -40,12 +56,6 @@
|
|
|
40
56
|
"enum": ["eslint"],
|
|
41
57
|
"default": "eslint"
|
|
42
58
|
},
|
|
43
|
-
"standaloneConfig": {
|
|
44
|
-
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
45
|
-
"type": "boolean",
|
|
46
|
-
"default": true,
|
|
47
|
-
"x-deprecated": "Nx only supports standaloneConfig"
|
|
48
|
-
},
|
|
49
59
|
"ignorePaths": {
|
|
50
60
|
"type": "array",
|
|
51
61
|
"description": "Paths to ignore when looking for components.",
|
|
@@ -65,5 +75,5 @@
|
|
|
65
75
|
]
|
|
66
76
|
}
|
|
67
77
|
},
|
|
68
|
-
"required": ["
|
|
78
|
+
"required": ["project"]
|
|
69
79
|
}
|
|
@@ -6,7 +6,7 @@ export interface NormalizedSchema {
|
|
|
6
6
|
lowerCaseName: string;
|
|
7
7
|
entryFile: string;
|
|
8
8
|
entryFileIos: string;
|
|
9
|
-
e2eTestRunner: 'detox' | 'none';
|
|
9
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none';
|
|
10
10
|
offsetFromRoot: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function normalizeOptions(options: UpgradeNativeConfigureSchema, appProjectRoot: string): NormalizedSchema;
|
|
@@ -4,6 +4,6 @@ export interface UpgradeNativeConfigureSchema {
|
|
|
4
4
|
name: string;
|
|
5
5
|
displayName?: string;
|
|
6
6
|
js: boolean; // default is false
|
|
7
|
-
e2eTestRunner: 'detox' | 'none'; // default is
|
|
7
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none'; // default is cypress
|
|
8
8
|
install: boolean; // default is true
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeUpgradeNativeConfigure",
|
|
5
5
|
"title": "React native upgrade native configuration",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"e2eTestRunner": {
|
|
28
28
|
"description": "Adds the specified e2e test runner.",
|
|
29
29
|
"type": "string",
|
|
30
|
-
"enum": ["detox", "none"],
|
|
31
|
-
"default": "
|
|
30
|
+
"enum": ["cypress", "playwright", "detox", "none"],
|
|
31
|
+
"default": "cypress"
|
|
32
32
|
},
|
|
33
33
|
"install": {
|
|
34
34
|
"type": "boolean",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated use `nx run @nx/react-native:upgrade` instead.
|
|
3
|
+
* TODO (@xiongemi): remove this generator for nx v19
|
|
2
4
|
* This function is a destructive command that replace React Native iOS and Android code with latest.
|
|
3
5
|
* It would replace the Android and iOS folder entirely.
|
|
4
6
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
+
* @deprecated use `nx run @nx/react-native:upgrade` instead.
|
|
4
|
+
* TODO (@xiongemi): remove this generator for nx v19
|
|
3
5
|
* This function is a destructive command that replace React Native iOS and Android code with latest.
|
|
4
6
|
* It would replace the Android and iOS folder entirely.
|
|
5
7
|
*/
|
|
@@ -11,6 +13,7 @@ const pod_install_task_1 = require("../../utils/pod-install-task");
|
|
|
11
13
|
const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
|
|
12
14
|
const create_native_files_1 = require("./lib/create-native-files");
|
|
13
15
|
async function reactNativeUpgradeNativeGenerator(host, schema) {
|
|
16
|
+
devkit_1.logger.warn(`Please run 'nx run @nx/react-native:upgrade ${schema.name}' instead.`);
|
|
14
17
|
const { projectType, root: appProjectRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.name);
|
|
15
18
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(host.root, appProjectRoot, 'ios');
|
|
16
19
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(host.root, appProjectRoot, 'android');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
|
|
4
|
+
if (
|
|
5
|
+
process.env.NX_TASK_TARGET_TARGET === 'build' ||
|
|
6
|
+
process.env.NX_TASK_TARGET_TARGET.includes('storybook')
|
|
7
|
+
) {
|
|
8
|
+
return {
|
|
9
|
+
presets: [
|
|
10
|
+
[
|
|
11
|
+
'@nx/react/babel',
|
|
12
|
+
{
|
|
13
|
+
runtime: 'automatic',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" style="height: 100%">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title><%= className %></title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
10
|
+
</head>
|
|
11
|
+
<body style="height:100%">
|
|
12
|
+
<div id="root" style="display: flex; height: 100%"></div>
|
|
13
|
+
<script type="module" src="/src/main-web.tsx"></script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
4
|
+
import * as esbuild from 'esbuild';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
|
|
7
|
+
const extensions = [
|
|
8
|
+
'.mjs',
|
|
9
|
+
'.web.tsx',
|
|
10
|
+
'.tsx',
|
|
11
|
+
'.web.ts',
|
|
12
|
+
'.ts',
|
|
13
|
+
'.web.jsx',
|
|
14
|
+
'.jsx',
|
|
15
|
+
'.web.js',
|
|
16
|
+
'.js',
|
|
17
|
+
'.css',
|
|
18
|
+
'.json',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const rollupPlugin = (matchers: RegExp[]) => ({
|
|
22
|
+
name: 'js-in-jsx',
|
|
23
|
+
load(id: string) {
|
|
24
|
+
if (matchers.some((matcher) => matcher.test(id)) && id.endsWith('.js')) {
|
|
25
|
+
const file = readFileSync(id, { encoding: 'utf-8' });
|
|
26
|
+
return esbuild.transformSync(file, { loader: 'jsx', jsx: 'automatic' });
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
root: __dirname,
|
|
33
|
+
cacheDir: '../../node_modules/.vite/<%= fileName %>',
|
|
34
|
+
define: {
|
|
35
|
+
global: 'window',
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
resolve: {
|
|
39
|
+
extensions,
|
|
40
|
+
alias: {
|
|
41
|
+
'react-native': 'react-native-web',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
build: {
|
|
46
|
+
reportCompressedSize: true,
|
|
47
|
+
commonjsOptions: { transformMixedEsModules: true },
|
|
48
|
+
outDir: '../../dist/apps/<%= fileName %>/web',
|
|
49
|
+
rollupOptions: {
|
|
50
|
+
plugins: [rollupPlugin([/react-native-vector-icons/])],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
server: {
|
|
55
|
+
port: 4200,
|
|
56
|
+
host: 'localhost',
|
|
57
|
+
fs: {
|
|
58
|
+
// Allow serving files from one level up to the project root
|
|
59
|
+
allow: ['..'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
preview: {
|
|
64
|
+
port: 4300,
|
|
65
|
+
host: 'localhost',
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
optimizeDeps: {
|
|
69
|
+
esbuildOptions: {
|
|
70
|
+
resolveExtensions: extensions,
|
|
71
|
+
jsx: 'automatic',
|
|
72
|
+
loader: { '.js': 'jsx' },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
plugins: [react(), nxViteTsPaths()],
|
|
77
|
+
|
|
78
|
+
// Uncomment this if you are using workers.
|
|
79
|
+
// worker: {
|
|
80
|
+
// plugins: [ nxViteTsPaths() ],
|
|
81
|
+
// },
|
|
82
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
|
|
4
|
+
if (
|
|
5
|
+
process.env.NX_TASK_TARGET_TARGET === 'build' ||
|
|
6
|
+
process.env.NX_TASK_TARGET_TARGET.includes('storybook')
|
|
7
|
+
) {
|
|
8
|
+
return {
|
|
9
|
+
presets: [
|
|
10
|
+
[
|
|
11
|
+
'@nx/react/babel',
|
|
12
|
+
{
|
|
13
|
+
runtime: 'automatic',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
22
|
+
};
|
|
23
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" style="height: 100%">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title><%= className %></title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
|
10
|
+
</head>
|
|
11
|
+
<body style="height:100%">
|
|
12
|
+
<div id="root" style="display: flex; height: 100%"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<% if (webpackPluginOptions) { %>
|
|
2
|
+
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
3
|
+
const { NxReactWebpackPlugin } = require('@nx/react');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
resolve: {
|
|
7
|
+
alias: {
|
|
8
|
+
'react-native$': 'react-native-web',
|
|
9
|
+
},
|
|
10
|
+
extensions: ['.web.tsx', '.web.ts', '.web.jsx', '.web.js']
|
|
11
|
+
},
|
|
12
|
+
devServer: {
|
|
13
|
+
port: 4200
|
|
14
|
+
},
|
|
15
|
+
plugins: [
|
|
16
|
+
new NxWebpackPlugin({
|
|
17
|
+
tsConfig: '<%= webpackPluginOptions.tsConfig %>',
|
|
18
|
+
compiler: '<%= webpackPluginOptions.compiler %>',
|
|
19
|
+
main: '<%= webpackPluginOptions.main %>',
|
|
20
|
+
index: '<%= webpackPluginOptions.index %>',
|
|
21
|
+
outputPath: '<%= webpackPluginOptions.outputPath %>',
|
|
22
|
+
baseHref: '<%= webpackPluginOptions.baseHref %>',
|
|
23
|
+
assets: <%- JSON.stringify(webpackPluginOptions.assets) %>,
|
|
24
|
+
styles: <%- JSON.stringify(webpackPluginOptions.styles) %>,
|
|
25
|
+
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
26
|
+
optimization: process.env['NODE_ENV'] === 'production',
|
|
27
|
+
}),
|
|
28
|
+
new NxReactWebpackPlugin({
|
|
29
|
+
// Uncomment this line if you don't want to use SVGR
|
|
30
|
+
// See: https://react-svgr.com/
|
|
31
|
+
// svgr: false
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
<% } else { %>
|
|
36
|
+
const { composePlugins, withNx } = require('@nx/webpack');
|
|
37
|
+
const { withReact } = require('@nx/react');
|
|
38
|
+
|
|
39
|
+
// Nx plugins for webpack.
|
|
40
|
+
module.exports = composePlugins(
|
|
41
|
+
withNx(),
|
|
42
|
+
withReact({
|
|
43
|
+
// Uncomment this line if you don't want to use SVGR
|
|
44
|
+
// See: https://react-svgr.com/
|
|
45
|
+
// svgr: false
|
|
46
|
+
}),
|
|
47
|
+
(config) => {
|
|
48
|
+
// Update the webpack config as needed here.
|
|
49
|
+
// e.g. `config.plugins.push(new MyPlugin())`
|
|
50
|
+
|
|
51
|
+
config.resolve.alias = {
|
|
52
|
+
...config.resolve.alias ?? {},
|
|
53
|
+
'react-native$': 'react-native-web',
|
|
54
|
+
};
|
|
55
|
+
config.resolve.extensions = [
|
|
56
|
+
'.web.tsx',
|
|
57
|
+
'.web.ts',
|
|
58
|
+
'.web.jsx',
|
|
59
|
+
'.web.js',
|
|
60
|
+
...config.resolve.extensions,
|
|
61
|
+
];
|
|
62
|
+
config.module.rules.push({
|
|
63
|
+
test: /\.(js|jsx)$/,
|
|
64
|
+
include: /react-native-vector-icons/,
|
|
65
|
+
loader: 'babel-loader',
|
|
66
|
+
options: {
|
|
67
|
+
presets: [
|
|
68
|
+
'@babel/preset-env',
|
|
69
|
+
['@babel/preset-react', { runtime: 'automatic' }],
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return config;
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
<% } %>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { WebConfigurationGeneratorSchema } from '../schema';
|
|
3
|
+
export interface NormalizedSchema extends WebConfigurationGeneratorSchema {
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
className: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function normalizeSchema(tree: Tree, schema: WebConfigurationGeneratorSchema): {
|
|
9
|
+
projectRoot: string;
|
|
10
|
+
offsetFromRoot: string;
|
|
11
|
+
fileName: string;
|
|
12
|
+
className: string;
|
|
13
|
+
project: string;
|
|
14
|
+
bundler: "vite" | "webpack";
|
|
15
|
+
skipFormat?: boolean;
|
|
16
|
+
skipPackageJson?: boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeSchema = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function normalizeSchema(tree, schema) {
|
|
6
|
+
const project = (0, devkit_1.getProjects)(tree).get(schema.project);
|
|
7
|
+
const { fileName, className } = (0, devkit_1.names)(schema.project);
|
|
8
|
+
return {
|
|
9
|
+
...schema,
|
|
10
|
+
projectRoot: project.root,
|
|
11
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(project.root),
|
|
12
|
+
fileName,
|
|
13
|
+
className,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.normalizeSchema = normalizeSchema;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TargetConfiguration } from '@nx/devkit';
|
|
2
|
+
import type { WithReactOptions } from '@nx/react';
|
|
3
|
+
import type { WithNxOptions } from '@nx/webpack';
|
|
4
|
+
import { NormalizedSchema } from './normalize-schema';
|
|
5
|
+
export declare function createBuildTarget(options: NormalizedSchema): TargetConfiguration;
|
|
6
|
+
export declare function createServeTarget(options: NormalizedSchema): TargetConfiguration;
|
|
7
|
+
export declare function createNxWebpackPluginOptions(options: NormalizedSchema): WithNxOptions & WithReactOptions;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNxWebpackPluginOptions = exports.createServeTarget = exports.createBuildTarget = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function createBuildTarget(options) {
|
|
6
|
+
return {
|
|
7
|
+
executor: '@nx/webpack:webpack',
|
|
8
|
+
outputs: ['{options.outputPath}'],
|
|
9
|
+
defaultConfiguration: 'production',
|
|
10
|
+
options: {
|
|
11
|
+
compiler: 'babel',
|
|
12
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot != '.' ? options.projectRoot : options.project, 'web'),
|
|
13
|
+
index: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/index.html'),
|
|
14
|
+
baseHref: '/',
|
|
15
|
+
main: (0, devkit_1.joinPathFragments)(options.projectRoot, `src/main-web.tsx`),
|
|
16
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
|
|
17
|
+
assets: [
|
|
18
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, 'src/favicon.ico'),
|
|
19
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, 'src/assets'),
|
|
20
|
+
],
|
|
21
|
+
webpackConfig: (0, devkit_1.joinPathFragments)(options.projectRoot, 'webpack.config.js'),
|
|
22
|
+
},
|
|
23
|
+
configurations: {
|
|
24
|
+
development: {
|
|
25
|
+
extractLicenses: false,
|
|
26
|
+
optimization: false,
|
|
27
|
+
sourceMap: true,
|
|
28
|
+
vendorChunk: true,
|
|
29
|
+
},
|
|
30
|
+
production: {
|
|
31
|
+
optimization: true,
|
|
32
|
+
outputHashing: 'all',
|
|
33
|
+
sourceMap: false,
|
|
34
|
+
namedChunks: false,
|
|
35
|
+
extractLicenses: true,
|
|
36
|
+
vendorChunk: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.createBuildTarget = createBuildTarget;
|
|
42
|
+
function createServeTarget(options) {
|
|
43
|
+
return {
|
|
44
|
+
executor: '@nx/webpack:dev-server',
|
|
45
|
+
defaultConfiguration: 'development',
|
|
46
|
+
options: {
|
|
47
|
+
buildTarget: `${options.project}:build`,
|
|
48
|
+
hmr: true,
|
|
49
|
+
},
|
|
50
|
+
configurations: {
|
|
51
|
+
development: {
|
|
52
|
+
buildTarget: `${options.project}:build:development`,
|
|
53
|
+
},
|
|
54
|
+
production: {
|
|
55
|
+
buildTarget: `${options.project}:build:production`,
|
|
56
|
+
hmr: false,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.createServeTarget = createServeTarget;
|
|
62
|
+
function createNxWebpackPluginOptions(options) {
|
|
63
|
+
return {
|
|
64
|
+
target: 'web',
|
|
65
|
+
compiler: 'babel',
|
|
66
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot != '.' ? options.projectRoot : options.project),
|
|
67
|
+
index: './src/index.html',
|
|
68
|
+
baseHref: '/',
|
|
69
|
+
main: `./src/main-web.tsx`,
|
|
70
|
+
tsConfig: './tsconfig.app.json',
|
|
71
|
+
assets: ['./src/favicon.ico', './src/assets'],
|
|
72
|
+
styles: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.createNxWebpackPluginOptions = createNxWebpackPluginOptions;
|