11import fs from 'node:fs' ;
22import path from 'node:path' ;
3- import {
4- bundleCommand ,
5- // @ts -expect-error missing typings - TODO drop dependency on community plugin
6- } from '@react-native/community-cli-plugin' ;
73import type { PluginApi } from '@rnef/config' ;
84import {
95 colorLink ,
@@ -14,6 +10,7 @@ import {
1410 runHermes ,
1511 spinner ,
1612} from '@rnef/tools' ;
13+ import { getReactNativeCommunityCliPlugin } from '../getReactNativeDeps.js' ;
1714
1815type BundleCommandArgs = {
1916 assetsDest ?: string ;
@@ -61,6 +58,9 @@ export function registerBundleCommand(api: PluginApi) {
6158 const bundleOutputDir = path . dirname ( args . bundleOutput ) ;
6259 fs . mkdirSync ( bundleOutputDir , { recursive : true } ) ;
6360
61+ const { bundleCommand } =
62+ await getReactNativeCommunityCliPlugin ( reactNativePath ) ;
63+
6464 await bundleCommand . func (
6565 undefined ,
6666 { root, reactNativeVersion, reactNativePath, platforms } ,
@@ -85,7 +85,104 @@ export function registerBundleCommand(api: PluginApi) {
8585 outro ( 'Success 🎉.' ) ;
8686 } ,
8787 options : [
88- ...bundleCommand . options ,
88+ {
89+ name : '--entry-file <path>' ,
90+ description :
91+ 'Path to the root JS file, either absolute or relative to JS root' ,
92+ } ,
93+ {
94+ name : '--platform <string>' ,
95+ description : 'Either "ios" or "android"' ,
96+ default : 'ios' ,
97+ } ,
98+ {
99+ name : '--transformer <string>' ,
100+ description : 'Specify a custom transformer to be used' ,
101+ } ,
102+ {
103+ name : '--dev [boolean]' ,
104+ description :
105+ 'If false, warnings are disabled and the bundle is minified' ,
106+ parse : ( val ) => val !== 'false' ,
107+ default : true ,
108+ } ,
109+ {
110+ name : '--minify [boolean]' ,
111+ description :
112+ 'Allows overriding whether bundle is minified. This defaults to ' +
113+ 'false if dev is true, and true if dev is false. Disabling minification ' +
114+ 'can be useful for speeding up production builds for testing purposes.' ,
115+ parse : ( val ) => val !== 'false' ,
116+ } ,
117+ {
118+ name : '--bundle-output <string>' ,
119+ description :
120+ 'File name where to store the resulting bundle, ex. /tmp/groups.bundle' ,
121+ } ,
122+ {
123+ name : '--bundle-encoding <string>' ,
124+ description :
125+ 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).' ,
126+ default : 'utf8' ,
127+ } ,
128+ {
129+ name : '--max-workers <number>' ,
130+ description :
131+ 'Specifies the maximum number of workers the worker-pool ' +
132+ 'will spawn for transforming files. This defaults to the number of the ' +
133+ 'cores available on your machine.' ,
134+ } ,
135+ {
136+ name : '--sourcemap-output <string>' ,
137+ description :
138+ 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map' ,
139+ } ,
140+ {
141+ name : '--sourcemap-sources-root <string>' ,
142+ description :
143+ "Path to make sourcemap's sources entries relative to, ex. /root/dir" ,
144+ } ,
145+ {
146+ name : '--sourcemap-use-absolute-path' ,
147+ description : 'Report SourceMapURL using its full path' ,
148+ default : false ,
149+ } ,
150+ {
151+ name : '--assets-dest <string>' ,
152+ description :
153+ 'Directory name where to store assets referenced in the bundle' ,
154+ } ,
155+ {
156+ name : '--unstable-transform-profile <string>' ,
157+ description :
158+ 'Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default' ,
159+ default : 'default' ,
160+ } ,
161+ {
162+ name : '--asset-catalog-dest [string]' ,
163+ description : 'Path where to create an iOS Asset Catalog for images' ,
164+ } ,
165+ {
166+ name : '--reset-cache' ,
167+ description : 'Removes cached files' ,
168+ default : false ,
169+ } ,
170+ {
171+ name : '--read-global-cache' ,
172+ description :
173+ 'Try to fetch transformed JS code from the global cache, if configured.' ,
174+ default : false ,
175+ } ,
176+ {
177+ name : '--config <string>' ,
178+ description : 'Path to the CLI configuration file' ,
179+ parse : ( val ) => path . resolve ( val ) ,
180+ } ,
181+ {
182+ name : '--resolver-option <string...>' ,
183+ description :
184+ 'Custom resolver options of the form key=value. URL-encoded. May be specified multiple times.' ,
185+ } ,
89186 {
90187 name : '--config-cmd [string]' ,
91188 description :
0 commit comments