Skip to content

Commit

Permalink
feat(components): 调整了components的打包策略
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Jan 23, 2019
1 parent 4d77930 commit c85f0f4
Show file tree
Hide file tree
Showing 35 changed files with 93 additions and 62 deletions.
10 changes: 8 additions & 2 deletions packages/taro-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"name": "@tarojs/components",
"version": "1.2.8",
"description": "",
"main": "./dist/index.js",
"main": "src/index.js",
"typings": "./types/index.d.ts",
"files": [
"src/components",
"src",
"dist",
"utils",
"types"
],
"sideEffects": false,
"scripts": {
"local-dev": "webpack-dev-server --config webpack.config.js --env development",
"dev": "webpack --config webpack.prod.config.js --watch",
Expand Down Expand Up @@ -40,10 +41,15 @@
"weui": "^1.1.2"
},
"devDependencies": {
"@babel/core": "^7.1.5",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"@tarojs/taro-h5": "1.2.8",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^22.4.4",
"babel-loader": "^8.0.5",
"jest": "^22.4.4",
"nerv-test-utils": "^1.2.18",
"swiper": "^4.4.2",
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/audio/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import './style/index.scss'

Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/block/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
export default class Block extends Nerv.Component {
constructor (props) {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/button/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/camera/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'

class Camera extends Nerv.Component {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'

class CheckboxGroup extends Nerv.Component {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/checkbox/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/form/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'

class Form extends Nerv.Component {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/icon/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import classNames from 'classnames'
import omit from 'omit.js'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/image/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import classNames from 'classnames'
import './style/index.scss'
Expand Down
29 changes: 0 additions & 29 deletions packages/taro-components/src/components/index.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/taro-components/src/components/input/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/label/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'

class Label extends Nerv.Component {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/src/components/picker/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getMaxDay (year, month) {
}
return 31
}
module.exports = {
export {
verifyDate,
getMaxDay
}
3 changes: 2 additions & 1 deletion packages/taro-components/src/components/picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
* @property {Boolean} disabled 是否禁用
* @property {EventHandle} onCancel 取消选择或点遮罩层收起 picker 时触发
*/
import 'weui'
import Nerv from 'nervjs'
import PickerGroup from './picker-group'
import classNames from 'classnames'
import { TOP, LINE_HEIGHT } from './constant'
import dateHandle from './date'
import * as dateHandle from './date'
import './style/index.scss'

// todos:
Expand Down
15 changes: 8 additions & 7 deletions packages/taro-components/src/components/progress/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'weui'
import Nerv from 'nervjs'
import classNames from 'classnames'
import _ from '../../../utils/parse-type'
import { isNumber, isBoolean, isString } from '../../utils/parse-type'

/**
* props 类型检测
Expand All @@ -22,15 +23,15 @@ function parseType (props) {
const throwErrorMsg = type => {
throw new TypeError(type)
}
if (showInfo) _.isBoolean(showInfo) ? '' : throwErrorMsg('showInfo')
if (active) _.isBoolean(active) ? '' : throwErrorMsg('active')
if (showInfo) isBoolean(showInfo) ? '' : throwErrorMsg('showInfo')
if (active) isBoolean(active) ? '' : throwErrorMsg('active')

if (percent) _.isNumber(percent) ? '' : throwErrorMsg('percent')
if (strokeWidth) _.isNumber(strokeWidth) ? '' : throwErrorMsg('strokeWidth')
if (percent) isNumber(percent) ? '' : throwErrorMsg('percent')
if (strokeWidth) isNumber(strokeWidth) ? '' : throwErrorMsg('strokeWidth')

if (activeColor) _.isString(activeColor) ? '' : throwErrorMsg('activeColor')
if (activeColor) isString(activeColor) ? '' : throwErrorMsg('activeColor')
if (backgroundColor) {
_.isString(backgroundColor) ? '' : throwErrorMsg('backgroundColor')
isString(backgroundColor) ? '' : throwErrorMsg('backgroundColor')
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/radio/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
5 changes: 3 additions & 2 deletions packages/taro-components/src/components/radio/radio-group.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'weui'
import Nerv from 'nervjs'
import _ from '../../../utils/parse-type'
import { isNumber } from '../../utils/parse-type'
class RadioGroup extends Nerv.Component {
constructor () {
super(...arguments)
Expand All @@ -15,7 +16,7 @@ class RadioGroup extends Nerv.Component {
let checkValue
let _value = this.radioValue.map((item, idx) => {
let curValue = item.value
if (_.isNumber(item.value)) curValue = item.value.toString()
if (isNumber(item.value)) curValue = item.value.toString()
if (e.target.value === curValue) {
checkValue = item.value
return {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
27 changes: 14 additions & 13 deletions packages/taro-components/src/components/slider/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'weui'
import Nerv from 'nervjs'
import _ from '../../../utils/parse-type'
import { isNumber, isBoolean, isString, isFunction } from '../../utils/parse-type'
import classNames from 'classnames'

/**
Expand Down Expand Up @@ -28,24 +29,24 @@ function parseType (props) {
throw new TypeError(type)
}

if (min) _.isNumber(min) ? '' : throwErrorMsg('min')
if (max) _.isNumber(max) ? '' : throwErrorMsg('max')
if (step) _.isNumber(step) ? '' : throwErrorMsg('step')
if (value) _.isNumber(value) ? '' : throwErrorMsg('value')
if (blockSize) _.isNumber(blockSize) ? '' : throwErrorMsg('blockSize')
if (min) isNumber(min) ? '' : throwErrorMsg('min')
if (max) isNumber(max) ? '' : throwErrorMsg('max')
if (step) isNumber(step) ? '' : throwErrorMsg('step')
if (value) isNumber(value) ? '' : throwErrorMsg('value')
if (blockSize) isNumber(blockSize) ? '' : throwErrorMsg('blockSize')

if (disabled) _.isBoolean(disabled) ? '' : throwErrorMsg('disabled')
if (showValue) _.isBoolean(showValue) ? '' : throwErrorMsg('showValue')
if (disabled) isBoolean(disabled) ? '' : throwErrorMsg('disabled')
if (showValue) isBoolean(showValue) ? '' : throwErrorMsg('showValue')

if (backgroundColor) {
_.isString(backgroundColor) ? '' : throwErrorMsg('backgroundColor')
isString(backgroundColor) ? '' : throwErrorMsg('backgroundColor')
}

if (activeColor) _.isString(activeColor) ? '' : throwErrorMsg('activeColor')
if (blockColor) _.isString(blockColor) ? '' : throwErrorMsg('blockColor')
if (activeColor) isString(activeColor) ? '' : throwErrorMsg('activeColor')
if (blockColor) isString(blockColor) ? '' : throwErrorMsg('blockColor')

if (onChange) _.isFunction(onChange) ? '' : throwErrorMsg('onChange')
if (onChanging) _.isFunction(onChanging) ? '' : throwErrorMsg('onChanging')
if (onChange) isFunction(onChange) ? '' : throwErrorMsg('onChange')
if (onChanging) isFunction(onChanging) ? '' : throwErrorMsg('onChanging')
}

class Slider extends Nerv.Component {
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-components/src/components/swiper/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'weui'
import Nerv from 'nervjs'
import classNames from 'classnames'
import Swipers from 'swiper/dist/js/swiper.min.js'
import * as Swipers from 'swiper'

import 'swiper/dist/css/swiper.min.css'
import './style/index.scss'
Expand Down
5 changes: 2 additions & 3 deletions packages/taro-components/src/components/swiper/swiper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Nerv from 'nervjs'
import classNames from 'classnames'
import './style/swiper.scss'
import _ from '../../../utils/parse-type'
import { isNumber } from '../../../utils/parse-type'

/**
* props 类型检测
Expand All @@ -18,7 +18,7 @@ function parseType (props) {
throw new TypeError(type + ' must be number')
}

if (current) _.isNumber(current) ? '' : throwErrorMsg('current')
if (current) isNumber(current) ? '' : throwErrorMsg('current')
}
class Swiper extends Nerv.Component {
constructor (props) {
Expand Down Expand Up @@ -217,7 +217,6 @@ class Swiper extends Nerv.Component {
? this.state.wrapperWidth - this.state.containerWidth
: this.state.wrapperHeight - this.state.containerHeight
let currentIndex = this.state.currentIndex
let ogIndex = currentIndex
if (translate > 0) {
// start
translate = 0
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/switch/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import classNames from 'classnames'
import View from '../view'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/tabbar/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Taro from '@tarojs/taro-h5'
import Nerv from 'nervjs'
import classNames from 'classnames'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/tabbar/panel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import classNames from 'classnames'
import View from '../view'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/text/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/textarea/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
class Textarea extends Nerv.Component {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/video/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import './style/index.scss'

Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/src/components/view/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'weui'
import Nerv from 'nervjs'
import omit from 'omit.js'
import classNames from 'classnames'
Expand Down
28 changes: 28 additions & 0 deletions packages/taro-components/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export { default as View } from './components/view'
export { default as Block } from './components/block'
export { default as Image } from './components/image'
export { default as Text } from './components/text'
export { default as Switch } from './components/switch'
export { default as Button } from './components/button'
export { default as Icon } from './components/icon'
export { default as Radio } from './components/radio'
export { default as Input } from './components/input'
export { default as ScrollView } from './components/scroll-view'
export { Swiper, SwiperItem } from './components/swiper'
export { default as Checkbox } from './components/checkbox'
export { default as Picker } from './components/picker'
export { default as Label } from './components/label'
export { default as Textarea } from './components/textarea'
export { default as Slider } from './components/slider'
export { default as Video } from './components/video'
export { default as Audio } from './components/audio'
export { default as Camera } from './components/camera'
export { default as Progress } from './components/progress'
export { default as RichText } from './components/rich-text'
export { default as Form } from './components/form'
export { default as RadioGroup } from './components/radio/radio-group'
export { default as CheckboxGroup } from './components/checkbox/checkbox-group'
export { default as Tabbar } from './components/tabbar'
export { default as TabbarContainer } from './components/tabbar/container'
export { default as TabbarPanel } from './components/tabbar/panel'
// export { default as Navigator } from './components/navigator'
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function isFunction (value) {

/** lodash EOF */

export default {
export {
isBoolean,
isNumber,
isString,
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components/webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')

module.exports = {
entry: './src/components/index.js',
entry: './src/index.js',
resolve: {
extensions: ['.js', '.scss', '.css']
},
Expand All @@ -27,7 +27,7 @@ module.exports = {
options: {
'presets': [
[
'@babel/env',
'@babel/preset-env',
{
'spec': true,
'useBuiltIns': false
Expand Down

0 comments on commit c85f0f4

Please sign in to comment.