@@ -22,7 +22,6 @@ export function init (cfg) {
2222 renderer . Document = cfg . Document
2323 renderer . Element = cfg . Element
2424 renderer . Comment = cfg . Comment
25- renderer . compileBundle = cfg . compileBundle
2625}
2726
2827/**
@@ -35,7 +34,6 @@ export function reset () {
3534 delete renderer . Document
3635 delete renderer . Element
3736 delete renderer . Comment
38- delete renderer . compileBundle
3937}
4038
4139/**
@@ -96,11 +94,7 @@ export function createInstance (
9694
9795 appCode = `(function(global){ \n${ appCode } \n })(Object.create(this))`
9896
99- if ( ! callFunctionNative ( instanceVars , appCode ) ) {
100- // If failed to compile functionBody on native side,
101- // fallback to 'callFunction()'.
102- callFunction ( instanceVars , appCode )
103- }
97+ callFunction ( instanceVars , appCode )
10498
10599 // Send `createFinish` signal to native.
106100 instance . document . taskCenter . send ( 'dom' , { action : 'createFinish' } , [ ] )
@@ -430,55 +424,3 @@ function callFunction (globalObjects, body) {
430424 const result = new Function ( ...globalKeys )
431425 return result ( ...globalValues )
432426}
433-
434- /**
435- * Call a new function generated on the V8 native side.
436- *
437- * This function helps speed up bundle compiling. Normally, the V8
438- * engine needs to download, parse, and compile a bundle on every
439- * visit. If 'compileBundle()' is available on native side,
440- * the downloding, parsing, and compiling steps would be skipped.
441- * @param {object } globalObjects
442- * @param {string } body
443- * @return {boolean }
444- */
445- function callFunctionNative ( globalObjects , body ) {
446- if ( typeof renderer . compileBundle !== 'function' ) {
447- return false
448- }
449-
450- let fn = void 0
451- let isNativeCompileOk = false
452- let script = '(function ('
453- const globalKeys = [ ]
454- const globalValues = [ ]
455- for ( const key in globalObjects ) {
456- globalKeys . push ( key )
457- globalValues . push ( globalObjects [ key ] )
458- }
459- for ( let i = 0 ; i < globalKeys . length - 1 ; ++ i ) {
460- script += globalKeys [ i ]
461- script += ','
462- }
463- script += globalKeys [ globalKeys . length - 1 ]
464- script += ') {'
465- script += body
466- script += '} )'
467-
468- try {
469- const weex = globalObjects . weex || { }
470- const config = weex . config || { }
471- fn = renderer . compileBundle ( script ,
472- config . bundleUrl ,
473- config . bundleDigest ,
474- config . codeCachePath )
475- if ( fn && typeof fn === 'function' ) {
476- fn ( ...globalValues )
477- isNativeCompileOk = true
478- }
479- } catch ( e ) {
480- console . error ( e )
481- }
482-
483- return isNativeCompileOk
484- }
0 commit comments