@rnx-kit/cli 0.14.4 → 0.14.6

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +18 -19
  3. package/coverage/clover.xml +72 -71
  4. package/coverage/coverage-final.json +5 -5
  5. package/coverage/lcov-report/index.html +18 -18
  6. package/coverage/lcov-report/src/{bundler-plugin-defaults.ts.html → bundle/defaultPlugins.ts.html} +10 -10
  7. package/coverage/lcov-report/src/bundle/index.html +23 -8
  8. package/coverage/lcov-report/src/bundle/kit-config.ts.html +3 -3
  9. package/coverage/lcov-report/src/bundle/metro.ts.html +13 -22
  10. package/coverage/lcov-report/src/bundle/overrides.ts.html +51 -33
  11. package/coverage/lcov-report/src/copy-assets.ts.html +1 -1
  12. package/coverage/lcov-report/src/index.html +7 -22
  13. package/coverage/lcov-report/src/metro-config.ts.html +20 -35
  14. package/coverage/lcov-report/src/typescript/index.html +1 -1
  15. package/coverage/lcov-report/src/typescript/project-cache.ts.html +3 -3
  16. package/coverage/lcov.info +121 -119
  17. package/lib/bundle/cliOptions.d.ts +39 -0
  18. package/lib/bundle/cliOptions.d.ts.map +1 -0
  19. package/lib/bundle/cliOptions.js +75 -0
  20. package/lib/bundle/cliOptions.js.map +1 -0
  21. package/lib/{bundler-plugin-defaults.d.ts → bundle/defaultPlugins.d.ts} +1 -1
  22. package/lib/bundle/defaultPlugins.d.ts.map +1 -0
  23. package/lib/{bundler-plugin-defaults.js → bundle/defaultPlugins.js} +1 -1
  24. package/lib/bundle/defaultPlugins.js.map +1 -0
  25. package/lib/bundle/kit-config.d.ts +1 -1
  26. package/lib/bundle/kit-config.d.ts.map +1 -1
  27. package/lib/bundle/kit-config.js +3 -3
  28. package/lib/bundle/kit-config.js.map +1 -1
  29. package/lib/bundle/metro.d.ts +3 -1
  30. package/lib/bundle/metro.d.ts.map +1 -1
  31. package/lib/bundle/metro.js +29 -8
  32. package/lib/bundle/metro.js.map +1 -1
  33. package/lib/bundle/overrides.d.ts +5 -14
  34. package/lib/bundle/overrides.d.ts.map +1 -1
  35. package/lib/bundle/overrides.js +14 -13
  36. package/lib/bundle/overrides.js.map +1 -1
  37. package/lib/bundle/types.d.ts +18 -0
  38. package/lib/bundle/types.d.ts.map +1 -1
  39. package/lib/bundle.d.ts +45 -19
  40. package/lib/bundle.d.ts.map +1 -1
  41. package/lib/bundle.js +20 -3
  42. package/lib/bundle.js.map +1 -1
  43. package/lib/index.d.ts +4 -3
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +11 -6
  46. package/lib/index.js.map +1 -1
  47. package/lib/metro-config.d.ts +3 -8
  48. package/lib/metro-config.d.ts.map +1 -1
  49. package/lib/metro-config.js +2 -5
  50. package/lib/metro-config.js.map +1 -1
  51. package/lib/parsers.d.ts +1 -0
  52. package/lib/parsers.d.ts.map +1 -1
  53. package/lib/parsers.js +5 -1
  54. package/lib/parsers.js.map +1 -1
  55. package/lib/ram-bundle.d.ts +49 -0
  56. package/lib/ram-bundle.d.ts.map +1 -0
  57. package/lib/ram-bundle.js +47 -0
  58. package/lib/ram-bundle.js.map +1 -0
  59. package/lib/serve/kit-config.js +2 -2
  60. package/lib/serve/kit-config.js.map +1 -1
  61. package/lib/start.d.ts.map +1 -1
  62. package/lib/start.js +28 -5
  63. package/lib/start.js.map +1 -1
  64. package/lib/typescript/project-cache.js +28 -5
  65. package/lib/typescript/project-cache.js.map +1 -1
  66. package/package.json +3 -3
  67. package/react-native.config.js +5 -96
  68. package/src/bundle/cliOptions.ts +82 -0
  69. package/src/{bundler-plugin-defaults.ts → bundle/defaultPlugins.ts} +0 -0
  70. package/src/bundle/kit-config.ts +2 -2
  71. package/src/bundle/metro.ts +8 -11
  72. package/src/bundle/overrides.ts +31 -25
  73. package/src/bundle/types.ts +19 -0
  74. package/src/bundle.ts +29 -23
  75. package/src/index.ts +4 -3
  76. package/src/metro-config.ts +18 -23
  77. package/src/parsers.ts +4 -0
  78. package/src/ram-bundle.ts +78 -0
  79. package/src/serve/kit-config.ts +1 -1
  80. package/src/start.ts +5 -12
  81. package/src/typescript/project-cache.ts +2 -2
  82. package/test/bundle/overrides.test.ts +25 -14
  83. package/test/metro-config.test.ts +33 -45
  84. package/lib/bundler-plugin-defaults.d.ts.map +0 -1
  85. package/lib/bundler-plugin-defaults.js.map +0 -1
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -8,8 +31,8 @@ const tools_node_1 = require("@rnx-kit/tools-node");
8
31
  const platform_1 = require("@rnx-kit/tools-react-native/platform");
9
32
  const typescript_react_native_resolver_1 = require("@rnx-kit/typescript-react-native-resolver");
10
33
  const typescript_service_1 = require("@rnx-kit/typescript-service");
11
- const fs_1 = __importDefault(require("fs"));
12
- const path_1 = __importDefault(require("path"));
34
+ const fs = __importStar(require("fs"));
35
+ const path = __importStar(require("path"));
13
36
  const typescript_1 = __importDefault(require("typescript"));
14
37
  /**
15
38
  * Create an empty cache for holding TypeScript projects.
@@ -30,15 +53,15 @@ function createProjectCache(print) {
30
53
  }
31
54
  }
32
55
  // Search the file system for the root of source file's package.
33
- const root = (0, tools_node_1.findPackageDir)(path_1.default.dirname(sourceFile));
56
+ const root = (0, tools_node_1.findPackageDir)(path.dirname(sourceFile));
34
57
  if (!root) {
35
58
  throw new Error(`Cannot find project root for source file '${sourceFile}'`);
36
59
  }
37
60
  return root;
38
61
  }
39
62
  function readTSConfig(root) {
40
- const configFileName = path_1.default.join(root, "tsconfig.json");
41
- if (!fs_1.default.existsSync(configFileName)) {
63
+ const configFileName = path.join(root, "tsconfig.json");
64
+ if (!fs.existsSync(configFileName)) {
42
65
  // Allow for packages that aren't TypeScript.
43
66
  //
44
67
  // Example: Users who enable bundling with all the config defaults will
@@ -1 +1 @@
1
- {"version":3,"file":"project-cache.js","sourceRoot":"","sources":["../../src/typescript/project-cache.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAqD;AACrD,mEAG8C;AAC9C,gGAA+F;AAC/F,oEAIqC;AACrC,4CAAoB;AACpB,gDAAwB;AACxB,4DAA4B;AAwC5B;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,KAAiC;IAEjC,MAAM,gBAAgB,GAAG,oBAAE,CAAC,sBAAsB,EAAE,CAAC;IACrD,MAAM,gBAAgB,GAAG,IAAA,2CAAsB,EAAC,KAAK,CAAC,CAAC;IAEvD,wEAAwE;IACxE,MAAM,QAAQ,GAGV,EAAE,CAAC;IAEP,SAAS,eAAe,CAAC,UAAkB;QACzC,6EAA6E;QAC7E,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACxC,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC/B,OAAO,IAAI,CAAC;aACb;SACF;QAED,gEAAgE;Q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Ab,QAAQ,CAAC,IAAI,IAAM,EAAE,EAAC;QAEtB,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEjC,iEAAiE;QACjE,8DAA8D;QAC9D,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YAC7D,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;SAC5B;QAED,gEAAgE;QAChE,8DAA8D;QAC9D,iBAAiB;QACjB,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/C,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,aAAa,CAAC,QAAsB;QAC3C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACrD,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAC1C,IAAI,IAAI,EAAE;gBACR,IAAI,IAAI,CAAC,SAAS,EAAE;oBAClB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;iBAC1B;gBACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;aACrC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,aAAa;QACb,cAAc;KACf,CAAC;AACJ,CAAC;AArJD,gDAqJC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/cli",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
4
4
  "description": "Command-line interface for working with kit packages in your repo",
5
5
  "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/cli",
6
6
  "license": "MIT",
@@ -19,14 +19,14 @@
19
19
  "test": "rnx-kit-scripts test"
20
20
  },
21
21
  "dependencies": {
22
- "@rnx-kit/config": "^0.5.0",
22
+ "@rnx-kit/config": "^0.5.2",
23
23
  "@rnx-kit/console": "^1.0.11",
24
24
  "@rnx-kit/dep-check": "^1.12.23",
25
25
  "@rnx-kit/metro-plugin-cyclic-dependencies-detector": "^1.0.21",
26
26
  "@rnx-kit/metro-plugin-duplicates-checker": "^2.0.0",
27
27
  "@rnx-kit/metro-serializer": "^1.0.11",
28
28
  "@rnx-kit/metro-serializer-esbuild": "^0.1.0",
29
- "@rnx-kit/metro-service": "^3.0.0",
29
+ "@rnx-kit/metro-service": "^3.0.2",
30
30
  "@rnx-kit/third-party-notices": "^1.2.13",
31
31
  "@rnx-kit/tools-language": "^1.3.0",
32
32
  "@rnx-kit/tools-node": "^1.2.7",
@@ -1,12 +1,12 @@
1
- const { parsePlatform } = require("@rnx-kit/tools-react-native/platform");
2
1
  const path = require("path");
3
2
  const {
4
3
  parseBoolean,
5
- parseTransformProfile,
6
- rnxBundle,
4
+ parseInt,
5
+ rnxBundleCommand,
7
6
  rnxCopyAssetsCommand,
8
7
  rnxStart,
9
8
  rnxDepCheckCommand,
9
+ rnxRamBundleCommand,
10
10
  rnxTestCommand,
11
11
  rnxWriteThirdPartyNotices,
12
12
  rnxClean,
@@ -14,99 +14,8 @@ const {
14
14
 
15
15
  module.exports = {
16
16
  commands: [
17
- {
18
- name: "rnx-bundle",
19
- description:
20
- "Bundle your rnx-kit package for offline use. See https://aka.ms/rnx-kit.",
21
- func: rnxBundle,
22
- options: [
23
- {
24
- name: "--id [id]",
25
- description:
26
- "Target bundle definition. This is only needed when the rnx-kit configuration has multiple bundle definitions.",
27
- },
28
- {
29
- name: "--entry-file [path]",
30
- description:
31
- "Path to the root JavaScript or TypeScript file, either absolute or relative to the package.",
32
- },
33
- {
34
- name: "--platform [ios|android|windows|win32|macos]",
35
- description:
36
- "Target platform. When not given, all platforms in the rnx-kit configuration are bundled.",
37
- parse: parsePlatform,
38
- },
39
- {
40
- name: "--dev [boolean]",
41
- description:
42
- "If false, warnings are disabled and the bundle is minified.",
43
- default: true,
44
- parse: parseBoolean,
45
- },
46
- {
47
- name: "--minify [boolean]",
48
- description:
49
- "Controls whether or not the bundle is minified. Disabling minification is useful for test builds.",
50
- parse: parseBoolean,
51
- },
52
- {
53
- name: "--bundle-output [string]",
54
- description:
55
- "Path to the output bundle file, either absolute or relative to the package.",
56
- },
57
- {
58
- name: "--bundle-encoding [utf8|utf16le|ascii]",
59
- description:
60
- "Character encoding to use when writing the bundle file.",
61
- default: "utf8",
62
- },
63
- {
64
- name: "--max-workers [number]",
65
- description:
66
- "Specifies the maximum number of parallel worker threads to use for transforming files. This defaults to the number of cores available on your machine.",
67
- parse: parseInt,
68
- },
69
- {
70
- name: "--sourcemap-output [string]",
71
- description:
72
- "Path where the bundle source map is written, either absolute or relative to the package.",
73
- },
74
- {
75
- name: "--sourcemap-sources-root [string]",
76
- description:
77
- "Path to use when relativizing file entries in the bundle source map.",
78
- },
79
- {
80
- name: "--sourcemap-use-absolute-path",
81
- description: "Report SourceMapURL using its full path",
82
- },
83
- {
84
- name: "--assets-dest [path]",
85
- description:
86
- "Path where bundle assets like images are written, either absolute or relative to the package. If not given, assets are ignored.",
87
- },
88
- {
89
- name: "--tree-shake [boolean]",
90
- description:
91
- "Enable tree shaking to remove unused code and reduce the bundle size.",
92
- parse: parseBoolean,
93
- },
94
- {
95
- name: "--unstable-transform-profile [string]",
96
- description:
97
- "Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default",
98
- parse: parseTransformProfile,
99
- },
100
- {
101
- name: "--reset-cache",
102
- description: "Reset the Metro cache.",
103
- },
104
- {
105
- name: "--config [string]",
106
- description: "Path to the Metro configuration file.",
107
- },
108
- ],
109
- },
17
+ rnxBundleCommand,
18
+ rnxRamBundleCommand,
110
19
  {
111
20
  name: "rnx-start",
112
21
  func: rnxStart,
@@ -0,0 +1,82 @@
1
+ import { parsePlatform } from "@rnx-kit/tools-react-native/platform";
2
+ import { parseBoolean, parseTransformProfile } from "../parsers";
3
+
4
+ export const commonBundleCommandOptions = [
5
+ {
6
+ name: "--id [id]",
7
+ description:
8
+ "Target bundle definition. This is only needed when the rnx-kit configuration has multiple bundle definitions.",
9
+ },
10
+ {
11
+ name: "--entry-file [path]",
12
+ description:
13
+ "Path to the root JavaScript or TypeScript file, either absolute or relative to the package.",
14
+ },
15
+ {
16
+ name: "--platform [ios|android|windows|win32|macos]",
17
+ description:
18
+ "Target platform. When not given, all platforms in the rnx-kit configuration are bundled.",
19
+ parse: parsePlatform,
20
+ },
21
+ {
22
+ name: "--dev [boolean]",
23
+ description: "If false, warnings are disabled and the bundle is minified.",
24
+ default: true,
25
+ parse: parseBoolean,
26
+ },
27
+ {
28
+ name: "--minify [boolean]",
29
+ description:
30
+ "Controls whether or not the bundle is minified. Disabling minification is useful for test builds.",
31
+ parse: parseBoolean,
32
+ },
33
+ {
34
+ name: "--bundle-output [string]",
35
+ description:
36
+ "Path to the output bundle file, either absolute or relative to the package.",
37
+ },
38
+ {
39
+ name: "--bundle-encoding [utf8|utf16le|ascii]",
40
+ description: "Character encoding to use when writing the bundle file.",
41
+ default: "utf8",
42
+ },
43
+ {
44
+ name: "--max-workers [number]",
45
+ description:
46
+ "Specifies the maximum number of parallel worker threads to use for transforming files. This defaults to the number of cores available on your machine.",
47
+ parse: parseInt,
48
+ },
49
+ {
50
+ name: "--sourcemap-output [string]",
51
+ description:
52
+ "Path where the bundle source map is written, either absolute or relative to the package.",
53
+ },
54
+ {
55
+ name: "--sourcemap-sources-root [string]",
56
+ description:
57
+ "Path to use when relativizing file entries in the bundle source map.",
58
+ },
59
+ {
60
+ name: "--sourcemap-use-absolute-path",
61
+ description: "Report SourceMapURL using its full path",
62
+ },
63
+ {
64
+ name: "--assets-dest [path]",
65
+ description:
66
+ "Path where bundle assets like images are written, either absolute or relative to the package. If not given, assets are ignored.",
67
+ },
68
+ {
69
+ name: "--unstable-transform-profile [string]",
70
+ description:
71
+ "Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default",
72
+ parse: parseTransformProfile,
73
+ },
74
+ {
75
+ name: "--reset-cache",
76
+ description: "Reset the Metro cache.",
77
+ },
78
+ {
79
+ name: "--config [string]",
80
+ description: "Path to the Metro configuration file.",
81
+ },
82
+ ];
@@ -4,8 +4,8 @@ import {
4
4
  getKitConfig,
5
5
  } from "@rnx-kit/config";
6
6
  import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
7
+ import { getDefaultBundlerPlugins } from "./defaultPlugins";
7
8
  import type { CliPlatformBundleConfig } from "./types";
8
- import { getDefaultBundlerPlugins } from "../bundler-plugin-defaults";
9
9
 
10
10
  /**
11
11
  * Get the list of target platforms for bundling.
@@ -49,7 +49,7 @@ function getDefaultBundleParameters(platform: string) {
49
49
  *
50
50
  * @param id Optional identity of the target bundle definition to return
51
51
  * @param overridePlatform Override platform, typically from the command-line. When given, this overrides the list of target platforms.
52
- * @returns Arrary of platform-specific bundle configurations
52
+ * @returns Array of platform-specific bundle configurations
53
53
  */
54
54
  export function getCliPlatformBundleConfigs(
55
55
  id?: string,
@@ -1,8 +1,9 @@
1
1
  import { info } from "@rnx-kit/console";
2
- import { bundle, BundleArgs as MetroBundleArgs } from "@rnx-kit/metro-service";
2
+ import type { BundleArgs as MetroBundleArgs } from "@rnx-kit/metro-service";
3
+ import { bundle } from "@rnx-kit/metro-service";
3
4
  import { createDirectory } from "@rnx-kit/tools-node/fs";
4
5
  import type { ConfigT } from "metro-config";
5
- import path from "path";
6
+ import * as path from "path";
6
7
  import { customizeMetroConfig } from "../metro-config";
7
8
  import type { CliPlatformBundleConfig } from "./types";
8
9
 
@@ -16,22 +17,18 @@ import type { CliPlatformBundleConfig } from "./types";
16
17
  * Further, optimizations like constant folding are disabled.
17
18
  * When `false`, warnings are disabled and the bundle is minified by default.
18
19
  * @param minify Optionally choose whether or not the bundle is minified. When not set, minification is controlled by the `dev` property.
20
+ * @param output Output bundle format; defaults to plain JS
19
21
  */
20
22
  export async function metroBundle(
21
23
  metroConfig: ConfigT,
22
24
  bundleConfig: CliPlatformBundleConfig,
23
25
  dev: boolean,
24
- minify?: boolean
26
+ minify?: boolean,
27
+ output = bundle
25
28
  ): Promise<void> {
26
29
  info(`Bundling ${bundleConfig.platform}...`);
27
30
 
28
- customizeMetroConfig(
29
- metroConfig,
30
- bundleConfig.detectCyclicDependencies,
31
- bundleConfig.detectDuplicateDependencies,
32
- bundleConfig.typescriptValidation,
33
- bundleConfig.treeShake
34
- );
31
+ customizeMetroConfig(metroConfig, bundleConfig);
35
32
 
36
33
  const metroBundleArgs: MetroBundleArgs = {
37
34
  ...bundleConfig,
@@ -46,5 +43,5 @@ export async function metroBundle(
46
43
  metroBundleArgs.assetsDest && createDirectory(metroBundleArgs.assetsDest);
47
44
 
48
45
  // create the bundle
49
- await bundle(metroBundleArgs, metroConfig);
46
+ await output(metroBundleArgs, metroConfig);
50
47
  }
@@ -1,41 +1,47 @@
1
- import type { TransformProfile } from "metro-babel-transformer";
2
- import type { BundleArgs } from "@rnx-kit/metro-service";
3
1
  import { pickValues } from "@rnx-kit/tools-language/properties";
4
2
  import type { CliPlatformBundleConfig } from "./types";
5
3
 
6
- export type BundleConfigOverrides = {
7
- entryFile?: string;
8
- bundleOutput?: string;
9
- bundleEncoding?: BundleArgs["bundleEncoding"];
10
- sourcemapOutput?: string;
11
- sourcemapSourcesRoot?: string;
12
- sourcemapUseAbsolutePath?: boolean;
13
- assetsDest?: string;
14
- treeShake?: boolean;
15
- unstableTransformProfile?: TransformProfile;
16
- };
4
+ type BundleConfigOverrides = Partial<
5
+ Pick<
6
+ CliPlatformBundleConfig,
7
+ | "entryFile"
8
+ | "bundleOutput"
9
+ | "bundleEncoding"
10
+ | "sourcemapOutput"
11
+ | "sourcemapSourcesRoot"
12
+ | "sourcemapUseAbsolutePath"
13
+ | "assetsDest"
14
+ | "treeShake"
15
+ | "unstableTransformProfile"
16
+ | "indexedRamBundle"
17
+ >
18
+ >;
19
+
20
+ export const overridableCommonBundleOptions: readonly (keyof BundleConfigOverrides)[] =
21
+ [
22
+ "assetsDest",
23
+ "bundleEncoding",
24
+ "bundleOutput",
25
+ "entryFile",
26
+ "sourcemapOutput",
27
+ "sourcemapSourcesRoot",
28
+ "sourcemapUseAbsolutePath",
29
+ "unstableTransformProfile",
30
+ ];
17
31
 
18
32
  /**
19
33
  * Apply overrides, if any, to each rnx-kit bundle configuration. Overrides are applied in-place.
20
34
  *
21
35
  * @param overrides Optional overrides to apply
22
36
  * @param configs Array of platform-specific bundle configurations. This is modified if any overrides are applied.
37
+ * @param keys Config keys to pick from {@link overrides}
23
38
  */
24
39
  export function applyBundleConfigOverrides(
25
40
  overrides: BundleConfigOverrides,
26
- configs: CliPlatformBundleConfig[]
41
+ configs: CliPlatformBundleConfig[],
42
+ keys: (keyof BundleConfigOverrides)[]
27
43
  ): void {
28
- const overridesToApply = pickValues(overrides, [
29
- "entryFile",
30
- "bundleOutput",
31
- "bundleEncoding",
32
- "sourcemapOutput",
33
- "sourcemapSourcesRoot",
34
- "sourcemapUseAbsolutePath",
35
- "assetsDest",
36
- "treeShake",
37
- "unstableTransformProfile",
38
- ]);
44
+ const overridesToApply = pickValues(overrides, keys);
39
45
  if (overridesToApply) {
40
46
  for (const config of configs) {
41
47
  Object.assign(config, overridesToApply);
@@ -1,7 +1,26 @@
1
1
  import type { TransformProfile } from "metro-babel-transformer";
2
2
  import type { BundleParameters } from "@rnx-kit/config";
3
+ import type { BundleArgs } from "@rnx-kit/metro-service";
3
4
  import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
4
5
 
6
+ export type CLICommonBundleOptions = {
7
+ id?: string;
8
+ entryFile?: string;
9
+ platform?: AllPlatforms;
10
+ dev: boolean;
11
+ minify?: boolean;
12
+ bundleOutput?: string;
13
+ bundleEncoding?: BundleArgs["bundleEncoding"];
14
+ maxWorkers?: number;
15
+ sourcemapOutput?: string;
16
+ sourcemapSourcesRoot?: string;
17
+ sourcemapUseAbsolutePath?: boolean;
18
+ assetsDest?: string;
19
+ unstableTransformProfile?: TransformProfile;
20
+ resetCache?: boolean;
21
+ config?: string;
22
+ };
23
+
5
24
  export type CliPlatformBundleConfig = BundleParameters &
6
25
  Required<
7
26
  Pick<
package/src/bundle.ts CHANGED
@@ -1,28 +1,17 @@
1
- import type { TransformProfile } from "metro-babel-transformer";
2
1
  import type { Config as CLIConfig } from "@react-native-community/cli-types";
3
- import { BundleArgs, loadMetroConfig } from "@rnx-kit/metro-service";
4
- import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
2
+ import { loadMetroConfig } from "@rnx-kit/metro-service";
3
+ import { commonBundleCommandOptions } from "./bundle/cliOptions";
5
4
  import { getCliPlatformBundleConfigs } from "./bundle/kit-config";
6
5
  import { metroBundle } from "./bundle/metro";
7
- import { applyBundleConfigOverrides } from "./bundle/overrides";
6
+ import {
7
+ applyBundleConfigOverrides,
8
+ overridableCommonBundleOptions,
9
+ } from "./bundle/overrides";
10
+ import type { CLICommonBundleOptions } from "./bundle/types";
11
+ import { parseBoolean } from "./parsers";
8
12
 
9
- export type CLIBundleOptions = {
10
- id?: string;
11
- entryFile?: string;
12
- platform?: AllPlatforms;
13
- dev: boolean;
14
- minify?: boolean;
15
- bundleOutput?: string;
16
- bundleEncoding?: BundleArgs["bundleEncoding"];
17
- maxWorkers?: number;
18
- sourcemapOutput?: string;
19
- sourcemapSourcesRoot?: string;
20
- sourcemapUseAbsolutePath?: boolean;
21
- assetsDest?: string;
13
+ type CLIBundleOptions = CLICommonBundleOptions & {
22
14
  treeShake?: boolean;
23
- unstableTransformProfile?: TransformProfile;
24
- resetCache?: boolean;
25
- config?: string;
26
15
  };
27
16
 
28
17
  export async function rnxBundle(
@@ -37,7 +26,10 @@ export async function rnxBundle(
37
26
  cliOptions.platform
38
27
  );
39
28
 
40
- applyBundleConfigOverrides(cliOptions, bundleConfigs);
29
+ applyBundleConfigOverrides(cliOptions, bundleConfigs, [
30
+ ...overridableCommonBundleOptions,
31
+ "treeShake",
32
+ ]);
41
33
 
42
34
  for (const bundleConfig of bundleConfigs) {
43
35
  await metroBundle(
@@ -47,6 +39,20 @@ export async function rnxBundle(
47
39
  cliOptions.minify
48
40
  );
49
41
  }
50
-
51
- return Promise.resolve();
52
42
  }
43
+
44
+ export const rnxBundleCommand = {
45
+ name: "rnx-bundle",
46
+ description:
47
+ "Bundle your rnx-kit package for offline use. See https://aka.ms/rnx-kit.",
48
+ func: rnxBundle,
49
+ options: [
50
+ ...commonBundleCommandOptions,
51
+ {
52
+ name: "--tree-shake [boolean]",
53
+ description:
54
+ "Enable tree shaking to remove unused code and reduce the bundle size.",
55
+ parse: parseBoolean,
56
+ },
57
+ ],
58
+ };
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
- export { rnxBundle } from "./bundle";
1
+ export { rnxBundle, rnxBundleCommand } from "./bundle";
2
+ export { rnxClean } from "./clean";
2
3
  export { copyProjectAssets, rnxCopyAssetsCommand } from "./copy-assets";
3
4
  export { rnxDepCheck, rnxDepCheckCommand } from "./dep-check";
5
+ export { parseBoolean, parseInt, parseTransformProfile } from "./parsers";
6
+ export { rnxRamBundle, rnxRamBundleCommand } from "./ram-bundle";
4
7
  export { rnxStart } from "./start";
5
8
  export { rnxTest, rnxTestCommand } from "./test";
6
9
  export { rnxWriteThirdPartyNotices } from "./write-third-party-notices";
7
- export { parseBoolean, parseTransformProfile } from "./parsers";
8
- export { rnxClean } from "./clean";
@@ -1,24 +1,20 @@
1
- import type { TypeScriptValidationOptions } from "@rnx-kit/config";
2
- import {
3
- CyclicDependencies,
4
- PluginOptions as CyclicDetectorOptions,
5
- } from "@rnx-kit/metro-plugin-cyclic-dependencies-detector";
6
- import {
7
- DuplicateDependencies,
8
- Options as DuplicateDetectorOptions,
9
- } from "@rnx-kit/metro-plugin-duplicates-checker";
10
- import { MetroPlugin, MetroSerializer } from "@rnx-kit/metro-serializer";
1
+ import type {
2
+ BundlerPlugins,
3
+ TypeScriptValidationOptions,
4
+ } from "@rnx-kit/config";
5
+ import { CyclicDependencies } from "@rnx-kit/metro-plugin-cyclic-dependencies-detector";
6
+ import { DuplicateDependencies } from "@rnx-kit/metro-plugin-duplicates-checker";
7
+ import type { MetroPlugin } from "@rnx-kit/metro-serializer";
8
+ import { MetroSerializer } from "@rnx-kit/metro-serializer";
11
9
  import {
12
10
  esbuildTransformerConfig,
13
11
  MetroSerializer as MetroSerializerEsbuild,
14
12
  } from "@rnx-kit/metro-serializer-esbuild";
15
- import { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
16
- import { Project } from "@rnx-kit/typescript-service";
17
-
18
- import { createProjectCache } from "./typescript/project-cache";
19
-
13
+ import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
14
+ import type { Project } from "@rnx-kit/typescript-service";
20
15
  import type { DeltaResult, Graph } from "metro";
21
16
  import type { InputConfigT, SerializerConfigT } from "metro-config";
17
+ import { createProjectCache } from "./typescript/project-cache";
22
18
 
23
19
  /**
24
20
  * Create a hook function to be registered with Metro during serialization.
@@ -116,18 +112,17 @@ const emptySerializerHook = (_graph: Graph, _delta: DeltaResult): void => {
116
112
  * Customize the Metro configuration.
117
113
  *
118
114
  * @param metroConfigReadonly Metro configuration
119
- * @param detectCyclicDependencies When true, cyclic dependency checking is enabled with a default set of options. Otherwise the object allows for fine-grained control over the detection process.
120
- * @param detectDuplicateDependencies When true, duplicate dependency checking is enabled with a default set of options. Otherwise, the object allows for fine-grained control over the detection process.
121
- * @param typescriptValidation When true, TypeScript type-checking is enabled with a default set of options. Otherwise, the object allows for fine-grained control over the type-checking process.
122
- * @param treeShake When true, tree shaking is enabled.
115
+ * @param bundlerPlugins Plugins used to further customize Metro configuration
123
116
  * @param print Optional function to use when printing status messages to the Metro console
124
117
  */
125
118
  export function customizeMetroConfig(
126
119
  metroConfigReadonly: InputConfigT,
127
- detectCyclicDependencies: boolean | CyclicDetectorOptions,
128
- detectDuplicateDependencies: boolean | DuplicateDetectorOptions,
129
- typescriptValidation: boolean | TypeScriptValidationOptions,
130
- treeShake: boolean,
120
+ {
121
+ detectCyclicDependencies,
122
+ detectDuplicateDependencies,
123
+ treeShake,
124
+ typescriptValidation,
125
+ }: BundlerPlugins,
131
126
  print?: (message: string) => void
132
127
  ): void {
133
128
  // We will be making changes to the Metro configuration. Coerce from a
package/src/parsers.ts CHANGED
@@ -12,6 +12,10 @@ export function parseBoolean(val: string): boolean {
12
12
  );
13
13
  }
14
14
 
15
+ export function parseInt(value: string): number {
16
+ return global.parseInt(value, 10);
17
+ }
18
+
15
19
  export function parseTransformProfile(val: string): TransformProfile {
16
20
  const allowedProfiles: TransformProfile[] = [
17
21
  "hermes-stable",