Don’t save original source code

Reviewed By: jeanlauliac

Differential Revision: D5901918

fbshipit-source-id: 68332b07f34ac4fd5491868cbc9f81283dae8d91
This commit is contained in:
David Aurelio 2017-09-25 18:03:49 -07:00 committed by Facebook Github Bot
parent 0c2e414337
commit afb91bccd3
5 changed files with 11 additions and 14 deletions

View File

@ -42,7 +42,7 @@ describe('Minification:', () => {
objectContaining({ objectContaining({
sourceMap: { sourceMap: {
content: map, content: map,
includeSources: true, includeSources: false,
}, },
}), }),
); );
@ -55,7 +55,7 @@ describe('Minification:', () => {
objectContaining({ objectContaining({
sourceMap: { sourceMap: {
content: undefined, content: undefined,
includeSources: true, includeSources: false,
}, },
}), }),
); );

View File

@ -46,7 +46,7 @@ function minify(inputCode: string, inputMap: ?MappingsMap) {
}, },
sourceMap: { sourceMap: {
content: inputMap, content: inputMap,
includeSources: true, includeSources: false,
}, },
toplevel: true, toplevel: true,
}); });

View File

@ -133,7 +133,6 @@ export type TransformResults = {[string]: TransformResult};
export type TransformVariants = {+[name: string]: {}, +default: {}}; export type TransformVariants = {+[name: string]: {}, +default: {}};
export type TransformedCodeFile = { export type TransformedCodeFile = {
+code: string,
+file: string, +file: string,
+hasteID: ?string, +hasteID: ?string,
package?: PackageData, package?: PackageData,

View File

@ -22,7 +22,7 @@ function generate(
sourceCode: string, sourceCode: string,
compact: boolean, compact: boolean,
) { ) {
return babelGenerate( const generated = babelGenerate(
ast, ast,
{ {
comments: false, comments: false,
@ -34,6 +34,9 @@ function generate(
}, },
sourceCode, sourceCode,
); );
delete generated.map.sourcesContent;
return generated;
} }
module.exports = generate; module.exports = generate;

View File

@ -43,17 +43,12 @@ function optimizeModule(
} }
const {details} = data; const {details} = data;
const {code, file, transformed} = details; const {file, transformed} = details;
const result = {...details, transformed: {}}; const result = {...details, transformed: {}};
const {postMinifyProcess} = optimizationOptions; const {postMinifyProcess} = optimizationOptions;
Object.entries(transformed).forEach(([k, t: TransformResult]) => { Object.entries(transformed).forEach(([k, t: TransformResult]) => {
const optimized = optimize( const optimized = optimize((t: $FlowFixMe), file, optimizationOptions);
(t: $FlowFixMe),
file,
code,
optimizationOptions,
);
const processed = postMinifyProcess({ const processed = postMinifyProcess({
code: optimized.code, code: optimized.code,
map: optimized.map, map: optimized.map,
@ -66,7 +61,7 @@ function optimizeModule(
return {type: 'code', details: result}; return {type: 'code', details: result};
} }
function optimize(transformed: TransformResult, file, originalCode, options) { function optimize(transformed: TransformResult, file, options) {
const {code, dependencyMapName, map} = transformed; const {code, dependencyMapName, map} = transformed;
const optimized = optimizeCode(code, map, file, options); const optimized = optimizeCode(code, map, file, options);
@ -82,7 +77,7 @@ function optimize(transformed: TransformResult, file, originalCode, options) {
} }
const inputMap = transformed.map; const inputMap = transformed.map;
const gen = generate(optimized.ast, file, originalCode, true); const gen = generate(optimized.ast, file, '', true);
const min = minify.withSourceMap( const min = minify.withSourceMap(
gen.code, gen.code,