Permalink
Browse files

Move packager core logic from `local-cli` to `packager`

Summary: Moves packager core logic to `packager/...` to prepare the open source split.

Reviewed By: cpojer

Differential Revision: D5116162

fbshipit-source-id: 06ee2406026686789f67acc88df41773866c3cd3
  • Loading branch information...
davidaurelio authored and facebook-github-bot committed May 24, 2017
1 parent aec7b34 commit bea7659762a14b3f30562e98fd6931d6eaa7d6bf
@@ -15,7 +15,7 @@ const log = require('../util/log').out('bundle');
const Server = require('../../packager/src/Server');
const TerminalReporter = require('../../packager/src/lib/TerminalReporter');
const outputBundle = require('./output/bundle');
const outputBundle = require('../../packager/src/shared/output/bundle');
const path = require('path');
const saveAssets = require('./saveAssets');
const defaultAssetExts = require('../../packager/defaults').assetExts;
@@ -10,7 +10,7 @@
const buildBundle = require('./buildBundle');
const bundleCommandLineArgs = require('./bundleCommandLineArgs');
const outputBundle = require('./output/bundle');
const outputBundle = require('../../packager/src/shared/output/bundle');
/**
* Builds the bundle starting to look for dependencies at the given entry path.
@@ -10,41 +10,4 @@
*/
'use strict';
import type Bundle from '../../packager/src/Bundler/Bundle';
import type {Unbundle} from '../../packager/src/Bundler/Bundle';
import type ModuleTransport, {SourceMapOrMappings} from '../../packager/src/lib/ModuleTransport';
import type {FBSourceMap, SourceMap} from '../../packager/src/lib/SourceMap';
export type {Bundle, FBSourceMap, ModuleTransport, SourceMap, Unbundle};
export type ModuleGroups = {|
groups: Map<number, Set<number>>,
modulesById: Map<number, ModuleTransportLike>,
modulesInGroups: Set<number>,
|};
export type ModuleTransportLike = {
+code: string,
+id: number,
+map: ?SourceMapOrMappings,
+name?: string,
+sourcePath: string,
};
export type OutputOptions = {
bundleOutput: string,
bundleEncoding?: 'utf8' | 'utf16le' | 'ascii',
dev?: boolean,
platform: string,
sourcemapOutput?: string,
sourcemapSourcesRoot?: string,
sourcemapUseAbsolutePath?: boolean,
};
export type RequestOptions = {|
entryFile: string,
sourceMapUrl?: string,
dev?: boolean,
minify: boolean,
platform: string,
|};
export type {OutputOptions, RequestOptions} from '../../packager/src/shared/types.flow';
@@ -10,7 +10,7 @@
const bundleWithOutput = require('./bundle').withOutput;
const bundleCommandLineArgs = require('./bundleCommandLineArgs');
const outputUnbundle = require('./output/unbundle');
const outputUnbundle = require('../../packager/src/shared/output/unbundle');
/**
* Builds the bundle starting to look for dependencies at the given entry path.
@@ -16,7 +16,7 @@ const babelGenerate = require('babel-generator').default;
const babylon = require('babylon');
import type {AssetDescriptor} from '.';
import type {ModuleTransportLike} from '../../../local-cli/bundle/types.flow';
import type {ModuleTransportLike} from '../shared/types.flow';
type SubTree<T: ModuleTransportLike> = (
moduleTransport: T,
@@ -10,11 +10,11 @@
*/
'use strict';
const buildSourceMapWithMetaData = require('../../../../local-cli/bundle/output/unbundle/build-unbundle-sourcemap-with-metadata.js');
const buildSourceMapWithMetaData = require('../../shared/output/unbundle/build-unbundle-sourcemap-with-metadata.js');
const nullthrows = require('fbjs/lib/nullthrows');
const {buildTableAndContents, createModuleGroups} = require('../../../../local-cli/bundle/output/unbundle/as-indexed-file');
const {createRamBundleGroups} = require('../../Bundler/util');
const {buildTableAndContents, createModuleGroups} = require('../../shared/output/unbundle/as-indexed-file');
const {concat} = require('./util');
import type {FBIndexMap} from '../../lib/SourceMap.js';
@@ -10,7 +10,7 @@
*/
'use strict';
const meta = require('../../../../local-cli/bundle/output/meta');
const meta = require('../../shared/output/meta');
const {createIndexMap} = require('./source-map');
const {addModuleIdsToModuleWrapper, concat} = require('./util');
@@ -11,14 +11,14 @@
'use strict';
const Server = require('../../../packager/src/Server');
const Server = require('../../Server');
const meta = require('./meta');
const relativizeSourceMap = require('../../../packager/src//lib/relativizeSourceMap');
const relativizeSourceMap = require('../../lib/relativizeSourceMap');
const writeFile = require('./writeFile');
import type Bundle from '../../../packager/src/Bundler/Bundle';
import type {SourceMap} from '../../../packager/src/lib/SourceMap';
import type Bundle from '../../Bundler/Bundle';
import type {SourceMap} from '../../lib/SourceMap';
import type {OutputOptions, RequestOptions} from '../types.flow';
function buildBundle(packagerClient: Server, requestOptions: RequestOptions) {
@@ -15,13 +15,13 @@ const MAGIC_UNBUNDLE_NUMBER = require('./magic-number');
const buildSourceMapWithMetaData = require('./build-unbundle-sourcemap-with-metadata');
const mkdirp = require('mkdirp');
const path = require('path');
const relativizeSourceMap = require('../../../../packager/src//lib/relativizeSourceMap');
const relativizeSourceMap = require('../../../lib/relativizeSourceMap');
const writeFile = require('../writeFile');
const writeSourceMap = require('./write-sourcemap');
const {joinModules} = require('./util');
import type Bundle from '../../../../packager/src//Bundler/Bundle';
import type Bundle from '../../../Bundler/Bundle';
import type {OutputOptions} from '../../types.flow';
// must not start with a dot, as that won't go into the apk
@@ -14,12 +14,13 @@ const MAGIC_UNBUNDLE_FILE_HEADER = require('./magic-number');
const buildSourceMapWithMetaData = require('./build-unbundle-sourcemap-with-metadata');
const fs = require('fs');
const relativizeSourceMap = require('../../../../packager/src//lib/relativizeSourceMap');
const relativizeSourceMap = require('../../../lib/relativizeSourceMap');
const writeSourceMap = require('./write-sourcemap');
const {joinModules} = require('./util');
import type {Bundle, ModuleGroups, ModuleTransportLike, OutputOptions} from '../../types.flow';
import type Bundle from '../../../Bundler/Bundle';
import type {ModuleGroups, ModuleTransportLike, OutputOptions} from '../../types.flow';
const SIZEOF_UINT32 = 4;
@@ -11,12 +11,12 @@
'use strict';
const Server = require('../../../../packager/src/Server');
const Server = require('../../../Server');
const asAssets = require('./as-assets');
const asIndexedFile = require('./as-indexed-file').save;
import type Bundle from '../../../../packager/src//Bundler/Bundle';
import type Bundle from '../../../Bundler/Bundle';
import type {OutputOptions, RequestOptions} from '../../types.flow';
function buildBundle(packagerClient: Server, requestOptions: RequestOptions) {
@@ -12,7 +12,7 @@
const invariant = require('fbjs/lib/invariant');
import type {FBIndexMap, IndexMap, MappingsMap, SourceMap} from '../../../../packager/src/lib/SourceMap';
import type {FBIndexMap, IndexMap, MappingsMap, SourceMap} from '../../../lib/SourceMap';
import type {ModuleGroups, ModuleTransportLike} from '../../types.flow';
const newline = /\r\n?|\n|\u2028|\u2029/g;
@@ -0,0 +1,44 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';
import type {SourceMapOrMappings} from '../lib/ModuleTransport';
export type ModuleGroups = {|
groups: Map<number, Set<number>>,
modulesById: Map<number, ModuleTransportLike>,
modulesInGroups: Set<number>,
|};
export type ModuleTransportLike = {
+code: string,
+id: number,
+map: ?SourceMapOrMappings,
+name?: string,
+sourcePath: string,
};
export type OutputOptions = {
bundleOutput: string,
bundleEncoding?: 'utf8' | 'utf16le' | 'ascii',
dev?: boolean,
platform: string,
sourcemapOutput?: string,
sourcemapSourcesRoot?: string,
sourcemapUseAbsolutePath?: boolean,
};
export type RequestOptions = {|
entryFile: string,
sourceMapUrl?: string,
dev?: boolean,
minify: boolean,
platform: string,
|};

0 comments on commit bea7659

Please sign in to comment.