Skip to content

Commit aa69810

Browse files
author
wangmengjun
committed
Merge branch '1.0.4' into 'master'
1.0.4 See merge request beatles-component/new-open-chameleon-sets!125
2 parents 05420a0 + 43814b0 commit aa69810

File tree

59 files changed

+1397
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1397
-502
lines changed

.eslintrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
root:true,
3+
env: {
4+
browser: true,
5+
es6: true,
6+
},
7+
extends: [
8+
'standard',
9+
],
10+
globals: {
11+
Atomics: 'readonly',
12+
SharedArrayBuffer: 'readonly'
13+
},
14+
parserOptions: {
15+
ecmaVersion: 2018,
16+
parser:'babel-eslint'
17+
},
18+
rules: {
19+
'semi':[2,'always']
20+
}
21+
}

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
## [1.0.4]
2+
- 支持mock文件更新实时重新编译
3+
- 支持分包页面依赖的js更新,打包结果重新编译
4+
- 优化dev模式内存占用
5+
- 修复分包模式下组件js抽离的时候重复对页面js抽离的操作
6+
7+
## [1.0.4-alpha.2]
8+
- 扩展新端增加内置环境变量 NODE_ENV
9+
- 支持模板多态语法
10+
111
## [1.0.4-alpha.1]
212

313
- 解决分包内组件js分包不彻底,优化包体积40%左右
414
- 支持原生小程序组件的导入也是函数式的
515
- 支持公用样式以文件的形式 @import
6-
- 支持模板多态语法
716

817
## [1.0.3]
918

commitlint.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//git commit -m"feat: 新增功能"
2+
//规范团队commit规范,参考commitlint-angular https://www.npmjs.com/package/@commitlint/config-angular
3+
module.exports = {
4+
extends: ['@commitlint/config-angular'],
5+
rules: {
6+
'type-enum': [2, 'always', [
7+
"feat", "fix", "docs", "style", "refactor", "test", "chore", "revert"
8+
]],
9+
'subject-full-stop': [0, 'never'],
10+
'subject-case': [0, 'never'],
11+
}
12+
};
13+
14+
//[build, ci, docs, feat, fix, perf, refactor, revert, style, test]
15+
16+
17+

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "1.0.4-alpha.1",
5+
"version": "1.0.4",
66
"command": {
77
"publish": {
88
"allowBranch": "master",

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,26 @@
1111
"author": "Chameleon-Team",
1212
"license": "Apache 2.0",
1313
"devDependencies": {
14+
"@commitlint/cli": "^8.2.0",
15+
"@commitlint/config-angular": "^8.2.0",
16+
"babel-eslint": "^10.0.3",
17+
"eslint": "^6.8.0",
18+
"eslint-config-standard": "^14.1.0",
19+
"eslint-plugin-import": "^2.19.1",
20+
"eslint-plugin-node": "^11.0.0",
21+
"eslint-plugin-promise": "^4.2.1",
22+
"eslint-plugin-standard": "^4.0.1",
23+
"eslint-plugin-vue": "^6.0.2",
24+
"husky": "^3.1.0",
1425
"istanbul": "^0.4.5",
15-
"lerna": "^3.5.1"
26+
"lerna": "^3.5.1",
27+
"lint-staged": "^9.5.0"
28+
},
29+
"husky": {
30+
"hooks": {
31+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
32+
"pre-commit": "lint-staged"
33+
}
1634
},
1735
"dependencies": {
1836
"babel-core": "^6.26.3",
@@ -23,5 +41,8 @@
2341
"mocha": "*",
2442
"nyc": "*",
2543
"rimraf": "^2.6.3"
44+
},
45+
"lint-staged": {
46+
"packages/**/*.js": "eslint --fix"
2647
}
2748
}

packages/babel-plugin-chameleon-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "babel-plugin-chameleon-import",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "Component modular import plugin for babel.",
55
"repository": {
66
"type": "git",

packages/chameleon-css-loader/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-css-loader",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "chameleon样式处理",
55
"main": "index.js",
66
"scripts": {

packages/chameleon-css-loader/test/parser-test/miniapp.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const parseCss = require('../../parser/miniapp.js');
22
const expect = require('chai').expect;
33

44
let source = `body {width:100cpx;font-size:26px;/* height:200px; */}`;
5+
let alipayCSS = `.cls1{color:red} .cls2{width:100cpx;height:200cpx;} .cls3:{font-size:30cpx;}`
56
describe('parse/miniapp', function() {
67
it('parse cssstyle px to rpx but leave comment in style alone', function() {
78
let result = parseCss(source,{
@@ -10,6 +11,13 @@ describe('parse/miniapp', function() {
1011
});
1112
expect(/100rpx/.test(result)).to.be.ok;
1213
})
14+
it('parse cssstyle px to rpx but leave comment in style alone', function() {
15+
let result = parseCss(alipayCSS,{
16+
cmlType:'alipay',
17+
filePath:"/src/page/index.cml"
18+
});
19+
expect(/100rpx/.test(result)).to.be.ok;
20+
})
1321
it('parse cssstyle px to rpx but leave comment in style alone', function() {
1422
let result = parseCss(source,{
1523
cmlType:'wx',

packages/chameleon-css-loader/test/parser-test/weex.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ describe('parse/weex', function() {
5858
.e {
5959
margin: 10px 20px 5px 15px;
6060
}
61+
.f {
62+
border-style:solid;
63+
border-width:10cpx;
64+
border-color:red;
65+
flex-flow:row;
66+
}
6167
`;
6268

6369
it('margin', function() {
6470

6571
let result = parseCss(css);// body {width:1rem;}
66-
console.log(result);
67-
expect(result).to.equal(`.a {\n margin-left: 10px;\n}\n\n.b {\n margin-top: 10px;\n margin-right: 10px;\n margin-bottom: 10px;\n margin-left: 10px;\n}\n\n.c {\n margin-top: 10px;\n margin-right: 20px;\n margin-bottom: 10px;\n margin-left: 20px;\n}\n\n.d {\n margin-top: 10px;\n margin-right: 20px;\n margin-bottom: 10px;\n margin-left: 20px;\n}\n\n.e {\n margin-top: 10px;\n margin-right: 20px;\n margin-bottom: 5px;\n margin-left: 15px;\n}`);
72+
expect(result).to.equal('.a {\n margin-left: 10px;\n}\n\n.b {\n margin-top: 10px;\n margin-right: 10px;\n margin-bottom: 10px;\n margin-left: 10px;\n}\n\n.c {\n margin-top: 10px;\n margin-right: 20px;\n margin-bottom: 10px;\n margin-left: 20px;\n}\n\n.d {\n margin-top: 10px;\n margin-right: 20px;\n margin-bottom: 10px;\n margin-left: 20px;\n}\n\n.e {\n margin-top: 10px;\n margin-right: 20px;\n margin-bottom: 5px;\n margin-left: 15px;\n}\n\n.f {\n border-top-style: solid;\n border-right-style: solid;\n border-bottom-style: solid;\n border-left-style: solid;\n border-top-width: 10px;\n border-right-width: 10px;\n border-bottom-width: 10px;\n border-left-width: 10px;\n border-top-color: red;\n border-right-color: red;\n border-bottom-color: red;\n border-left-color: red;\n flex-direction: row;\n}');
6873
})
6974

7075
})

packages/chameleon-dev-proxy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-dev-proxy",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "cml开发环境代理服务模块",
55
"main": "index.js",
66
"author": "Chameleon-Team",

packages/chameleon-errors-webpack-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.4-alpha.1",
2+
"version": "1.0.4",
33
"name": "chameleon-errors-webpack-plugin",
44
"main": "index.js",
55
"author": "Chameleon-Team",

packages/chameleon-linter/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-linter",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "cml规范校验工具",
55
"main": "index.js",
66
"scripts": {
@@ -24,10 +24,10 @@
2424
"@babel/traverse": "^7.1.4",
2525
"bulk-require": "^1.0.1",
2626
"chalk": "^2.4.1",
27-
"chameleon-tool-utils": "1.0.4-alpha.1",
28-
"cml-component-parser": "1.0.4-alpha.1",
29-
"cml-htmllint": "1.0.4-alpha.1",
30-
"cml-js-parser": "1.0.4-alpha.1",
27+
"chameleon-tool-utils": "1.0.4",
28+
"cml-component-parser": "1.0.4",
29+
"cml-htmllint": "1.0.4",
30+
"cml-js-parser": "1.0.4",
3131
"commander": "^2.19.0",
3232
"glob": "^7.1.3",
3333
"json-lint": "^0.1.0",

packages/chameleon-loader/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-loader",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "chameleon cml文件处理loader",
55
"main": "src/index.js",
66
"directories": {
@@ -18,18 +18,18 @@
1818
"@babel/types": "^7.3.4",
1919
"babel-generator": "6.26.1",
2020
"babel-traverse": "6.26.0",
21-
"chameleon-template-parse": "1.0.4-alpha.1",
22-
"chameleon-tool-utils": "1.0.4-alpha.1",
21+
"chameleon-template-parse": "1.0.4",
22+
"chameleon-tool-utils": "1.0.4",
2323
"consolidate": "0.14.0",
2424
"de-indent": "1.0.2",
2525
"fs-extra": "^7.0.1",
2626
"hash-sum": "1.0.2",
2727
"he": "1.1.0",
2828
"loader-utils": "1.1.0",
2929
"lru-cache": "4.1.1",
30-
"mvvm-interface-parser": "1.0.4-alpha.1",
30+
"mvvm-interface-parser": "1.0.4",
3131
"resolve": "1.4.0",
32-
"runtime-check": "1.0.4-alpha.1",
32+
"runtime-check": "1.0.4",
3333
"source-map": "0.6.1",
3434
"vue-style-loader": "4.0.1"
3535
},

packages/chameleon-loader/src/loader.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const fs = require('fs');
1010
const {getVueRunTimeSnippet} = require('./cml-compile/runtime/index.js');
1111

1212
var compileTemplate = require('chameleon-template-parse');
13-
13+
const preParseMultiTemplate = require('chameleon-template-parse').preParseMultiTemplate;
1414
var jsonHandler = require('./cml-compile/json-handle.js');
1515
const { getScriptCode } = require('./interface-check/getScriptCode.js');
1616
const cmlUtils = require('chameleon-tool-utils');
@@ -259,6 +259,7 @@ module.exports = function (content) {
259259
if (type !== 'app') {
260260
let parseTemplate = parts.template && parts.template[0];
261261
let templateContent = (parseTemplate && parseTemplate.content) || '';
262+
templateContent = preParseMultiTemplate(`<template>${templateContent}</template>`,cmlType,{needTranJSX:true,needDelTemplate:true});
262263
let lang = (parseTemplate && parseTemplate.lang) || 'cml';
263264
//content是不带template标签的内容;
264265
let compileResult = ASTcompileTemplate(templateContent, {
@@ -360,17 +361,14 @@ module.exports = function (content) {
360361
function webWeexHandler() {
361362
//主要是对模板进行编译和script进行拼接 vue组件的注册
362363
const parseTemplate = (parts.template && parts.template[0]) || {};
363-
const templateContent = parseTemplate.content || '';
364+
let templateContent = parseTemplate.content || '';
365+
if(type !== 'app'){
366+
templateContent = preParseMultiTemplate(`<template>${templateContent}</template>`,cmlType,{needTranJSX:true,needDelTemplate:true});
367+
}
364368
const lang = parseTemplate.lang || 'cml';
365369
const parseScript = (parts.script && parts.script[0]) || {};
366370
const scriptContent = parseScript.content || '';
367371
let newTemplate = handleTemplate();
368-
// if(type === 'app') {
369-
// newTemplate = newTemplate.replace(/<app[\s\S]*?\/app>/,`<div class="app" bubble="true">
370-
// <router-view ></router-view>
371-
// </div>`)
372-
373-
// }
374372
if(type === 'app') {
375373
if (cmlType == 'web') {
376374
newTemplate = newTemplate.replace(/<app[\s\S]*?\/app>/,`<router-view class="app" bubble="true"></router-view> `)

packages/chameleon-miniapp-target/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-miniapp-target",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "chameleon 小程序webpack的target",
55
"main": "src/index.js",
66
"scripts": {
@@ -14,7 +14,7 @@
1414
"webpack": "^3.12.0"
1515
},
1616
"dependencies": {
17-
"chameleon-tool-utils": "1.0.4-alpha.1"
17+
"chameleon-tool-utils": "1.0.4"
1818
},
1919
"mail": "ChameleonCore@didiglobal.com",
2020
"gitHead": "5ddcde4330774710f7646559446e008f7785ce00"

packages/chameleon-mixins/miniapp-utils/px2cpx.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ _.px2cpx = function(px) {
1515
const { windowWidth } = my.getSystemInfoSync();
1616
return windowWidth;
1717
}
18+
if(platform === 'qq'){
19+
const { windowWidth } = qq.getSystemInfoSync();
20+
return windowWidth;
21+
}
1822
}
1923

2024
viewportWidth = viewportWidth || getViewportSize();

packages/chameleon-mixins/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-mixins",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "chameleon-mixins",
55
"main": "index.js",
66
"scripts": {
@@ -12,7 +12,7 @@
1212
"license": "Apache",
1313
"devDependencies": {
1414
"chai": "^4.2.0",
15-
"chameleon-css-loader": "1.0.4-alpha.1",
15+
"chameleon-css-loader": "1.0.4",
1616
"coveralls": "^2.11.9",
1717
"eslint": "^5.9.0",
1818
"gulp": "^3.9.1",

packages/chameleon-template-parse/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chameleon-template-parse",
3-
"version": "1.0.4-alpha.1",
3+
"version": "1.0.4",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -24,9 +24,9 @@
2424
},
2525
"devDependencies": {
2626
"chai": "^4.2.0",
27-
"chameleon-css-loader": "1.0.4-alpha.1",
28-
"chameleon-mixins": "1.0.4-alpha.1",
29-
"chameleon-tool-utils": "1.0.4-alpha.1",
27+
"chameleon-css-loader": "1.0.4",
28+
"chameleon-mixins": "1.0.4",
29+
"chameleon-tool-utils": "1.0.4",
3030
"clean-webpack-plugin": "^0.1.19",
3131
"coveralls": "^2.11.9",
3232
"eslint": "^5.9.0",

0 commit comments

Comments
 (0)