Skip to content

Commit

Permalink
Packager postprocessing hook
Browse files Browse the repository at this point in the history
Reviewed By: davidaurelio

Differential Revision: D5244060

fbshipit-source-id: 3f5f9ab9aeeb63eca13d6dab089c2bda42f70c33
  • Loading branch information
cblappert authored and facebook-github-bot committed Jun 26, 2017
1 parent 83faa4b commit c0505ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions local-cli/bundle/buildBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function buildBundle(
platforms: defaultPlatforms.concat(platforms),
postMinifyProcess: config.postMinifyProcess,
postProcessModules: config.postProcessModules,
postProcessBundleSourcemap: config.postProcessBundleSourcemap,
projectRoots: config.getProjectRoots(),
providesModuleNodeModules: providesModuleNodeModules,
resetCache: args.resetCache,
Expand Down
18 changes: 16 additions & 2 deletions local-cli/util/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ const {providesModuleNodeModules} = require('metro-bundler/src/defaults');

const RN_CLI_CONFIG = 'rn-cli.config.js';

import type {GetTransformOptions, PostMinifyProcess, PostProcessModules} from 'metro-bundler/src/Bundler';
import type {
GetTransformOptions,
PostMinifyProcess,
PostProcessModules,
// $FlowFixMe: Exported by metro bundler
PostProcessBundleSourcemap
} from 'metro-bundler/src/Bundler';
import type {HasteImpl} from 'metro-bundler/src/node-haste/Module';
import type {TransformVariants} from 'metro-bundler/src/ModuleGraph/types.flow';
import type {PostProcessModules as PostProcessModulesForBuck} from 'metro-bundler/src/ModuleGraph/types.flow.js';
Expand Down Expand Up @@ -86,7 +92,7 @@ export type ConfigT = {

/**
* An optional function that can modify the code and source map of bundle
* after the minifaction took place.
* after the minifaction took place. (Function applied per module).
*/
postMinifyProcess: PostMinifyProcess,

Expand All @@ -96,6 +102,13 @@ export type ConfigT = {
*/
postProcessModules: PostProcessModules,

/**
* An optional function that can modify the code and source map of the bundle
* before it is written. Applied once for the entire bundle, only works if
* output is a plainBundle.
*/
postProcessBundleSourcemap: PostProcessBundleSourcemap,

/**
* Same as `postProcessModules` but for the Buck worker. Eventually we do want
* to unify both variants.
Expand Down Expand Up @@ -161,6 +174,7 @@ const Config = {
postMinifyProcess: x => x,
postProcessModules: modules => modules,
postProcessModulesForBuck: modules => modules,
postProcessBundleSourcemap: ({code, map, outFileName}) => ({code, map}),
transformVariants: () => ({default: {}}),
getWorkerPath: () => null,
}: ConfigT),
Expand Down

0 comments on commit c0505ce

Please sign in to comment.