Skip to content

Commit

Permalink
fix(mobx-common mobx-h5): 增加编译代码 fix #2017
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Jan 24, 2019
1 parent fd57e13 commit 82ffd4a
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 24 deletions.
2 changes: 2 additions & 0 deletions packages/taro-mobx-common/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = require('./dist/index.js')
module.exports.default = module.exports
10 changes: 7 additions & 3 deletions packages/taro-mobx-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"main": "dist/index.js",
"main": "index.js",
"module": "dist/index.esm.js",
"files": [
"dist"
"dist",
"index.js"
],
"scripts": {
"build": "rollup -c --environment TARGET:umd",
Expand All @@ -25,6 +27,8 @@
"mobx": "4.8.0"
},
"devDependencies": {
"rimraf": "^2.6.2"
"rimraf": "^2.6.2",
"rollup": "1.1.0",
"rollup-plugin-babel": "4.0.3"
}
}
22 changes: 14 additions & 8 deletions packages/taro-mobx-common/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import babel from 'rollup-plugin-babel'

export default {
input: 'src/index.js',
output: {
sourcemap: false,
output: [{
name: '@tarojs/mobx-common',
sourcemap: false,
exports: 'named',
format: 'umd',
format: 'cjs',
file: 'dist/index.js'
},
}, {
sourcemap: false,
exports: 'named',
format: 'esm',
file: 'dist/index.esm.js'
}],
external: ['mobx'],
plugins: [
babel({
presets: [
Expand All @@ -17,8 +23,8 @@ export default {
}]
],
plugins: [
"@babel/plugin-proposal-class-properties"
'@babel/plugin-proposal-class-properties'
]
}),
].filter(Boolean)
}
})
]
}
13 changes: 2 additions & 11 deletions packages/taro-mobx-h5/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
import { Component } from '@tarojs/taro-h5'
import { createElement } from 'nervjs'
import { inject as originInject } from '@tarojs/mobx-common'

export function inject () {
return originInject(...arguments, { Component, createElement })
}

export { observer } from '@tarojs/mobx-common'

export { default as Provider } from './Provider'
module.exports = require('./dist/index.js')
module.exports.default = module.exports
16 changes: 14 additions & 2 deletions packages/taro-mobx-h5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"scripts": {
"build": "rollup -c rollup.config.js",
"dev": "rollup -c rollup.config.js --watch"
},
"main": "index.js",
"module": "dist/index.esm.js",
"files": [
"index.js",
"Provider.js"
"dist",
"index.js"
],
"peerDependencies": {
"nervjs": "^1.3.0"
},
"dependencies": {
"@tarojs/mobx-common": "1.2.8",
"@tarojs/taro-h5": "1.1.7"
},
"devDependencies": {
"lodash": "4.17.11",
"rollup": "1.1.0",
"rollup-plugin-babel": "4.0.3",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-node-resolve": "^4.0.0"
}
}
52 changes: 52 additions & 0 deletions packages/taro-mobx-h5/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve'

export default {
input: 'src/index.js',
external: ['nervjs', '@tarojs/taro-h5', 'mobx'],
output: [{
file: 'dist/index.js',
format: 'cjs',
sourcemap: false,
exports: 'named'
}, {
file: 'dist/index.esm.js',
format: 'esm',
sourcemap: false,
exports: 'named'
}],
plugins: [
resolve({
preferBuiltins: false
}),
babel({
babelrc: false,
presets: [
['@babel/preset-env', {
modules: false
}]
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-transform-react-jsx', {
'pragma': 'Nerv.createElement'
}]
]
}),
commonjs({
include: ['../taro-mobx-common/index.js'],
namedExports: {
'../taro-mobx-common/index.js': [
'observer', 'inject', 'setStore'
]
}
})
],
watch: {
include: 'src/**',
clearScreen: true
}
}
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/taro-mobx-h5/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@tarojs/taro-h5'
import { createElement } from 'nervjs'
import { inject as originInject } from '@tarojs/mobx-common'

export function inject () {
return originInject(...arguments, { Component, createElement })
}

export { observer } from '@tarojs/mobx-common'

export { default as Provider } from './Provider'

0 comments on commit 82ffd4a

Please sign in to comment.