Commit 2eb0fe6d authored by rockyl's avatar rockyl

修复内联过程代码没有抽离的问题

parent 4e592f36
......@@ -56,10 +56,7 @@ class ProcessManager {
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
this.deal(subProcess);
}
}
}
......@@ -83,7 +80,9 @@ class ProcessManager {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\n');
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
......@@ -100,11 +99,11 @@ ${script}
this.pool = {};
}
async compile(){
async compile() {
try {
const {code ,sourcemap} = await compile(this.scripts, true);
const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
} catch (e) {
console.log('编译失败', e);
}
}
......@@ -348,19 +347,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
}
const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){
if(process.sub){
for(let uuid in process.sub){
function deleteUnusedData(processes) {
for (let process of processes) {
if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid];
for(let field of unusedFields){
if(subProcess.hasOwnProperty(field)){
for (let field of unusedFields) {
if (subProcess.hasOwnProperty(field)) {
delete subProcess[field];
}
}
}
}
if(process.metas && process.metas.length > 0){
if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas);
}
}
......
This diff is collapsed.
......@@ -62,10 +62,7 @@ class ProcessManager {
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
this.deal(subProcess);
}
}
}
......@@ -89,7 +86,9 @@ class ProcessManager {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\n');
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
......@@ -106,11 +105,11 @@ ${script}
this.pool = {};
}
async compile(){
async compile() {
try {
const {code ,sourcemap} = await compile(this.scripts, true);
const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
} catch (e) {
console.log('编译失败', e);
}
}
......@@ -354,19 +353,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
}
const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){
if(process.sub){
for(let uuid in process.sub){
function deleteUnusedData(processes) {
for (let process of processes) {
if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid];
for(let field of unusedFields){
if(subProcess.hasOwnProperty(field)){
for (let field of unusedFields) {
if (subProcess.hasOwnProperty(field)) {
delete subProcess[field];
}
}
}
}
if(process.metas && process.metas.length > 0){
if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas);
}
}
......
This diff is collapsed.
......@@ -62,10 +62,7 @@
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
this.deal(subProcess);
}
}
}
......@@ -89,7 +86,9 @@
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\n');
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
......@@ -106,11 +105,11 @@ ${script}
this.pool = {};
}
async compile(){
async compile() {
try {
const {code ,sourcemap} = await compile(this.scripts, true);
const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
} catch (e) {
console.log('编译失败', e);
}
}
......@@ -354,19 +353,20 @@ ${scripts}
}
const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){
if(process.sub){
for(let uuid in process.sub){
function deleteUnusedData(processes) {
for (let process of processes) {
if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid];
for(let field of unusedFields){
if(subProcess.hasOwnProperty(field)){
for (let field of unusedFields) {
if (subProcess.hasOwnProperty(field)) {
delete subProcess[field];
}
}
}
}
if(process.metas && process.metas.length > 0){
if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas);
}
}
......
This diff is collapsed.
......@@ -23,10 +23,7 @@ export default class ProcessManager {
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
this.deal(subProcess);
}
}
}
......@@ -50,7 +47,9 @@ export default class ProcessManager {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\n');
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
......@@ -67,11 +66,11 @@ ${script}
this.pool = {};
}
async compile(){
async compile() {
try {
const {code ,sourcemap} = await compile(this.scripts, true);
const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
} catch (e) {
console.log('编译失败', e);
}
}
......
......@@ -151,19 +151,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
}
const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){
if(process.sub){
for(let uuid in process.sub){
function deleteUnusedData(processes) {
for (let process of processes) {
if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid];
for(let field of unusedFields){
if(subProcess.hasOwnProperty(field)){
for (let field of unusedFields) {
if (subProcess.hasOwnProperty(field)) {
delete subProcess[field];
}
}
}
}
if(process.metas && process.metas.length > 0){
if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment