MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / buildBundle

Function buildBundle

local-cli/bundle/buildBundle.js:35–121  ·  view source on GitHub ↗
(
  args: OutputOptions & {
    assetsDest: mixed,
    entryFile: string,
    resetCache: boolean,
    transformer: string,
  },
  config: ConfigT,
  output = outputBundle,
  packagerInstance,
)

Source from the content-addressed store, hash-verified

33}
34
35function buildBundle(
36 args: OutputOptions & {
37 assetsDest: mixed,
38 entryFile: string,
39 resetCache: boolean,
40 transformer: string,
41 },
42 config: ConfigT,
43 output = outputBundle,
44 packagerInstance,
45) {
46 // This is used by a bazillion of npm modules we don't control so we don't
47 // have other choice than defining it as an env variable here.
48 process.env.NODE_ENV = args.dev ? 'development' : 'production';
49
50 let sourceMapUrl = args.sourcemapOutput;
51 if (sourceMapUrl && !args.sourcemapUseAbsolutePath) {
52 sourceMapUrl = path.basename(sourceMapUrl);
53 }
54
55 const requestOpts: RequestOptions = {
56 entryFile: args.entryFile,
57 sourceMapUrl,
58 dev: args.dev,
59 minify: !args.dev,
60 platform: args.platform,
61 };
62
63 // If a packager instance was not provided, then just create one for this
64 // bundle command and close it down afterwards.
65 var shouldClosePackager = false;
66 if (!packagerInstance) {
67 const assetExts = (config.getAssetExts && config.getAssetExts()) || [];
68 const sourceExts = (config.getSourceExts && config.getSourceExts()) || [];
69 const platforms = (config.getPlatforms && config.getPlatforms()) || [];
70
71 const transformModulePath =
72 args.transformer ? path.resolve(args.transformer) :
73 typeof config.getTransformModulePath === 'function' ? config.getTransformModulePath() :
74 undefined;
75
76 const providesModuleNodeModules =
77 typeof config.getProvidesModuleNodeModules === 'function' ? config.getProvidesModuleNodeModules() :
78 defaultProvidesModuleNodeModules;
79
80 const options = {
81 assetExts: defaultAssetExts.concat(assetExts),
82 blacklistRE: config.getBlacklistRE(args.platform),
83 extraNodeModules: config.extraNodeModules,
84 getTransformOptions: config.getTransformOptions,
85 globalTransformCache: null,
86 hasteImpl: config.hasteImpl,
87 platforms: defaultPlatforms.concat(platforms),
88 postProcessModules: config.postProcessModules,
89 projectRoots: config.getProjectRoots(),
90 providesModuleNodeModules: providesModuleNodeModules,
91 resetCache: args.resetCache,
92 reporter: new TerminalReporter(),

Callers 1

bundleWithOutputFunction · 0.70

Calls 7

saveBundleFunction · 0.85
saveAssetsFunction · 0.85
getAssetsMethod · 0.80
resolveMethod · 0.65
buildMethod · 0.65
thenMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…