* [html5] build for esm.

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/7e2d4ef9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/7e2d4ef9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/7e2d4ef9

Branch: refs/heads/0.16-dev
Commit: 7e2d4ef9fe74638e788854e22ecc28932e3f72ae
Parents: a105b22
Author: MrRaindrop <tekk...@gmail.com>
Authored: Sat Aug 12 15:15:09 2017 +0800
Committer: MrRaindrop <tekk...@gmail.com>
Committed: Mon Aug 21 11:15:10 2017 +0800

----------------------------------------------------------------------
 build/build.js                             | 17 ++++++++++++++---
 build/config.js                            | 12 ++++++++++--
 packages/weex-vue-render/src/index.core.js | 17 +++++++++++++----
 packages/weex-vue-render/src/index.js      | 17 +++++++++++++----
 4 files changed, 50 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e2d4ef9/build/build.js
----------------------------------------------------------------------
diff --git a/build/build.js b/build/build.js
index 9ddf8a1..02f1e8c 100644
--- a/build/build.js
+++ b/build/build.js
@@ -207,9 +207,20 @@ function build (name) {
   else {
     console.log(`\n => start to build ${name} (${pkgName})\n`)
     return new Promise((resolve, reject) => {
-      runRollup(config).then(() => {
-        runRollup(minifyConfig).then(() => {
-          zip(minifyConfig.dest, resolve)
+      return runRollup(config).then(() => {
+        let p = Promise.resolve()
+        if (name === 'vue') {
+          const esConfig = getConfig(pkgName, false, {
+            format: 'es',
+            _isProd: true
+          })
+          esConfig.dest = esConfig.dest.replace(/\.js$/, '.es.js')
+          p = runRollup(esConfig)
+        }
+        return p.then(function () {
+          return runRollup(minifyConfig).then(() => {
+            zip(minifyConfig.dest, resolve)
+          })
         })
       })
     })

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e2d4ef9/build/config.js
----------------------------------------------------------------------
diff --git a/build/config.js b/build/config.js
index a863919..3efccb2 100644
--- a/build/config.js
+++ b/build/config.js
@@ -157,8 +157,16 @@ console.log('START WEEX VUE RENDER CORE: 
${subversion['vue-render']}, Build ${no
   }
 }
 
-function getConfig (name, minify) {
+function getConfig (name, minify, params) {
   const opt = configs[name]
+  let isProd
+  if (params) {
+    isProd = params._isProd
+    delete params._isProd
+    for (const k in params) {
+      opt[k] = params[k]
+    }
+  }
   const config = {
     moduleName: opt.moduleName,
     entry: opt.entry,
@@ -169,7 +177,7 @@ function getConfig (name, minify) {
       json(),
       replace({
         'process.env.VIEWPORT_WIDTH': 750,
-        'process.env.NODE_ENV': JSON.stringify(minify ? 'production' : 
'development'),
+        'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : minify 
? 'production' : 'development'),
         'process.env.VUE_ENV': JSON.stringify('WEEX'),
         'process.env.NODE_DEBUG': false
       }),

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e2d4ef9/packages/weex-vue-render/src/index.core.js
----------------------------------------------------------------------
diff --git a/packages/weex-vue-render/src/index.core.js 
b/packages/weex-vue-render/src/index.core.js
index 3bc8edb..dc49562 100644
--- a/packages/weex-vue-render/src/index.core.js
+++ b/packages/weex-vue-render/src/index.core.js
@@ -5,9 +5,18 @@ import text from '../../../html5/render/vue/components/text'
 import image from '../../../html5/render/vue/components/image'
 import scrollable from '../../../html5/render/vue/components/scrollable'
 
-weex.install(div)
-weex.install(text)
-weex.install(image)
-weex.install(scrollable)
+const preInit = weex.init
+
+weex.init = function () {
+  preInit.apply(weex, arguments)
+  weex.install(div)
+  weex.install(text)
+  weex.install(image)
+  weex.install(scrollable)
+}
+
+if (global.Vue) {
+  weex.init(global.Vue)
+}
 
 export default weex

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e2d4ef9/packages/weex-vue-render/src/index.js
----------------------------------------------------------------------
diff --git a/packages/weex-vue-render/src/index.js 
b/packages/weex-vue-render/src/index.js
index efbbaeb..178da4c 100644
--- a/packages/weex-vue-render/src/index.js
+++ b/packages/weex-vue-render/src/index.js
@@ -3,10 +3,19 @@ import weex from '../../../html5/render/vue'
 import components from '../../../html5/render/vue/components'
 import modules from '../../../html5/render/vue/modules'
 
-const plugins = components.concat(modules)
+const preInit = weex.init
 
-plugins.forEach(function (plugin) {
-  weex.install(plugin)
-})
+weex.init = function () {
+  preInit.apply(weex, arguments)
+  const plugins = components.concat(modules)
+
+  plugins.forEach(function (plugin) {
+    weex.install(plugin)
+  })
+}
+
+if (global.Vue) {
+  weex.init(global.Vue)
+}
 
 export default weex

Reply via email to