Skip to content

Commit

Permalink
* [html5] fixed rollup build
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Sep 27, 2016
1 parent 4a1c208 commit 03f241c
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 77 deletions.
29 changes: 29 additions & 0 deletions build/rollup.browser.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { rollup } from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import json from 'rollup-plugin-json'
import buble from 'rollup-plugin-buble'
import postcss from 'rollup-plugin-postcss'

const banner = `var global = this
var process = { env: {}};
`

export default {
entry: './html5/render/browser/index.js',
dest: './dist/browser.js',
banner,
format: 'umd',
moduleName: 'weex',
plugins: [
postcss(),
nodeResolve({
jsnext: true,
main: true,
browser: true
}),
commonjs(),
json(),
buble()
]
}
4 changes: 2 additions & 2 deletions html5/frameworks/legacy/vm/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ function setClassStyle (el, css, classList) {
for (let i = 0; i < length; i++) {
const style = css[classList[i]]
if (style) {
for (const key in style) {
Object.keys(style).forEach((key) => {
classStyle[key] = style[key]
}
})
}
}
el.setClassStyle(classStyle)
Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/base/component/flexbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ export default {
this.node.style.justifyContent = value
}
}
}
};
2 changes: 1 addition & 1 deletion html5/render/browser/base/component/lazyLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict'

require('lazyimg')
import 'lazyimg'

let lazyloadTimer

Expand Down
58 changes: 27 additions & 31 deletions html5/render/browser/extend/api/animation/lib.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
'use strict'

module.exports = {

/**
* config:
* - styles
* - duration [Number] milliseconds(ms)
* - timingFunction [string]
* - dealy [Number] milliseconds(ms)
*/
transitionOnce: function (comp, config, callback) {
const styles = config.styles || {}
const duration = config.duration || 1000 // ms
const timingFunction = config.timingFunction || 'ease'
const delay = config.delay || 0 // ms
const transitionValue = 'all ' + duration + 'ms '
+ timingFunction + ' ' + delay + 'ms'
const dom = comp.node
const transitionEndHandler = function (e) {
e.stopPropagation()
dom.removeEventListener('webkitTransitionEnd', transitionEndHandler)
dom.removeEventListener('transitionend', transitionEndHandler)
dom.style.transition = ''
dom.style.webkitTransition = ''
callback()
}
dom.style.transition = transitionValue
dom.style.webkitTransition = transitionValue
dom.addEventListener('webkitTransitionEnd', transitionEndHandler)
dom.addEventListener('transitionend', transitionEndHandler)
comp.updateStyle(styles)
/**
* config:
* - styles
* - duration [Number] milliseconds(ms)
* - timingFunction [string]
* - dealy [Number] milliseconds(ms)
*/
export function transitionOnce (comp, config, callback) {
const styles = config.styles || {}
const duration = config.duration || 1000 // ms
const timingFunction = config.timingFunction || 'ease'
const delay = config.delay || 0 // ms
const transitionValue = 'all ' + duration + 'ms '
+ timingFunction + ' ' + delay + 'ms'
const dom = comp.node
const transitionEndHandler = function (e) {
e.stopPropagation()
dom.removeEventListener('webkitTransitionEnd', transitionEndHandler)
dom.removeEventListener('transitionend', transitionEndHandler)
dom.style.transition = ''
dom.style.webkitTransition = ''
callback()
}

dom.style.transition = transitionValue
dom.style.webkitTransition = transitionValue
dom.addEventListener('webkitTransitionEnd', transitionEndHandler)
dom.addEventListener('transitionend', transitionEndHandler)
comp.updateStyle(styles)
}
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/countdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const Kountdown = require('kountdown')
const Kountdown = import 'kountdown'

const FORMATTER_REGEXP = /(\\)?(dd*|hh?|mm?|ss?)/gi

Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/indicator/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

require('./indicator.css')
import './indicator.css'

const DEFAULT_ITEM_COLOR = '#999'
const DEFAULT_ITEM_SELECTED_COLOR = '#0000ff'
Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/scrollable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export default {
Weex.install(refresh)
Weex.install(loading)
}
}
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */

require('./motion')
import './motion'

var doc = window.document
var ua = window.navigator.userAgent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

'use strict'

require('./scrollable.css')
require('./scroll')
import './scrollable.css'
import './scroll'

// lib.scroll events:
// - scrollstart
Expand Down
8 changes: 4 additions & 4 deletions html5/render/browser/extend/components/slider/carrousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
'use strict'

// require('./gesture')
require('cubicbezier')
require('animationjs')
require('./carrousel.css')
import 'cubicbezier'
import 'animationjs'
import './carrousel.css'

var doc = window.document
var ua = window.navigator.userAgent
Expand All @@ -14,7 +14,7 @@ var IEMobile = !!ua.match(/IEMobile/i)
var cssPrefix = Firefox ? '-moz-' : IEMobile ? '-ms-' : '-webkit-'
var stylePrefix = Firefox ? 'Moz' : IEMobile ? 'ms' : 'webkit'

var timer = require('./timer')
import * as timer from './timer'
var setTimeout = timer.setTimeout
var clearTimeout = timer.clearTimeout

Expand Down
48 changes: 21 additions & 27 deletions html5/render/browser/extend/components/slider/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,26 @@ function _getGlobalId() {
return _globalId
}

var timer = {

setTimeout: function (cb, ms) {
var id = _getGlobalId()
var start = Date.now()
_idMap[id] = raf(function loop() {
if (!_idMap[id] && _idMap[id] !== 0) {
return
}
var ind = Date.now() - start
if (ind < ms) {
_idMap[id] = raf(loop)
} else {
delete _idMap[id]
cb()
}
})
return id
},

clearTimeout: function (id) {
var tid = _idMap[id]
tid && caf(tid)
delete _idMap[id]
}

export function setTimeout (cb, ms) {
var id = _getGlobalId()
var start = Date.now()
_idMap[id] = raf(function loop() {
if (!_idMap[id] && _idMap[id] !== 0) {
return
}
var ind = Date.now() - start
if (ind < ms) {
_idMap[id] = raf(loop)
} else {
delete _idMap[id]
cb()
}
})
return id
}

module.exports = timer
export function clearTimeout (id) {
var tid = _idMap[id]
tid && caf(tid)
delete _idMap[id]
}
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/spinner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict'

require('./spinner.css')
import './spinner.css'

let loopArray, getRgb

Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/switch/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

require('./switch.css')
import './switch.css'

const defaults = {
color: '#64bd63',
Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/tabheader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// TODO: refactor this scss code since this is strongly
// dependent on lib.flexible other than the value of
// scale.
require('./tabheader.css')
import './tabheader.css'

function initFoldBtn (tabheader) {
const node = tabheader.node
Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/extend/components/video/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

require('./video.css')
import './video.css'

function getProto (Weex) {
const Atomic = Weex.Atomic
Expand Down
2 changes: 1 addition & 1 deletion html5/render/browser/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import Weex from './render'
import Weex from './render/index'

/**
* install components and APIs
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"scripts": {
"postinstall": "bash ./bin/install-hooks.sh",
"build:new": "rollup -c build/rollup.config.js",
"build:browser:new": "rollup -w -c build/rollup.browser.config.js",
"build:config": "node build/config.frameworks.js",
"build:browser": "webpack --config build/webpack.browser.config.js",
"build:common": "webpack --config build/webpack.common.config.js",
Expand Down Expand Up @@ -102,6 +103,7 @@
"rollup-plugin-commonjs": "^5.0.4",
"rollup-plugin-json": "^2.0.2",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-postcss": "^0.2.0",
"rollup-watch": "^2.5.0",
"selenium-server": "2.53.1",
"serve": "^1.4.0",
Expand Down

0 comments on commit 03f241c

Please sign in to comment.