@nx/react-native 24.0.0-canary.20261016-5ef7804 → 24.0.0-canary.20261020-e7ffd79
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/dist/plugins/metro-reporter.d.ts +1 -0
- package/dist/plugins/metro-reporter.js +50 -0
- package/dist/plugins/plugin.js +20 -5
- package/dist/src/generators/application/application.js +2 -3
- package/dist/src/generators/application/lib/add-project.js +1 -83
- package/dist/src/generators/application/lib/normalize-options.js +0 -4
- package/dist/src/generators/application/schema.d.ts +0 -1
- package/dist/src/generators/convert-to-inferred/lib/create-process-options.d.ts +2 -2
- package/dist/src/generators/convert-to-inferred/lib/create-process-options.js +2 -2
- package/dist/src/generators/init/init.js +44 -53
- package/dist/src/generators/init/schema.d.ts +0 -1
- package/dist/src/generators/library/lib/normalize-options.js +0 -5
- package/dist/src/generators/library/library.js +2 -3
- package/dist/src/generators/library/schema.d.ts +0 -1
- package/dist/src/generators/web-configuration/files/base-vite/vite.config.mts__tmpl__ +6 -5
- package/dist/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +1 -42
- package/dist/src/generators/web-configuration/lib/webpack-targets.d.ts +1 -3
- package/dist/src/generators/web-configuration/lib/webpack-targets.js +0 -57
- package/dist/src/generators/web-configuration/web-configuration.js +9 -18
- package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +12 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +30 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +68 -0
- package/dist/src/utils/add-jest.d.ts +1 -1
- package/dist/src/utils/add-jest.js +1 -2
- package/dist/src/utils/add-linting.d.ts +0 -1
- package/dist/src/utils/add-linting.js +0 -1
- package/dist/src/utils/chmod-android-gradle-files.d.ts +0 -1
- package/dist/src/utils/chmod-android-gradle-files.js +0 -1
- package/dist/src/utils/pod-install-task.d.ts +0 -6
- package/dist/src/utils/pod-install-task.js +0 -1
- package/dist/src/utils/versions.d.ts +1 -0
- package/dist/src/utils/versions.js +2 -1
- package/executors.json +0 -40
- package/migrations.json +7 -0
- package/package.json +9 -9
- package/dist/src/executors/build-android/build-android.impl.d.ts +0 -6
- package/dist/src/executors/build-android/build-android.impl.js +0 -53
- package/dist/src/executors/build-android/schema.d.ts +0 -13
- package/dist/src/executors/build-android/schema.json +0 -82
- package/dist/src/executors/build-ios/build-ios.impl.d.ts +0 -6
- package/dist/src/executors/build-ios/build-ios.impl.js +0 -60
- package/dist/src/executors/build-ios/schema.d.ts +0 -17
- package/dist/src/executors/build-ios/schema.json +0 -92
- package/dist/src/executors/bundle/bundle.impl.d.ts +0 -6
- package/dist/src/executors/bundle/bundle.impl.js +0 -61
- package/dist/src/executors/bundle/schema.d.ts +0 -16
- package/dist/src/executors/bundle/schema.json +0 -93
- package/dist/src/executors/pod-install/pod-install.impl.d.ts +0 -6
- package/dist/src/executors/pod-install/pod-install.impl.js +0 -13
- package/dist/src/executors/pod-install/schema.d.ts +0 -6
- package/dist/src/executors/pod-install/schema.json +0 -34
- package/dist/src/executors/run-android/run-android.impl.d.ts +0 -6
- package/dist/src/executors/run-android/run-android.impl.js +0 -71
- package/dist/src/executors/run-android/schema.d.ts +0 -12
- package/dist/src/executors/run-android/schema.json +0 -102
- package/dist/src/executors/run-ios/run-ios.impl.d.ts +0 -6
- package/dist/src/executors/run-ios/run-ios.impl.js +0 -70
- package/dist/src/executors/run-ios/schema.d.ts +0 -7
- package/dist/src/executors/run-ios/schema.json +0 -98
- package/dist/src/executors/start/lib/is-packager-running.d.ts +0 -1
- package/dist/src/executors/start/lib/is-packager-running.js +0 -13
- package/dist/src/executors/start/schema.d.ts +0 -7
- package/dist/src/executors/start/schema.json +0 -30
- package/dist/src/executors/start/start.impl.d.ts +0 -9
- package/dist/src/executors/start/start.impl.js +0 -91
- package/dist/src/executors/upgrade/schema.d.ts +0 -1
- package/dist/src/executors/upgrade/schema.json +0 -12
- package/dist/src/executors/upgrade/upgrade.impl.d.ts +0 -12
- package/dist/src/executors/upgrade/upgrade.impl.js +0 -51
- package/dist/src/utils/deprecation.d.ts +0 -2
- package/dist/src/utils/deprecation.js +0 -19
- package/dist/src/utils/get-cli-options.d.ts +0 -8
- package/dist/src/utils/get-cli-options.js +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const diagnostics_channel_1 = require("diagnostics_channel");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const tls_1 = require("tls");
|
|
6
|
+
const { TerminalReporter } = require(resolveMetro(process.cwd()));
|
|
7
|
+
/**
|
|
8
|
+
* Metro's terminal reporter, which also reports the dev server's address to an
|
|
9
|
+
* Nx task whose readyWhen is `signal`. `react-native start` loads it through
|
|
10
|
+
* `--custom-log-reporter-path`.
|
|
11
|
+
*/
|
|
12
|
+
class NxMetroReporter extends TerminalReporter {
|
|
13
|
+
constructor(terminal) {
|
|
14
|
+
super(terminal);
|
|
15
|
+
this.secureByPort = new Map();
|
|
16
|
+
if (process.env.NX_READY_SIGNAL_SOCKET) {
|
|
17
|
+
// server_listening has no protocol, and Metro also serves HTTPS for a
|
|
18
|
+
// `server.tls` config. This channel publishes before that event fires.
|
|
19
|
+
(0, diagnostics_channel_1.subscribe)('tracing:net.server.listen:asyncEnd', (message) => {
|
|
20
|
+
const { server } = message;
|
|
21
|
+
const address = server.address();
|
|
22
|
+
if (address && typeof address === 'object') {
|
|
23
|
+
this.secureByPort.set(address.port, server instanceof tls_1.Server);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
update(event) {
|
|
29
|
+
super.update(event);
|
|
30
|
+
if (event.type !== 'server_listening' ||
|
|
31
|
+
!process.env.NX_READY_SIGNAL_SOCKET) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const { emitReadySignal } = require('@nx/devkit');
|
|
35
|
+
const { getListeningUrl } = require('@nx/devkit/internal');
|
|
36
|
+
const listening = event;
|
|
37
|
+
emitReadySignal(getListeningUrl(listening, this.secureByPort.get(listening.port) ??
|
|
38
|
+
process.argv.includes('--https')));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// The metro react-native start uses. This package does not depend on metro,
|
|
42
|
+
// so a plain require can fail or find another hoisted version.
|
|
43
|
+
function resolveMetro(projectRoot) {
|
|
44
|
+
const reactNative = (0, path_1.dirname)(require.resolve('react-native/package.json', { paths: [projectRoot] }));
|
|
45
|
+
const cliPlugin = (0, path_1.dirname)(require.resolve('@react-native/community-cli-plugin/package.json', {
|
|
46
|
+
paths: [reactNative],
|
|
47
|
+
}));
|
|
48
|
+
return require.resolve('metro', { paths: [cliPlugin] });
|
|
49
|
+
}
|
|
50
|
+
module.exports = NxMetroReporter;
|
package/dist/plugins/plugin.js
CHANGED
|
@@ -59,11 +59,7 @@ async function createNodesInternal(configFile, options, context, targetsCache, h
|
|
|
59
59
|
function buildReactNativeTargets(projectRoot, options, context) {
|
|
60
60
|
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
61
61
|
const targets = {
|
|
62
|
-
[options.startTargetName]:
|
|
63
|
-
command: `react-native start`,
|
|
64
|
-
continuous: true,
|
|
65
|
-
options: { cwd: projectRoot },
|
|
66
|
-
},
|
|
62
|
+
[options.startTargetName]: getStartTarget(projectRoot, context),
|
|
67
63
|
[options.podInstallTargetName]: {
|
|
68
64
|
command: `pod install`,
|
|
69
65
|
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot, 'ios') },
|
|
@@ -112,6 +108,25 @@ function buildReactNativeTargets(projectRoot, options, context) {
|
|
|
112
108
|
};
|
|
113
109
|
return targets;
|
|
114
110
|
}
|
|
111
|
+
const METRO_REPORTER_PATH = 'node_modules/@nx/react-native/dist/plugins/metro-reporter.js';
|
|
112
|
+
function getStartTarget(projectRoot, context) {
|
|
113
|
+
const target = {
|
|
114
|
+
command: `react-native start`,
|
|
115
|
+
continuous: true,
|
|
116
|
+
options: { cwd: projectRoot },
|
|
117
|
+
};
|
|
118
|
+
// react-native start fails on a missing reporter, as when the plugin is
|
|
119
|
+
// installed outside the root node_modules (e.g. .nx/installation)
|
|
120
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(context.workspaceRoot, METRO_REPORTER_PATH))) {
|
|
121
|
+
return target;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
...target,
|
|
125
|
+
// Relative to the task's cwd, so the graph holds no machine-specific path
|
|
126
|
+
command: `react-native start --custom-log-reporter-path ${(0, devkit_1.offsetFromRoot)(projectRoot)}${METRO_REPORTER_PATH}`,
|
|
127
|
+
readyWhen: { signal: true },
|
|
128
|
+
};
|
|
129
|
+
}
|
|
115
130
|
function getAppConfig(configFilePath, context) {
|
|
116
131
|
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
117
132
|
return (0, internal_1.loadConfigFile)(resolvedPath);
|
|
@@ -22,7 +22,6 @@ const sync_deps_impl_1 = require("../../executors/sync-deps/sync-deps.impl");
|
|
|
22
22
|
const internal_2 = require("@nx/js/internal");
|
|
23
23
|
async function reactNativeApplicationGenerator(host, schema) {
|
|
24
24
|
return await reactNativeApplicationGeneratorInternal(host, {
|
|
25
|
-
addPlugin: false,
|
|
26
25
|
useProjectJson: true,
|
|
27
26
|
...schema,
|
|
28
27
|
});
|
|
@@ -30,7 +29,7 @@ async function reactNativeApplicationGenerator(host, schema) {
|
|
|
30
29
|
async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
31
30
|
(0, versions_1.assertSupportedReactNativeVersion)(host);
|
|
32
31
|
const tasks = [];
|
|
33
|
-
const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(host, schema.
|
|
32
|
+
const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(host, schema.useTsSolution);
|
|
34
33
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
35
34
|
...schema,
|
|
36
35
|
skipFormat: true,
|
|
@@ -59,7 +58,7 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
59
58
|
],
|
|
60
59
|
});
|
|
61
60
|
tasks.push(lintTask);
|
|
62
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson,
|
|
61
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, 'tsconfig.app.json');
|
|
63
62
|
tasks.push(jestTask);
|
|
64
63
|
const webTask = await (0, web_configuration_1.webConfigurationGenerator)(host, {
|
|
65
64
|
...options,
|
|
@@ -2,20 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addProject = addProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const deprecation_1 = require("../../../utils/deprecation");
|
|
6
5
|
function addProject(host, options) {
|
|
7
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
8
|
-
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
9
|
-
? p === '@nx/react-native/plugin'
|
|
10
|
-
: p.plugin === '@nx/react-native/plugin');
|
|
11
|
-
if (!hasPlugin) {
|
|
12
|
-
(0, deprecation_1.warnReactNativeExecutorGenerating)();
|
|
13
|
-
}
|
|
14
6
|
const project = {
|
|
15
7
|
root: options.appProjectRoot,
|
|
16
8
|
sourceRoot: `${options.appProjectRoot}/src`,
|
|
17
9
|
projectType: 'application',
|
|
18
|
-
targets:
|
|
10
|
+
targets: {},
|
|
19
11
|
tags: options.parsedTags,
|
|
20
12
|
};
|
|
21
13
|
const templatedPackageJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'));
|
|
@@ -29,10 +21,6 @@ function addProject(host, options) {
|
|
|
29
21
|
if (options.projectName !== options.importPath) {
|
|
30
22
|
packageJson.nx = { name: options.projectName };
|
|
31
23
|
}
|
|
32
|
-
if (!hasPlugin) {
|
|
33
|
-
packageJson.nx ??= {};
|
|
34
|
-
packageJson.nx.targets = getTargets(options);
|
|
35
|
-
}
|
|
36
24
|
if (options.parsedTags?.length) {
|
|
37
25
|
packageJson.nx ??= {};
|
|
38
26
|
packageJson.nx.tags = options.parsedTags;
|
|
@@ -47,73 +35,3 @@ function addProject(host, options) {
|
|
|
47
35
|
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
48
36
|
}
|
|
49
37
|
}
|
|
50
|
-
function getTargets(options) {
|
|
51
|
-
const architect = {};
|
|
52
|
-
architect.start = {
|
|
53
|
-
executor: '@nx/react-native:start',
|
|
54
|
-
dependsOn: [],
|
|
55
|
-
options: {
|
|
56
|
-
port: 8081,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
architect['run-ios'] = {
|
|
60
|
-
executor: '@nx/react-native:run-ios',
|
|
61
|
-
dependsOn: [],
|
|
62
|
-
options: {},
|
|
63
|
-
};
|
|
64
|
-
architect['bundle-ios'] = {
|
|
65
|
-
executor: '@nx/react-native:bundle',
|
|
66
|
-
dependsOn: [],
|
|
67
|
-
outputs: ['{options.bundleOutput}'],
|
|
68
|
-
options: {
|
|
69
|
-
entryFile: options.entryFile,
|
|
70
|
-
platform: 'ios',
|
|
71
|
-
bundleOutput: `dist/${options.appProjectRoot}/ios/main.jsbundle`,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
architect['run-android'] = {
|
|
75
|
-
executor: '@nx/react-native:run-android',
|
|
76
|
-
dependsOn: [],
|
|
77
|
-
options: {},
|
|
78
|
-
};
|
|
79
|
-
architect['build-android'] = {
|
|
80
|
-
executor: '@nx/react-native:build-android',
|
|
81
|
-
outputs: [
|
|
82
|
-
`{projectRoot}/android/app/build/outputs/bundle`,
|
|
83
|
-
`{projectRoot}/android/app/build/outputs/apk`,
|
|
84
|
-
],
|
|
85
|
-
dependsOn: [],
|
|
86
|
-
options: {},
|
|
87
|
-
};
|
|
88
|
-
architect['build-ios'] = {
|
|
89
|
-
executor: '@nx/react-native:build-ios',
|
|
90
|
-
outputs: ['{projectRoot}/ios/build/Build'],
|
|
91
|
-
dependsOn: [],
|
|
92
|
-
options: {},
|
|
93
|
-
};
|
|
94
|
-
architect['pod-install'] = {
|
|
95
|
-
executor: '@nx/react-native:pod-install',
|
|
96
|
-
dependsOn: ['sync-deps'],
|
|
97
|
-
outputs: ['{projectRoot}/ios/Pods', '{projectRoot}/ios/Podfile.lock'],
|
|
98
|
-
options: {},
|
|
99
|
-
};
|
|
100
|
-
architect.upgrade = {
|
|
101
|
-
executor: '@nx/react-native:upgrade',
|
|
102
|
-
options: {},
|
|
103
|
-
};
|
|
104
|
-
architect['bundle-android'] = {
|
|
105
|
-
executor: '@nx/react-native:bundle',
|
|
106
|
-
dependsOn: [],
|
|
107
|
-
outputs: ['{options.bundleOutput}'],
|
|
108
|
-
options: {
|
|
109
|
-
entryFile: options.entryFile,
|
|
110
|
-
platform: 'android',
|
|
111
|
-
bundleOutput: `dist/${options.appProjectRoot}/android/main.jsbundle`,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
architect['sync-deps'] = {
|
|
115
|
-
executor: '@nx/react-native:sync-deps',
|
|
116
|
-
options: {},
|
|
117
|
-
};
|
|
118
|
-
return architect;
|
|
119
|
-
}
|
|
@@ -11,10 +11,6 @@ async function normalizeOptions(host, options) {
|
|
|
11
11
|
projectType: 'application',
|
|
12
12
|
directory: options.directory,
|
|
13
13
|
});
|
|
14
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
15
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
16
|
-
nxJson.useInferencePlugins !== false;
|
|
17
|
-
options.addPlugin ??= addPluginDefault;
|
|
18
14
|
const { className, fileName } = (0, devkit_1.names)(projectNames.projectSimpleName);
|
|
19
15
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
|
|
20
16
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AggregatedLog } from '@nx/devkit/internal';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Maps options to CLI args the way the removed executors did, so converted
|
|
4
|
+
* targets run the same React Native CLI command.
|
|
5
5
|
*/
|
|
6
6
|
export declare function createProcessOptions(executorName: string, optionKeysToIgnore: string[], optionKeysInCamelName: string[]): (projectName: string, options: any, migrationLogs: AggregatedLog) => void;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createProcessOptions = createProcessOptions;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Maps options to CLI args the way the removed executors did, so converted
|
|
7
|
+
* targets run the same React Native CLI command.
|
|
8
8
|
*/
|
|
9
9
|
function createProcessOptions(executorName, optionKeysToIgnore, optionKeysInCamelName) {
|
|
10
10
|
return (projectName, options, migrationLogs) => {
|
|
@@ -9,63 +9,54 @@ const plugin_1 = require("../../../plugins/plugin");
|
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
11
11
|
function reactNativeInitGenerator(host, schema) {
|
|
12
|
-
return reactNativeInitGeneratorInternal(host,
|
|
13
|
-
addPlugin: false,
|
|
14
|
-
...schema,
|
|
15
|
-
});
|
|
12
|
+
return reactNativeInitGeneratorInternal(host, schema);
|
|
16
13
|
}
|
|
17
14
|
async function reactNativeInitGeneratorInternal(host, schema) {
|
|
18
15
|
(0, versions_1.assertSupportedReactNativeVersion)(host);
|
|
19
16
|
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'sync-deps',
|
|
64
|
-
'react-native:sync-deps',
|
|
65
|
-
'react-native-sync-deps',
|
|
66
|
-
],
|
|
67
|
-
}, schema.updatePackageScripts);
|
|
68
|
-
}
|
|
17
|
+
await (0, internal_1.addPlugin)(host, await (0, devkit_1.createProjectGraphAsync)(), '@nx/react-native/plugin', plugin_1.createNodesV2, {
|
|
18
|
+
startTargetName: ['start', 'react-native:start', 'react-native-start'],
|
|
19
|
+
upgradeTargetName: [
|
|
20
|
+
'update',
|
|
21
|
+
'react-native:update',
|
|
22
|
+
'react-native-update',
|
|
23
|
+
],
|
|
24
|
+
bundleTargetName: [
|
|
25
|
+
'bundle',
|
|
26
|
+
'react-native:bundle',
|
|
27
|
+
'react-native-bundle',
|
|
28
|
+
],
|
|
29
|
+
podInstallTargetName: [
|
|
30
|
+
'pod-install',
|
|
31
|
+
'react-native:pod-install',
|
|
32
|
+
'react-native-pod-install',
|
|
33
|
+
],
|
|
34
|
+
runIosTargetName: [
|
|
35
|
+
'run-ios',
|
|
36
|
+
'react-native:run-ios',
|
|
37
|
+
'react-native-run-ios',
|
|
38
|
+
],
|
|
39
|
+
runAndroidTargetName: [
|
|
40
|
+
'run-android',
|
|
41
|
+
'react-native:run-android',
|
|
42
|
+
'react-native-run-android',
|
|
43
|
+
],
|
|
44
|
+
buildIosTargetName: [
|
|
45
|
+
'build-ios',
|
|
46
|
+
'react-native:build-ios',
|
|
47
|
+
'react-native-build-ios',
|
|
48
|
+
],
|
|
49
|
+
buildAndroidTargetName: [
|
|
50
|
+
'build-android',
|
|
51
|
+
'react-native:build-android',
|
|
52
|
+
'react-native-build-android',
|
|
53
|
+
],
|
|
54
|
+
syncDepsTargetName: [
|
|
55
|
+
'sync-deps',
|
|
56
|
+
'react-native:sync-deps',
|
|
57
|
+
'react-native-sync-deps',
|
|
58
|
+
],
|
|
59
|
+
}, schema.updatePackageScripts);
|
|
69
60
|
const tasks = [];
|
|
70
61
|
if (!schema.skipPackageJson) {
|
|
71
62
|
tasks.push(moveDependency(host));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
5
|
const internal_2 = require("@nx/js/internal");
|
|
7
6
|
async function normalizeOptions(host, options) {
|
|
@@ -12,10 +11,6 @@ async function normalizeOptions(host, options) {
|
|
|
12
11
|
directory: options.directory,
|
|
13
12
|
importPath: options.importPath,
|
|
14
13
|
});
|
|
15
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
-
nxJson.useInferencePlugins !== false;
|
|
18
|
-
options.addPlugin ??= addPluginDefault;
|
|
19
14
|
const parsedTags = options.tags
|
|
20
15
|
? options.tags.split(',').map((s) => s.trim())
|
|
21
16
|
: [];
|
|
@@ -18,7 +18,6 @@ const path_1 = require("path");
|
|
|
18
18
|
const versions_1 = require("../../utils/versions");
|
|
19
19
|
async function reactNativeLibraryGenerator(host, schema) {
|
|
20
20
|
return await reactNativeLibraryGeneratorInternal(host, {
|
|
21
|
-
addPlugin: false,
|
|
22
21
|
useProjectJson: true,
|
|
23
22
|
...schema,
|
|
24
23
|
});
|
|
@@ -26,7 +25,7 @@ async function reactNativeLibraryGenerator(host, schema) {
|
|
|
26
25
|
async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
27
26
|
(0, versions_1.assertSupportedReactNativeVersion)(host);
|
|
28
27
|
const tasks = [];
|
|
29
|
-
const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(host
|
|
28
|
+
const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(host);
|
|
30
29
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
31
30
|
...schema,
|
|
32
31
|
addTsPlugin,
|
|
@@ -58,7 +57,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
58
57
|
],
|
|
59
58
|
});
|
|
60
59
|
tasks.push(lintTask);
|
|
61
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson,
|
|
60
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, 'tsconfig.lib.json');
|
|
62
61
|
tasks.push(jestTask);
|
|
63
62
|
const relativeCwd = (0, internal_1.getRelativeCwd)();
|
|
64
63
|
const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.js ? `${options.fileName}.js` : options.fileName);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineConfig, transformWithEsbuild } from 'vite';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
|
-
|
|
4
|
-
import { readFileSync } from 'fs';
|
|
3
|
+
<% if (!useNativeTsconfigPaths) { %>import tsconfigPaths from 'vite-tsconfig-paths';
|
|
4
|
+
<% } %>import { readFileSync } from 'fs';
|
|
5
5
|
|
|
6
6
|
const extensions = [
|
|
7
7
|
'.mjs',
|
|
@@ -37,7 +37,8 @@ export default defineConfig({
|
|
|
37
37
|
global: 'window',
|
|
38
38
|
},
|
|
39
39
|
resolve: {
|
|
40
|
-
|
|
40
|
+
<% if (useNativeTsconfigPaths) { %> tsconfigPaths: true,
|
|
41
|
+
<% } %> extensions,
|
|
41
42
|
alias: {
|
|
42
43
|
'react-native': 'react-native-web',
|
|
43
44
|
'react-native-svg': 'react-native-svg-web',
|
|
@@ -72,9 +73,9 @@ export default defineConfig({
|
|
|
72
73
|
loader: { '.js': 'jsx' },
|
|
73
74
|
},
|
|
74
75
|
},
|
|
75
|
-
plugins: [react()
|
|
76
|
+
plugins: [react()<% if (!useNativeTsconfigPaths) { %>, tsconfigPaths({ loose: true })<% } %>],
|
|
76
77
|
// Uncomment this if you are using workers.
|
|
77
78
|
// worker: {
|
|
78
|
-
// plugins:
|
|
79
|
+
// plugins: [],
|
|
79
80
|
// },
|
|
80
81
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
3
3
|
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');
|
|
4
4
|
|
|
@@ -30,45 +30,4 @@ module.exports = {
|
|
|
30
30
|
new NxReactWebpackPlugin(),
|
|
31
31
|
],
|
|
32
32
|
};
|
|
33
|
-
<% } else { %>
|
|
34
|
-
const { composePlugins, withNx } = require('@nx/webpack');
|
|
35
|
-
const { withReact } = require('@nx/react');
|
|
36
|
-
|
|
37
|
-
// Nx plugins for webpack.
|
|
38
|
-
module.exports = composePlugins(
|
|
39
|
-
withNx(),
|
|
40
|
-
withReact(),
|
|
41
|
-
(config) => {
|
|
42
|
-
// Update the webpack config as needed here.
|
|
43
|
-
// e.g. `config.plugins.push(new MyPlugin())`
|
|
44
33
|
|
|
45
|
-
config.output.clean = true;
|
|
46
|
-
config.resolve.alias = {
|
|
47
|
-
...config.resolve.alias ?? {},
|
|
48
|
-
'react-native$': 'react-native-web',
|
|
49
|
-
'react-native-svg': 'react-native-svg-web',
|
|
50
|
-
'@react-native/assets-registry/registry': 'react-native-web/dist/modules/AssetRegistry/index',
|
|
51
|
-
};
|
|
52
|
-
config.resolve.extensions = [
|
|
53
|
-
'.web.tsx',
|
|
54
|
-
'.web.ts',
|
|
55
|
-
'.web.jsx',
|
|
56
|
-
'.web.js',
|
|
57
|
-
...config.resolve.extensions,
|
|
58
|
-
];
|
|
59
|
-
config.module.rules.push({
|
|
60
|
-
test: /\.(js|jsx)$/,
|
|
61
|
-
include: /react-native-vector-icons/,
|
|
62
|
-
loader: 'babel-loader',
|
|
63
|
-
options: {
|
|
64
|
-
presets: [
|
|
65
|
-
'@babel/preset-env',
|
|
66
|
-
['@babel/preset-react', { runtime: 'automatic' }],
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return config;
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
<% } %>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { WithReactOptions } from '@nx/react';
|
|
3
3
|
import type { WithNxOptions } from '@nx/webpack';
|
|
4
4
|
import { NormalizedSchema } from './normalize-schema';
|
|
5
|
-
export declare function createBuildTarget(tree: Tree, options: NormalizedSchema): TargetConfiguration;
|
|
6
|
-
export declare function createServeTarget(options: NormalizedSchema): TargetConfiguration;
|
|
7
5
|
export declare function createNxWebpackPluginOptions(tree: Tree, options: NormalizedSchema): WithNxOptions & WithReactOptions;
|
|
8
6
|
export declare function determineTsConfig(tree: Tree, options: NormalizedSchema): "tsconfig.app.json" | "tsconfig.json" | "tsconfig.lib.json";
|
|
@@ -1,65 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBuildTarget = createBuildTarget;
|
|
4
|
-
exports.createServeTarget = createServeTarget;
|
|
5
3
|
exports.createNxWebpackPluginOptions = createNxWebpackPluginOptions;
|
|
6
4
|
exports.determineTsConfig = determineTsConfig;
|
|
7
5
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
function createBuildTarget(tree, options) {
|
|
9
|
-
return {
|
|
10
|
-
executor: '@nx/webpack:webpack',
|
|
11
|
-
outputs: ['{options.outputPath}'],
|
|
12
|
-
defaultConfiguration: 'production',
|
|
13
|
-
options: {
|
|
14
|
-
compiler: 'babel',
|
|
15
|
-
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot != '.' ? options.projectRoot : options.project, 'web'),
|
|
16
|
-
index: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/index.html'),
|
|
17
|
-
baseHref: '/',
|
|
18
|
-
main: (0, devkit_1.joinPathFragments)(options.projectRoot, `src/main-web.tsx`),
|
|
19
|
-
tsConfig: (0, devkit_1.joinPathFragments)(options.projectRoot, determineTsConfig(tree, options)),
|
|
20
|
-
assets: [
|
|
21
|
-
(0, devkit_1.joinPathFragments)(options.projectRoot, 'src/favicon.ico'),
|
|
22
|
-
(0, devkit_1.joinPathFragments)(options.projectRoot, 'src/assets'),
|
|
23
|
-
],
|
|
24
|
-
webpackConfig: (0, devkit_1.joinPathFragments)(options.projectRoot, 'webpack.config.js'),
|
|
25
|
-
},
|
|
26
|
-
configurations: {
|
|
27
|
-
development: {
|
|
28
|
-
extractLicenses: false,
|
|
29
|
-
optimization: false,
|
|
30
|
-
sourceMap: true,
|
|
31
|
-
vendorChunk: true,
|
|
32
|
-
},
|
|
33
|
-
production: {
|
|
34
|
-
optimization: true,
|
|
35
|
-
outputHashing: 'all',
|
|
36
|
-
sourceMap: false,
|
|
37
|
-
namedChunks: false,
|
|
38
|
-
extractLicenses: true,
|
|
39
|
-
vendorChunk: false,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function createServeTarget(options) {
|
|
45
|
-
return {
|
|
46
|
-
executor: '@nx/webpack:dev-server',
|
|
47
|
-
defaultConfiguration: 'development',
|
|
48
|
-
options: {
|
|
49
|
-
buildTarget: `${options.project}:build`,
|
|
50
|
-
hmr: true,
|
|
51
|
-
},
|
|
52
|
-
configurations: {
|
|
53
|
-
development: {
|
|
54
|
-
buildTarget: `${options.project}:build:development`,
|
|
55
|
-
},
|
|
56
|
-
production: {
|
|
57
|
-
buildTarget: `${options.project}:build:production`,
|
|
58
|
-
hmr: false,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
6
|
function createNxWebpackPluginOptions(tree, options) {
|
|
64
7
|
return {
|
|
65
8
|
target: 'web',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webConfigurationGenerator = webConfigurationGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
6
|
const versions_1 = require("../../utils/versions");
|
|
7
7
|
const normalize_schema_1 = require("./lib/normalize-schema");
|
|
8
8
|
const webpack_targets_1 = require("./lib/webpack-targets");
|
|
@@ -31,15 +31,19 @@ async function webConfigurationGenerator(tree, options) {
|
|
|
31
31
|
tasks.push(...bundlerTasks);
|
|
32
32
|
// create files for webpack and vite config, index.html
|
|
33
33
|
if (normalizedSchema.bundler === 'vite') {
|
|
34
|
-
|
|
34
|
+
// resolve.tsconfigPaths is native only from Vite 8; older majors ignore it.
|
|
35
|
+
const installedVite = (0, semver_1.coerce)((0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'vite') ?? '');
|
|
36
|
+
const useNativeTsconfigPaths = !installedVite || (0, semver_1.major)(installedVite) >= 8;
|
|
37
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/base-vite'), normalizedSchema.projectRoot, { ...normalizedSchema, useNativeTsconfigPaths, tmpl: '' });
|
|
38
|
+
if (!useNativeTsconfigPaths && !options.skipPackageJson) {
|
|
39
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'vite-tsconfig-paths': versions_1.viteTsconfigPathsVersion }, undefined, true));
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
else {
|
|
37
43
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/base-webpack'), normalizedSchema.projectRoot, {
|
|
38
44
|
...normalizedSchema,
|
|
39
45
|
tmpl: '',
|
|
40
|
-
webpackPluginOptions: (0,
|
|
41
|
-
? (0, webpack_targets_1.createNxWebpackPluginOptions)(tree, normalizedSchema)
|
|
42
|
-
: null,
|
|
46
|
+
webpackPluginOptions: (0, webpack_targets_1.createNxWebpackPluginOptions)(tree, normalizedSchema),
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
49
|
if (!options.skipPackageJson) {
|
|
@@ -85,19 +89,6 @@ async function addBundlerConfiguration(tree, normalizedSchema) {
|
|
|
85
89
|
const { ensureDependencies, } = require('@nx/webpack/internal');
|
|
86
90
|
tasks.push(ensureDependencies(tree, { uiFramework: 'react' }));
|
|
87
91
|
}
|
|
88
|
-
if (!(0, internal_1.hasWebpackPlugin)(tree)) {
|
|
89
|
-
// Mirrors warnWebpackExecutorGenerating from @nx/webpack/src/utils/deprecation.
|
|
90
|
-
// Inlined to avoid a cross-package import where react-native does not
|
|
91
|
-
// declare a TypeScript project reference to webpack.
|
|
92
|
-
devkit_1.logger.warn('Generating targets that use the deprecated `@nx/webpack:webpack` and `@nx/webpack:dev-server` executors. These executors will be removed in Nx v24. Run `nx g @nx/webpack:convert-to-inferred` next to migrate these targets to the `@nx/webpack/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
93
|
-
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, normalizedSchema.project);
|
|
94
|
-
projectConfiguration.targets = {
|
|
95
|
-
...projectConfiguration.targets,
|
|
96
|
-
build: (0, webpack_targets_1.createBuildTarget)(tree, normalizedSchema),
|
|
97
|
-
serve: (0, webpack_targets_1.createServeTarget)(normalizedSchema),
|
|
98
|
-
};
|
|
99
|
-
(0, devkit_1.updateProjectConfiguration)(tree, normalizedSchema.project, projectConfiguration);
|
|
100
|
-
}
|
|
101
92
|
return tasks;
|
|
102
93
|
}
|
|
103
94
|
}
|