Skip to content

Commit

Permalink
Merge pull request #266 from didi/0.4.x-alpha
Browse files Browse the repository at this point in the history
0.4.x alpha
  • Loading branch information
beatles-chameleon authored Aug 27, 2019
2 parents a3b973b + 8d27cb1 commit 39d14ae
Show file tree
Hide file tree
Showing 52 changed files with 4,850 additions and 4,482 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [0.4.1-alpha.1]
### Bugfixes
- 修复window下分包加载的bug
- 修复babel-loader无法在回调插件中重新配置的bug
## [0.4.1-alpha.0]

### Bug Fixes

- 修复 config.json文件中不生成extra
- 修复 -h 指令提示 -n 的情况

## [0.4.0]
### Features
- 灰度完成发正式版
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"command": {
"publish": {
"allowBranch": "master",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-chameleon-import/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-chameleon-import",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "Component modular import plugin for babel.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/chameleon-css-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-css-loader",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "chameleon样式处理",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/chameleon-dev-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-dev-proxy",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "cml开发环境代理服务模块",
"main": "index.js",
"author": "Chameleon-Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/chameleon-errors-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"name": "chameleon-errors-webpack-plugin",
"main": "index.js",
"author": "Chameleon-Team",
Expand Down
10 changes: 5 additions & 5 deletions packages/chameleon-linter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-linter",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "cml规范校验工具",
"main": "index.js",
"scripts": {
Expand All @@ -24,10 +24,10 @@
"@babel/traverse": "^7.1.4",
"bulk-require": "^1.0.1",
"chalk": "^2.4.1",
"chameleon-tool-utils": "0.4.0",
"cml-component-parser": "0.4.0",
"cml-htmllint": "0.4.0",
"cml-js-parser": "0.4.0",
"chameleon-tool-utils": "0.4.1-alpha.1",
"cml-component-parser": "0.4.1-alpha.1",
"cml-htmllint": "0.4.1-alpha.1",
"cml-js-parser": "0.4.1-alpha.1",
"commander": "^2.19.0",
"glob": "^7.1.3",
"json-lint": "^0.1.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/chameleon-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-loader",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "chameleon cml文件处理loader",
"main": "src/index.js",
"directories": {
Expand All @@ -18,18 +18,18 @@
"@babel/types": "^7.3.4",
"babel-generator": "6.26.1",
"babel-traverse": "6.26.0",
"chameleon-template-parse": "0.4.0",
"chameleon-tool-utils": "0.4.0",
"chameleon-template-parse": "0.4.1-alpha.1",
"chameleon-tool-utils": "0.4.1-alpha.1",
"consolidate": "0.14.0",
"de-indent": "1.0.2",
"fs-extra": "^7.0.1",
"hash-sum": "1.0.2",
"he": "1.1.0",
"loader-utils": "1.1.0",
"lru-cache": "4.1.1",
"mvvm-interface-parser": "0.4.0",
"mvvm-interface-parser": "0.4.1-alpha.1",
"resolve": "1.4.0",
"runtime-check": "0.4.0",
"runtime-check": "0.4.1-alpha.1",
"source-map": "0.6.1",
"vue-style-loader": "4.0.1"
},
Expand Down
9 changes: 7 additions & 2 deletions packages/chameleon-loader/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ function resolveLoaders (
hasScoped,
hasComment,
hasFunctionalTemplate,
needCssSourceMap
needCssSourceMap,
loaderContext
) {
const JSLoader = (loaderContext._compiler.options.module.rules || []).find((rule) => (rule.test instanceof RegExp && rule.test.test('name.js')))
const JSLoaderConfig = (JSLoader.use || []).find((item) => item.loader === 'babel-loader')
options.loaders && (options.loaders.js = JSLoaderConfig)
let cssLoaderOptions = ''
if (needCssSourceMap) {
cssLoaderOptions += '?sourceMap'
Expand Down Expand Up @@ -129,7 +133,8 @@ module.exports = function createHelpers (
hasScoped,
hasComment,
hasFunctionalTemplate,
needCssSourceMap
needCssSourceMap,
loaderContext
)

function getRequire (type, part, index, scoped) {
Expand Down
4 changes: 2 additions & 2 deletions packages/chameleon-miniapp-target/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-miniapp-target",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "chameleon 小程序webpack的target",
"main": "src/index.js",
"scripts": {
Expand All @@ -14,7 +14,7 @@
"webpack": "^3.12.0"
},
"dependencies": {
"chameleon-tool-utils": "0.4.0"
"chameleon-tool-utils": "0.4.1-alpha.1"
},
"mail": "[email protected]",
"gitHead": "5ddcde4330774710f7646559446e008f7785ce00"
Expand Down
4 changes: 2 additions & 2 deletions packages/chameleon-mixins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-mixins",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "chameleon-mixins",
"main": "index.js",
"scripts": {
Expand All @@ -12,7 +12,7 @@
"license": "Apache",
"devDependencies": {
"chai": "^4.2.0",
"chameleon-css-loader": "0.4.0",
"chameleon-css-loader": "0.4.1-alpha.1",
"coveralls": "^2.11.9",
"eslint": "^5.9.0",
"gulp": "^3.9.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/chameleon-template-parse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-template-parse",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "",
"main": "index.js",
"scripts": {
Expand All @@ -24,9 +24,9 @@
},
"devDependencies": {
"chai": "^4.2.0",
"chameleon-css-loader": "0.4.0",
"chameleon-mixins": "0.4.0",
"chameleon-tool-utils": "0.4.0",
"chameleon-css-loader": "0.4.1-alpha.1",
"chameleon-mixins": "0.4.1-alpha.1",
"chameleon-tool-utils": "0.4.1-alpha.1",
"clean-webpack-plugin": "^0.1.19",
"coveralls": "^2.11.9",
"eslint": "^5.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/chameleon-templates/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chameleon-templates",
"version": "0.4.0",
"version": "0.4.1-alpha.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/chameleon-tool-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
"test": "mocha --recursive --reporter spec",
"break-test": "./node_modules/.bin/mocha --inspect-brk --recursive --reporter spec"
},
"version": "0.4.0"
"version": "0.4.1-alpha.1"
}
2 changes: 1 addition & 1 deletion packages/chameleon-tool/chameleon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env node
#! /usr/bin/env node
// --inspect-brk

require('./lib/index.js');
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/alipay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports.desc = 'tools for the alipay miniprogram project';
exports.register = function (commander) {
commander
.option('-r, --root [root]', 'specify project root')
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
cml.utils.checkProjectConfig();
/* eslint-disable */
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/baidu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports.desc = 'tools for the baidu miniprogram project';
exports.register = function (commander) {
commander
.option('-r, --root [root]', 'specify project root')
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
cml.utils.checkProjectConfig();
/* eslint-disable */
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports.desc = 'start dev mode';
/* istanbul ignore next */
exports.register = function (commander) {
commander
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
cml.utils.checkProjectConfig();
/* eslint-disable */
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/qq/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports.desc = 'tools for the qq miniprogram project';
exports.register = function (commander) {
commander
.option('-r, --root [root]', 'specify project root')
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
cml.utils.checkProjectConfig();
/* eslint-disable */
Expand Down
7 changes: 4 additions & 3 deletions packages/chameleon-tool/commanders/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const path = require('path');
const fs = require('fs');
const crypto = require('crypto');
const cmlUtils = require('chameleon-tool-utils');

/**
* 非web端构建
* @param {*} media dev or build ...
Expand Down Expand Up @@ -212,13 +213,13 @@ exports.createConfigJson = function() {
let configObj = {};
if (cml.utils.isFile(configJsonPath)) {
configObj = JSON.parse(fs.readFileSync(configJsonPath, {encoding: 'utf-8'}))
};
}
// 获取weex jsbundle地址
let weexjs = configObj.weexjs || '';
let md5str = '';
const weexjsName = weexjs.split('/').pop();
const weexjsPath = path.resolve(cml.projectRoot, 'dist/weex/', weexjsName);

if (cml.utils.isFile(weexjsPath)) {
const md5sum = crypto.createHash('md5');
const buffer = fs.readFileSync(weexjsPath);
Expand Down Expand Up @@ -327,7 +328,7 @@ exports.createConfigJson = function() {

result.forEach(item => {
Object.keys(item).forEach(key => {
if (!~cml.activePlatform.indexOf(key)) {
if (!~cml.activePlatform.indexOf(key) && key !== 'extra') {
delete item[key]
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports.desc = 'tools for the web project';
exports.register = function (commander) {
commander
.option('-r, --root [root]', 'specify project root')
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
/* eslint-disable */
cml.log.startBuilding();
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/weex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports.desc = 'tools for the weex project';
exports.register = function (commander) {
commander
.option('-r, --root [root]', 'specify project root')
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
cml.utils.checkProjectConfig();
/* eslint-disable */
Expand Down
1 change: 1 addition & 0 deletions packages/chameleon-tool/commanders/wx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports.desc = 'tools for the weixin miniprogram project';
exports.register = function (commander) {
commander
.option('-r, --root [root]', 'specify project root')
.option('-n, --nopreview ', "don't auto open preview")
.action(function (...args) {
cml.utils.checkProjectConfig();
/* eslint-disable */
Expand Down
7 changes: 4 additions & 3 deletions packages/chameleon-tool/configs/plugins/miniAppSubPkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class MiniAppSubPkg {
let regStatic = /require\(.*?static\/js\/pages.*?\)/;
let regMainfest = /var.*?require\(.*?manifest\.js.*?\)/
subPagesArr.forEach((item) => {
let subPageJSPath = `${item}.js`
let subPageStaticJSPath = `static/js/${item}.js`;
let subPageJSPath = cmlUtils.handleWinPath(`${item}.js`);
let subPageStaticJSPath = cmlUtils.handleWinPath(`static/js/${item}.js`);
let content = compilation.assets[subPageJSPath] && compilation.assets[subPageJSPath].source();

if (content) {
Expand All @@ -58,7 +58,8 @@ class MiniAppSubPkg {
// 注意 assets中的key configurable与否
}
let finalContent = content + '\n' + staticContent;
compilation.assets[subPageJSPath]._value = finalContent;

compilation.assets[subPageJSPath] && (compilation.assets[subPageJSPath]._value = finalContent);
});
callback();
}
Expand Down
1 change: 0 additions & 1 deletion packages/chameleon-tool/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports.run = function () {
commander
.command(cmd.name)
.option('-l, --log [debug]', 'logLevel')
.option('-n, --nopreview ', "don't auto open preview")
.usage(cmd.usage)
.description(cmd.desc)
);
Expand Down
Loading

0 comments on commit 39d14ae

Please sign in to comment.