mirror of
https://github.com/status-im/metro.git
synced 2025-01-19 07:32:16 +00:00
Don’t save original source code
Reviewed By: jeanlauliac Differential Revision: D5901918 fbshipit-source-id: 68332b07f34ac4fd5491868cbc9f81283dae8d91
This commit is contained in:
parent
0c2e414337
commit
afb91bccd3
@ -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,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -46,7 +46,7 @@ function minify(inputCode: string, inputMap: ?MappingsMap) {
|
|||||||
},
|
},
|
||||||
sourceMap: {
|
sourceMap: {
|
||||||
content: inputMap,
|
content: inputMap,
|
||||||
includeSources: true,
|
includeSources: false,
|
||||||
},
|
},
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
});
|
});
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user