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

View File

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

View File

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

View File

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

View File

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