Skip to content

Commit 5da4427

Browse files
committed
feat: taro ui next build config
1 parent 70f23a5 commit 5da4427

File tree

7 files changed

+559
-82
lines changed

7 files changed

+559
-82
lines changed

config/webpack.analyze.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const merge = require('webpack-merge')
2+
const buildConfig = require('./webpack.config')
3+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
4+
.BundleAnalyzerPlugin
5+
6+
module.exports = merge(buildConfig, {
7+
plugins: [new BundleAnalyzerPlugin()]
8+
})

config/webpack.config.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const path = require('path')
2+
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
3+
const CopyWebpackPlugin = require('copy-webpack-plugin')
4+
5+
module.exports = {
6+
mode: 'production',
7+
devtool: 'source-map',
8+
entry: path.resolve(__dirname, '..', 'src/index.ts'),
9+
module: {
10+
rules: [
11+
{
12+
test: /\.ts(x?)$/,
13+
exclude: /node_modules/,
14+
use: [
15+
{
16+
loader: 'ts-loader'
17+
}
18+
]
19+
},
20+
{
21+
test: /\.js(x?)$/,
22+
exclude: /node_modules/,
23+
use: [
24+
{
25+
loader: 'babel-loader'
26+
}
27+
]
28+
},
29+
{
30+
enforce: 'pre',
31+
test: /\.js$/,
32+
loader: 'source-map-loader'
33+
}
34+
]
35+
},
36+
output: {
37+
filename: 'index.js',
38+
path: path.resolve(__dirname, '..', 'dist'),
39+
libraryTarget: 'umd',
40+
library: 'taro-ui'
41+
},
42+
plugins: [
43+
new CleanWebpackPlugin(),
44+
new CopyWebpackPlugin([
45+
{
46+
from: path.resolve(__dirname, '..', 'src', 'style'),
47+
to: path.resolve(__dirname, '..', 'dist', 'style')
48+
}
49+
])
50+
],
51+
resolve: {
52+
alias: {
53+
'taro-ui': path.resolve(__dirname, '..', 'src/index.ts')
54+
},
55+
extensions: ['.js', '.jsx', '.ts', '.tsx']
56+
},
57+
externals: {
58+
react: 'React',
59+
'react-dom': 'ReactDOM',
60+
'@tarojs/components': '@tarojs/components',
61+
'@tarojs/runtime': '@tarojs/runtime',
62+
'@tarojs/taro': '@tarojs/taro',
63+
'@tarojs/react': '@tarojs/react',
64+
// TODO: Taro 3 bug
65+
vue: 'Vue'
66+
}
67+
}

package.json

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "taro-ui",
3-
"version": "2.3.1",
3+
"version": "3.0.0-alpha.0",
44
"description": "UI KIT for Taro",
5+
"module": "dist/es/index.js",
56
"main": "dist/index.js",
6-
"main:h5": "dist/h5/index.js",
77
"sideEffects": [
88
"*.scss",
99
"*.css"
@@ -16,9 +16,7 @@
1616
],
1717
"files": [
1818
"dist",
19-
"types",
20-
"src/**/interface.ts",
21-
"src/**/*.d.ts"
19+
"types"
2220
],
2321
"author": "O2Team <aotu.io>",
2422
"homepage": "https://taro-ui.aotu.io",
@@ -210,7 +208,9 @@
210208
"build:h5": "taro build --type h5",
211209
"build:swan": "taro build --type swan",
212210
"build:alipay": "taro build --type alipay",
213-
"build:component": "cross-env TARO_BUILD_TYPE=component taro build --ui",
211+
"build:esmodule": "tsc --project tsconfig.build.json",
212+
"build:webpack": "webpack --config ./config/webpack.config.js",
213+
"build:component": "npm run build:webpack && npm run build:esmodule",
214214
"build:h5-static": "npm run build:h5 && node ./build/build-static",
215215
"build:doc": "npm run build:h5-static && node ./build/build-docs",
216216
"prepublishOnly": "npm run clean && npm run build:component",
@@ -219,14 +219,15 @@
219219
"lint:style-fix": "stylelint \"src/**/*.scss\" --syntax scss --fix",
220220
"test": "cross-env NODE_ENV=test && jest --coverage",
221221
"test:ci": "npm run build:h5 && npm run test",
222+
"test:analyze": "webpack --config ./config/webpack.analyze.js",
222223
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
223224
"clean": "rimraf .temp dist coverage"
224225
},
225226
"dependencies": {
226-
"bind-decorator": "^1.0.11",
227227
"classnames": "^2.2.6",
228228
"dayjs": "^1.7.7",
229-
"lodash": "^4.17.10"
229+
"lodash": "^4.17.10",
230+
"prop-types": "^15.7.2"
230231
},
231232
"devDependencies": {
232233
"@babel/core": "^7.0.0-rc.1",
@@ -253,6 +254,7 @@
253254
"@tarojs/webpack-runner": "^2.0.3",
254255
"@types/classnames": "^2.2.9",
255256
"@types/react": "^16.9.23",
257+
"@types/react-dom": "^16.9.5",
256258
"@types/webpack-env": "^1.13.6",
257259
"@typescript-eslint/eslint-plugin": "^2.10.0",
258260
"@typescript-eslint/parser": "^2.10.0",
@@ -309,28 +311,35 @@
309311
"postcss": "^7.0.2",
310312
"postcss-loader": "^3.0.0",
311313
"prettier": "^1.19.1",
312-
"prop-types": "^15.7.2",
313314
"qrcode.react": "^1.0.0",
314315
"react": "^16.13.0",
316+
"react-dom": "^16.13.0",
315317
"react-markdown-loader": "^1.1.14",
316318
"react-router-dom": "^5.1.2",
317319
"regenerator-runtime": "^0.13.3",
318320
"rimraf": "^3.0.2",
319321
"sass-loader": "^8.0.0",
320322
"simulant": "^0.2.2",
323+
"source-map-loader": "^0.2.4",
321324
"stylelint": "^13.0.0",
322325
"stylelint-config-standard": "^20.0.0",
323326
"stylelint-scss": "^3.2.0",
324327
"terser": "^4.4.2",
325-
"typescript": "^3.0.1",
328+
"ts-loader": "^6.2.2",
329+
"typescript": "^3.8.3",
326330
"url-loader": "^3.0.0",
327-
"webpack": "^4.16.5",
331+
"vue": "^2.6.11",
332+
"webpack": "^4.42.1",
333+
"webpack-bundle-analyzer": "^3.6.1",
334+
"webpack-cli": "^3.3.11",
328335
"webpack-dev-server": "^3.1.5",
329336
"webpack-merge": "^4.1.3",
330337
"yaml-loader": "^0.5.0"
331338
},
332339
"peerDependencies": {
333-
"prop-types": ">=15.7.2",
334-
"react": ">=16.13.0"
340+
"@tarojs/components": ">=3.0.0-beta.1",
341+
"@tarojs/react": ">=3.0.0-beta.1",
342+
"react": ">=16.13.0",
343+
"react-dom": ">=16.13.0"
335344
}
336345
}

tsconfig.base.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"experimentalDecorators": true,
5+
"jsx": "react",
6+
"jsxFactory": "React.createElement",
7+
"moduleResolution": "node",
8+
"noImplicitAny": false,
9+
"noUnusedLocals": true,
10+
"noUnusedParameters": true,
11+
"preserveConstEnums": true,
12+
"sourceMap": true,
13+
"strictNullChecks": true,
14+
"resolveJsonModule": true
15+
},
16+
"compileOnSave": false
17+
}

tsconfig.build.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "./tsconfig.base",
3+
"compilerOptions": {
4+
"skipLibCheck": true,
5+
"target": "es2017",
6+
"module": "es6",
7+
"baseUrl": ".",
8+
"outDir": "./dist/es"
9+
},
10+
"include": [
11+
"src/common/*",
12+
"src/components/*",
13+
"src/index.ts"
14+
],
15+
"exclude": [
16+
"node_modules"
17+
]
18+
}

tsconfig.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
{
2+
"extends": "./tsconfig.base",
23
"compilerOptions": {
34
"target": "es2017",
45
"module": "commonjs",
5-
"preserveConstEnums": true,
6-
"moduleResolution": "node",
7-
"experimentalDecorators": true,
8-
"jsxFactory": "React.createElement",
9-
"noImplicitAny": false,
10-
"allowSyntheticDefaultImports": true,
11-
"outDir": "dist",
12-
"noUnusedLocals": true,
13-
"noUnusedParameters": true,
14-
"strictNullChecks": true,
15-
"sourceMap": true,
166
"baseUrl": ".",
17-
"rootDir": ".",
18-
"jsx": "preserve",
197
"typeRoots": [
208
"node_modules/@types",
219
"global.d.ts",
2210
"types"
2311
],
24-
"resolveJsonModule": true,
2512
"paths": {
26-
"taro-ui": [ "src/ui.ts" ]
13+
"taro-ui": [
14+
"src/index.ts"
15+
]
2716
}
28-
},
29-
"compileOnSave": false
17+
}
3018
}

0 commit comments

Comments
 (0)