react-native-update-cli 1.10.0 → 1.11.0
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/cli.json +3 -1
- package/lib/bundle.js +12 -9
- package/package.json +1 -1
- package/src/bundle.js +26 -18
package/cli.json
CHANGED
package/lib/bundle.js
CHANGED
|
@@ -55,7 +55,6 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
|
|
|
55
55
|
|
|
56
56
|
fs.emptyDirSync(outputFolder);
|
|
57
57
|
|
|
58
|
-
// TODO sourcemap
|
|
59
58
|
Array.prototype.push.apply(reactNativeBundleArgs, [path.join('node_modules', 'react-native', 'local-cli', 'cli.js'), 'bundle', '--assets-dest', outputFolder, '--bundle-output', path.join(outputFolder, bundleName), '--dev', development, '--entry-file', entryFile, '--platform', platform, '--reset-cache']);
|
|
60
59
|
|
|
61
60
|
if (sourcemapOutput) {
|
|
@@ -83,7 +82,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
|
|
|
83
82
|
reject(new Error(`"react-native bundle" command exited with code ${exitCode}.`));
|
|
84
83
|
} else {
|
|
85
84
|
if (platform === 'android' && gradleConfig.enableHermes || platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine')) {
|
|
86
|
-
await compileHermesByteCode(bundleName, outputFolder);
|
|
85
|
+
await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput);
|
|
87
86
|
}
|
|
88
87
|
resolve(null);
|
|
89
88
|
}
|
|
@@ -117,7 +116,7 @@ async function checkGradleConfig() {
|
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
async function compileHermesByteCode(bundleName, outputFolder) {
|
|
119
|
+
async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput) {
|
|
121
120
|
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
|
122
121
|
// >= rn 0.69
|
|
123
122
|
let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
|
|
@@ -130,9 +129,13 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
|
|
130
129
|
hermesCommand = fs.existsSync(`${hermesPath}/hermesc`) ? `${hermesPath}/hermesc` // 0.5+
|
|
131
130
|
: `${hermesPath}/hermes`; // < 0.5
|
|
132
131
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
const args = ['-emit-binary', '-out', path.join(outputFolder, bundleName), path.join(outputFolder, bundleName), '-O'];
|
|
133
|
+
if (sourcemapOutput) {
|
|
134
|
+
args.push('-output-source-map');
|
|
135
|
+
}
|
|
136
|
+
spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
|
|
137
|
+
stdio: 'ignore'
|
|
138
|
+
});
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
async function pack(dir, output) {
|
|
@@ -462,11 +465,11 @@ const commands = exports.commands = {
|
|
|
462
465
|
bundle: async function ({ options }) {
|
|
463
466
|
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
464
467
|
|
|
465
|
-
let { bundleName, entryFile, intermediaDir, output, dev,
|
|
468
|
+
let { bundleName, entryFile, intermediaDir, output, dev, sourcemap } = (0, _utils.translateOptions)(_extends({}, options, {
|
|
466
469
|
platform
|
|
467
470
|
}));
|
|
468
471
|
|
|
469
|
-
|
|
472
|
+
const sourcemapOutput = path.join(intermediaDir, bundleName + '.map');
|
|
470
473
|
|
|
471
474
|
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
|
472
475
|
|
|
@@ -479,7 +482,7 @@ const commands = exports.commands = {
|
|
|
479
482
|
console.log('Bundling with react-native: ', version);
|
|
480
483
|
(0, _utils.printVersionCommand)();
|
|
481
484
|
|
|
482
|
-
await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform);
|
|
485
|
+
await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform, sourcemap ? sourcemapOutput : '');
|
|
483
486
|
|
|
484
487
|
await pack(path.resolve(intermediaDir), realOutput);
|
|
485
488
|
|
package/package.json
CHANGED
package/src/bundle.js
CHANGED
|
@@ -48,7 +48,6 @@ async function runReactNativeBundleCommand(
|
|
|
48
48
|
|
|
49
49
|
fs.emptyDirSync(outputFolder);
|
|
50
50
|
|
|
51
|
-
// TODO sourcemap
|
|
52
51
|
Array.prototype.push.apply(reactNativeBundleArgs, [
|
|
53
52
|
path.join('node_modules', 'react-native', 'local-cli', 'cli.js'),
|
|
54
53
|
'bundle',
|
|
@@ -99,7 +98,11 @@ async function runReactNativeBundleCommand(
|
|
|
99
98
|
(platform === 'android' && gradleConfig.enableHermes) ||
|
|
100
99
|
(platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine'))
|
|
101
100
|
) {
|
|
102
|
-
await compileHermesByteCode(
|
|
101
|
+
await compileHermesByteCode(
|
|
102
|
+
bundleName,
|
|
103
|
+
outputFolder,
|
|
104
|
+
sourcemapOutput,
|
|
105
|
+
);
|
|
103
106
|
}
|
|
104
107
|
resolve(null);
|
|
105
108
|
}
|
|
@@ -136,7 +139,11 @@ async function checkGradleConfig() {
|
|
|
136
139
|
};
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
async function compileHermesByteCode(
|
|
142
|
+
async function compileHermesByteCode(
|
|
143
|
+
bundleName,
|
|
144
|
+
outputFolder,
|
|
145
|
+
sourcemapOutput,
|
|
146
|
+
) {
|
|
140
147
|
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
|
141
148
|
// >= rn 0.69
|
|
142
149
|
let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
|
|
@@ -151,19 +158,19 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
|
|
151
158
|
? `${hermesPath}/hermesc` // 0.5+
|
|
152
159
|
: `${hermesPath}/hermes`; // < 0.5
|
|
153
160
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
path.join
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
);
|
|
161
|
+
const args = [
|
|
162
|
+
'-emit-binary',
|
|
163
|
+
'-out',
|
|
164
|
+
path.join(outputFolder, bundleName),
|
|
165
|
+
path.join(outputFolder, bundleName),
|
|
166
|
+
'-O',
|
|
167
|
+
];
|
|
168
|
+
if (sourcemapOutput) {
|
|
169
|
+
args.push('-output-source-map');
|
|
170
|
+
}
|
|
171
|
+
spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
|
|
172
|
+
stdio: 'ignore',
|
|
173
|
+
});
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
async function pack(dir, output) {
|
|
@@ -524,13 +531,13 @@ export const commands = {
|
|
|
524
531
|
options.platform || (await question('平台(ios/android):')),
|
|
525
532
|
);
|
|
526
533
|
|
|
527
|
-
let { bundleName, entryFile, intermediaDir, output, dev,
|
|
534
|
+
let { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
|
|
528
535
|
translateOptions({
|
|
529
536
|
...options,
|
|
530
537
|
platform,
|
|
531
538
|
});
|
|
532
539
|
|
|
533
|
-
|
|
540
|
+
const sourcemapOutput = path.join(intermediaDir, bundleName + '.map');
|
|
534
541
|
|
|
535
542
|
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
|
536
543
|
|
|
@@ -549,6 +556,7 @@ export const commands = {
|
|
|
549
556
|
entryFile,
|
|
550
557
|
intermediaDir,
|
|
551
558
|
platform,
|
|
559
|
+
sourcemap ? sourcemapOutput : '',
|
|
552
560
|
);
|
|
553
561
|
|
|
554
562
|
await pack(path.resolve(intermediaDir), realOutput);
|