Commit 2eb0fe6d authored by rockyl's avatar rockyl

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

parent 4e592f36
...@@ -56,10 +56,7 @@ class ProcessManager { ...@@ -56,10 +56,7 @@ class ProcessManager {
} }
if (process.metas) { if (process.metas) {
for (let subProcess of process.metas) { for (let subProcess of process.metas) {
let hash = this.put(subProcess); this.deal(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
} }
} }
} }
...@@ -83,7 +80,9 @@ class ProcessManager { ...@@ -83,7 +80,9 @@ class ProcessManager {
let scripts = ''; let scripts = '';
for (let hash in this.pool) { for (let hash in this.pool) {
let {script, ids} = this.pool[hash]; 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 += ` scripts += `
exports['${hash}'] = function(args, props, target, global, vm){ exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
...@@ -100,11 +99,11 @@ ${script} ...@@ -100,11 +99,11 @@ ${script}
this.pool = {}; this.pool = {};
} }
async compile(){ async compile() {
try { try {
const {code ,sourcemap} = await compile(this.scripts, true); const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code; this.scripts = code;
}catch (e) { } catch (e) {
console.log('编译失败', e); console.log('编译失败', e);
} }
} }
...@@ -348,19 +347,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -348,19 +347,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
} }
const unusedFields = ['design']; const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){ function deleteUnusedData(processes) {
if(process.sub){ for (let process of processes) {
for(let uuid in process.sub){ if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid]; let subProcess = process.sub[uuid];
for(let field of unusedFields){ for (let field of unusedFields) {
if(subProcess.hasOwnProperty(field)){ if (subProcess.hasOwnProperty(field)) {
delete subProcess[field]; delete subProcess[field];
} }
} }
} }
} }
if(process.metas && process.metas.length > 0){ if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas); deleteUnusedData(process.metas);
} }
} }
......
This diff is collapsed.
...@@ -62,10 +62,7 @@ class ProcessManager { ...@@ -62,10 +62,7 @@ class ProcessManager {
} }
if (process.metas) { if (process.metas) {
for (let subProcess of process.metas) { for (let subProcess of process.metas) {
let hash = this.put(subProcess); this.deal(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
} }
} }
} }
...@@ -89,7 +86,9 @@ class ProcessManager { ...@@ -89,7 +86,9 @@ class ProcessManager {
let scripts = ''; let scripts = '';
for (let hash in this.pool) { for (let hash in this.pool) {
let {script, ids} = this.pool[hash]; 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 += ` scripts += `
exports['${hash}'] = function(args, props, target, global, vm){ exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
...@@ -106,11 +105,11 @@ ${script} ...@@ -106,11 +105,11 @@ ${script}
this.pool = {}; this.pool = {};
} }
async compile(){ async compile() {
try { try {
const {code ,sourcemap} = await compile(this.scripts, true); const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code; this.scripts = code;
}catch (e) { } catch (e) {
console.log('编译失败', e); console.log('编译失败', e);
} }
} }
...@@ -354,19 +353,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -354,19 +353,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
} }
const unusedFields = ['design']; const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){ function deleteUnusedData(processes) {
if(process.sub){ for (let process of processes) {
for(let uuid in process.sub){ if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid]; let subProcess = process.sub[uuid];
for(let field of unusedFields){ for (let field of unusedFields) {
if(subProcess.hasOwnProperty(field)){ if (subProcess.hasOwnProperty(field)) {
delete subProcess[field]; delete subProcess[field];
} }
} }
} }
} }
if(process.metas && process.metas.length > 0){ if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas); deleteUnusedData(process.metas);
} }
} }
......
This diff is collapsed.
...@@ -62,10 +62,7 @@ ...@@ -62,10 +62,7 @@
} }
if (process.metas) { if (process.metas) {
for (let subProcess of process.metas) { for (let subProcess of process.metas) {
let hash = this.put(subProcess); this.deal(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
} }
} }
} }
...@@ -89,7 +86,9 @@ ...@@ -89,7 +86,9 @@
let scripts = ''; let scripts = '';
for (let hash in this.pool) { for (let hash in this.pool) {
let {script, ids} = this.pool[hash]; 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 += ` scripts += `
exports['${hash}'] = function(args, props, target, global, vm){ exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
...@@ -106,11 +105,11 @@ ${script} ...@@ -106,11 +105,11 @@ ${script}
this.pool = {}; this.pool = {};
} }
async compile(){ async compile() {
try { try {
const {code ,sourcemap} = await compile(this.scripts, true); const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code; this.scripts = code;
}catch (e) { } catch (e) {
console.log('编译失败', e); console.log('编译失败', e);
} }
} }
...@@ -354,19 +353,20 @@ ${scripts} ...@@ -354,19 +353,20 @@ ${scripts}
} }
const unusedFields = ['design']; const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){ function deleteUnusedData(processes) {
if(process.sub){ for (let process of processes) {
for(let uuid in process.sub){ if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid]; let subProcess = process.sub[uuid];
for(let field of unusedFields){ for (let field of unusedFields) {
if(subProcess.hasOwnProperty(field)){ if (subProcess.hasOwnProperty(field)) {
delete subProcess[field]; delete subProcess[field];
} }
} }
} }
} }
if(process.metas && process.metas.length > 0){ if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas); deleteUnusedData(process.metas);
} }
} }
......
This diff is collapsed.
...@@ -23,10 +23,7 @@ export default class ProcessManager { ...@@ -23,10 +23,7 @@ export default class ProcessManager {
} }
if (process.metas) { if (process.metas) {
for (let subProcess of process.metas) { for (let subProcess of process.metas) {
let hash = this.put(subProcess); this.deal(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
} }
} }
} }
...@@ -50,7 +47,9 @@ export default class ProcessManager { ...@@ -50,7 +47,9 @@ export default class ProcessManager {
let scripts = ''; let scripts = '';
for (let hash in this.pool) { for (let hash in this.pool) {
let {script, ids} = this.pool[hash]; 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 += ` scripts += `
exports['${hash}'] = function(args, props, target, global, vm){ exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
...@@ -67,11 +66,11 @@ ${script} ...@@ -67,11 +66,11 @@ ${script}
this.pool = {}; this.pool = {};
} }
async compile(){ async compile() {
try { try {
const {code ,sourcemap} = await compile(this.scripts, true); const {code, sourcemap} = await compile(this.scripts, true);
this.scripts = code; this.scripts = code;
}catch (e) { } catch (e) {
console.log('编译失败', e); console.log('编译失败', e);
} }
} }
......
...@@ -151,19 +151,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -151,19 +151,20 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
} }
const unusedFields = ['design']; const unusedFields = ['design'];
function deleteUnusedData(processes){
for(let process of processes){ function deleteUnusedData(processes) {
if(process.sub){ for (let process of processes) {
for(let uuid in process.sub){ if (process.sub) {
for (let uuid in process.sub) {
let subProcess = process.sub[uuid]; let subProcess = process.sub[uuid];
for(let field of unusedFields){ for (let field of unusedFields) {
if(subProcess.hasOwnProperty(field)){ if (subProcess.hasOwnProperty(field)) {
delete subProcess[field]; delete subProcess[field];
} }
} }
} }
} }
if(process.metas && process.metas.length > 0){ if (process.metas && process.metas.length > 0) {
deleteUnusedData(process.metas); 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