xhs-mp-compiler-cli 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -5
- package/dist/bin/xhs-mp-cli-build.d.ts +0 -2
- package/dist/bin/xhs-mp-cli-build.js +0 -40
- package/dist/bin/xhs-mp-cli-dev.d.ts +0 -2
- package/dist/bin/xhs-mp-cli-dev.js +0 -59
- package/dist/bin/xhs-mp-cli.d.ts +0 -2
- package/dist/bin/xhs-mp-cli.js +0 -16
- package/dist/compiler.d.ts +0 -76
- package/dist/compiler.js +0 -361
- package/dist/compilerCP.d.ts +0 -1
- package/dist/compilerCP.js +0 -175
- package/dist/config/constant.config.d.ts +0 -7
- package/dist/config/constant.config.js +0 -10
- package/dist/dev-server/index.d.ts +0 -3
- package/dist/dev-server/index.js +0 -64
- package/dist/dev-server/lib/ensurePort.d.ts +0 -2
- package/dist/dev-server/lib/ensurePort.js +0 -32
- package/dist/dev-server/lib/openBrowser.d.ts +0 -2
- package/dist/dev-server/lib/openBrowser.js +0 -23
- package/dist/dev-server/lib/openChrome.applescript +0 -78
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -5
- package/dist/packs/index.d.ts +0 -14
- package/dist/packs/index.js +0 -31
- package/dist/packs/mp-pack/index.d.ts +0 -3
- package/dist/packs/mp-pack/index.js +0 -32
- package/dist/packs/webpack/index.d.ts +0 -3
- package/dist/packs/webpack/index.js +0 -92
- package/dist/packs/webpack/webpack.d.ts +0 -21
- package/dist/packs/webpack/webpack.js +0 -79
- package/dist/presets/babel.d.ts +0 -8
- package/dist/presets/babel.js +0 -59
- package/dist/presets/common.d.ts +0 -4
- package/dist/presets/common.js +0 -46
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.d.ts +0 -10
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.js +0 -46
- package/dist/presets/configs/minigame/assets/index.d.ts +0 -2
- package/dist/presets/configs/minigame/assets/index.js +0 -65
- package/dist/presets/configs/minigame/service/index.d.ts +0 -3
- package/dist/presets/configs/minigame/service/index.js +0 -34
- package/dist/presets/configs/minigame/service/resolveLimitPlugin.d.ts +0 -8
- package/dist/presets/configs/minigame/service/resolveLimitPlugin.js +0 -35
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.d.ts +0 -9
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.js +0 -69
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.d.ts +0 -10
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.js +0 -32
- package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.d.ts +0 -12
- package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.js +0 -132
- package/dist/presets/configs/miniprogram/assets/index.d.ts +0 -4
- package/dist/presets/configs/miniprogram/assets/index.js +0 -47
- package/dist/presets/configs/miniprogram/render/component.d.ts +0 -3
- package/dist/presets/configs/miniprogram/render/component.js +0 -47
- package/dist/presets/configs/miniprogram/render/index.d.ts +0 -5
- package/dist/presets/configs/miniprogram/render/index.js +0 -70
- package/dist/presets/configs/miniprogram/render/render.d.ts +0 -3
- package/dist/presets/configs/miniprogram/render/render.js +0 -49
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.d.ts +0 -8
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.js +0 -55
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.d.ts +0 -15
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.js +0 -163
- package/dist/presets/configs/miniprogram/service/index.d.ts +0 -5
- package/dist/presets/configs/miniprogram/service/index.js +0 -72
- package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.d.ts +0 -8
- package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.js +0 -66
- package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.d.ts +0 -9
- package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.js +0 -65
- package/dist/presets/index.d.ts +0 -2
- package/dist/presets/index.js +0 -95
- package/dist/presets/loaders/mg-entry-loader.d.ts +0 -1
- package/dist/presets/loaders/mg-entry-loader.js +0 -27
- package/dist/presets/loaders/mini-style-loader.d.ts +0 -1
- package/dist/presets/loaders/mini-style-loader.js +0 -72
- package/dist/presets/loaders/mp-entry-loader.d.ts +0 -1
- package/dist/presets/loaders/mp-entry-loader.js +0 -196
- package/dist/presets/loaders/sjs-loader/index.d.ts +0 -12
- package/dist/presets/loaders/sjs-loader/index.js +0 -605
- package/dist/presets/loaders/sjs-loader/scope.d.ts +0 -36
- package/dist/presets/loaders/sjs-loader/scope.js +0 -122
- package/dist/presets/loaders/sjs-loader/tranform.d.ts +0 -2
- package/dist/presets/loaders/sjs-loader/tranform.js +0 -31
- package/dist/presets/loaders/wxss-loader.d.ts +0 -1
- package/dist/presets/loaders/wxss-loader.js +0 -77
- package/dist/presets/plugins/InjectorPlugin.d.ts +0 -7
- package/dist/presets/plugins/InjectorPlugin.js +0 -14
- package/dist/presets/prod.d.ts +0 -4
- package/dist/presets/prod.js +0 -80
- package/dist/types/index.d.ts +0 -118
- package/dist/types/index.js +0 -13
- package/dist/utils/asyncWebpack.d.ts +0 -3
- package/dist/utils/asyncWebpack.js +0 -38
- package/dist/utils/common.d.ts +0 -8
- package/dist/utils/common.js +0 -36
- package/dist/utils/const.d.ts +0 -27
- package/dist/utils/const.js +0 -47
- package/dist/utils/css.d.ts +0 -2
- package/dist/utils/css.js +0 -41
- package/dist/utils/depenedHelper.d.ts +0 -31
- package/dist/utils/depenedHelper.js +0 -89
- package/dist/utils/getSuffixName.d.ts +0 -3
- package/dist/utils/getSuffixName.js +0 -18
- package/dist/utils/loader-utils.d.ts +0 -15
- package/dist/utils/loader-utils.js +0 -59
- package/dist/utils/postcssRpx2Vw.d.ts +0 -12
- package/dist/utils/postcssRpx2Vw.js +0 -35
- package/dist/utils/projectConfig.d.ts +0 -1
- package/dist/utils/projectConfig.js +0 -20
- package/dist/utils/tagTransformMap.d.ts +0 -35
- package/dist/utils/tagTransformMap.js +0 -38
- package/dist/utils/utils.d.ts +0 -5
- package/dist/utils/utils.js +0 -37
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScopeManager = exports.Scope = exports.SPECIFY_VAR = void 0;
|
|
4
|
-
exports.SPECIFY_VAR = ["getDate", "getRegExp", "console"];
|
|
5
|
-
const IDENTIFIER_WHITE_LIST = [
|
|
6
|
-
"Object", "Boolean", "Array", "String", "Number", "Date", "Map", "Set",
|
|
7
|
-
"decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "isNaN", "isFinite", "parseFloat", "parseInt",
|
|
8
|
-
"Infinity", "NaN", "undefined",
|
|
9
|
-
"setTimeout", "clearTimeout", "setInterval", "clearInterval",
|
|
10
|
-
"JSON", "Math",
|
|
11
|
-
// 模块化
|
|
12
|
-
"module", "require", "exports",
|
|
13
|
-
...exports.SPECIFY_VAR
|
|
14
|
-
];
|
|
15
|
-
// 变量作用域表
|
|
16
|
-
class Scope {
|
|
17
|
-
constructor() {
|
|
18
|
-
// 当前作用域定义的变量
|
|
19
|
-
this.defines = {};
|
|
20
|
-
// 当前作用域使用的变量
|
|
21
|
-
this.access = {};
|
|
22
|
-
}
|
|
23
|
-
toString() {
|
|
24
|
-
return `defines: ${Object.keys(this.defines)} access: ${Object.keys(this.access)}`;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
anlysis() {
|
|
30
|
-
// TODO 优化算法复杂度
|
|
31
|
-
// 在自身作用域 以及 上级作用域寻找,找到顶层作用域时 则需要看 白名单是否含有
|
|
32
|
-
for (const variable in this.access) {
|
|
33
|
-
// 白名单也不包含此变量
|
|
34
|
-
if (this.checkGlobal(variable) && !IDENTIFIER_WHITE_LIST.includes(variable)) {
|
|
35
|
-
return { variable, span: this.access[variable] };
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
// 检查是否是全局调用
|
|
41
|
-
checkGlobal(key) {
|
|
42
|
-
let scope = this;
|
|
43
|
-
while (scope) {
|
|
44
|
-
if (!scope.defines[key]) {
|
|
45
|
-
scope = scope.parentScope;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return !scope;
|
|
53
|
-
}
|
|
54
|
-
setAccess(key, value) {
|
|
55
|
-
this.access[key] = value;
|
|
56
|
-
}
|
|
57
|
-
setDefines(key, value) {
|
|
58
|
-
this.defines[key] = value;
|
|
59
|
-
}
|
|
60
|
-
setParentScope(scope) {
|
|
61
|
-
this.parentScope = scope;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.Scope = Scope;
|
|
65
|
-
class ScopeManager {
|
|
66
|
-
constructor() {
|
|
67
|
-
// 栈帧
|
|
68
|
-
this._scopeStack = [];
|
|
69
|
-
// 栈 深度遍历结果
|
|
70
|
-
this._scopeTables = [];
|
|
71
|
-
// 是否停止收集
|
|
72
|
-
this._stop = false;
|
|
73
|
-
}
|
|
74
|
-
// 停止分析
|
|
75
|
-
stop() {
|
|
76
|
-
this._stop = true;
|
|
77
|
-
}
|
|
78
|
-
enterScope() {
|
|
79
|
-
if (this._stop)
|
|
80
|
-
return;
|
|
81
|
-
this._scopeStack.push(new Scope());
|
|
82
|
-
}
|
|
83
|
-
exitScope() {
|
|
84
|
-
if (this._stop)
|
|
85
|
-
return;
|
|
86
|
-
const scope = this._scopeStack.pop();
|
|
87
|
-
if (scope) {
|
|
88
|
-
this._scopeTables.push(scope);
|
|
89
|
-
scope.setParentScope(this.getCurrentScope());
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
getCurrentScope() {
|
|
93
|
-
if (this._stop)
|
|
94
|
-
return;
|
|
95
|
-
return this._scopeStack[this._scopeStack.length - 1];
|
|
96
|
-
}
|
|
97
|
-
// 记录定义的值
|
|
98
|
-
pushIdentifier(id) {
|
|
99
|
-
var _a;
|
|
100
|
-
if (this._stop)
|
|
101
|
-
return;
|
|
102
|
-
if (this.getCurrentScope()) {
|
|
103
|
-
(_a = this.getCurrentScope()) === null || _a === void 0 ? void 0 : _a.setDefines(id.value, id.span);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// 记录使用的值
|
|
107
|
-
pushAccess(id) {
|
|
108
|
-
if (this._stop)
|
|
109
|
-
return;
|
|
110
|
-
const current = this.getCurrentScope();
|
|
111
|
-
if (current) {
|
|
112
|
-
current === null || current === void 0 ? void 0 : current.setAccess(id.value, id.span);
|
|
113
|
-
if (exports.SPECIFY_VAR.includes(id.value)) {
|
|
114
|
-
id._xhsScope = current;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
getDFSScope() {
|
|
119
|
-
return this._scopeTables;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.ScopeManager = ScopeManager;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transform = void 0;
|
|
4
|
-
const core_1 = require("@swc/core");
|
|
5
|
-
const transform = (code, plugin, target = 'esnext', minify = false) => (0, core_1.transformSync)(code, {
|
|
6
|
-
swcrc: false,
|
|
7
|
-
configFile: false,
|
|
8
|
-
minify,
|
|
9
|
-
sourceMaps: false,
|
|
10
|
-
jsc: {
|
|
11
|
-
preserveAllComments: true,
|
|
12
|
-
target,
|
|
13
|
-
// minify: false,
|
|
14
|
-
externalHelpers: false,
|
|
15
|
-
parser: {
|
|
16
|
-
syntax: "ecmascript",
|
|
17
|
-
jsx: false,
|
|
18
|
-
dynamicImport: false,
|
|
19
|
-
privateMethod: false,
|
|
20
|
-
functionBind: false,
|
|
21
|
-
classPrivateProperty: false,
|
|
22
|
-
exportDefaultFrom: false,
|
|
23
|
-
exportNamespaceFrom: false,
|
|
24
|
-
decorators: false,
|
|
25
|
-
decoratorsBeforeExport: false,
|
|
26
|
-
importMeta: false,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
plugin,
|
|
30
|
-
});
|
|
31
|
-
exports.transform = transform;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const postcss_1 = __importDefault(require("postcss"));
|
|
16
|
-
const postcss_import_1 = __importDefault(require("postcss-import"));
|
|
17
|
-
const postcss_prefix_selector_1 = __importDefault(require("postcss-prefix-selector"));
|
|
18
|
-
const CssSyntaxError_1 = __importDefault(require("css-loader/dist/CssSyntaxError"));
|
|
19
|
-
const tagTransformMap_1 = __importDefault(require("../../utils/tagTransformMap"));
|
|
20
|
-
const getSuffixName_1 = require("../../utils/getSuffixName");
|
|
21
|
-
const common_1 = require("../../utils/common");
|
|
22
|
-
const tags = Object.keys(tagTransformMap_1.default).join('|');
|
|
23
|
-
const labelStr = `(^|\\s)(${tags}|page|audio|live-player|map|cover-view|cover-image|video)`;
|
|
24
|
-
const labelReg = new RegExp(labelStr, 'g');
|
|
25
|
-
function wxssLoader(source) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
var _a, _b, _c, _d, _e;
|
|
28
|
-
const done = this.async();
|
|
29
|
-
const { project } = this._compiler;
|
|
30
|
-
const { appJSON = {}, miniprogramDir = '' } = project || {};
|
|
31
|
-
const shortPath = (0, common_1.getShortPath)(miniprogramDir, this.resourcePath).replace(new RegExp(`\\.${(0, getSuffixName_1.getCssSuffixName)()}$`), '');
|
|
32
|
-
const index = (_c = (_b = (_a = appJSON === null || appJSON === void 0 ? void 0 : appJSON.componentsMap) === null || _a === void 0 ? void 0 : _a[shortPath]) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : null;
|
|
33
|
-
const styleIsolation = (_e = (_d = appJSON === null || appJSON === void 0 ? void 0 : appJSON.componentsMap) === null || _d === void 0 ? void 0 : _d[shortPath]) === null || _e === void 0 ? void 0 : _e.styleIsolation;
|
|
34
|
-
const selectorIndex = styleIsolation === 'shared' ? 0 : index || 0;
|
|
35
|
-
// js / json 的配置会影响样式
|
|
36
|
-
const extReg = new RegExp(`${(0, getSuffixName_1.getCssSuffixName)()}$`);
|
|
37
|
-
this.addDependency(this.resourcePath.replace(extReg, 'js'));
|
|
38
|
-
this.addDependency(this.resourcePath.replace(extReg, 'json'));
|
|
39
|
-
(0, postcss_1.default)()
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
.use((0, postcss_import_1.default)({ root: miniprogramDir }))
|
|
42
|
-
.use((0, postcss_prefix_selector_1.default)({
|
|
43
|
-
prefix: 'xhs',
|
|
44
|
-
transform(prefix, selector) {
|
|
45
|
-
// 支持 host 选择器 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/wxml-wxss.html
|
|
46
|
-
if (selector === ':host') {
|
|
47
|
-
return `[is="${shortPath}"]`;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 替换所有类选择器,用于做样式隔离 wiki: https://wiki.xiaohongshu.com/pages/viewpage.action?pageId=181017177
|
|
51
|
-
* .app -> .xhs_0_app
|
|
52
|
-
*/
|
|
53
|
-
selector = selector.replace(/\.(\w)/g, `.xhs_${selectorIndex}_$1`);
|
|
54
|
-
// 为内置组件加上 xhs 前缀
|
|
55
|
-
if (selector.match(labelReg)) {
|
|
56
|
-
selector = selector.replace(labelReg, `$1${prefix}-$2`);
|
|
57
|
-
}
|
|
58
|
-
return selector;
|
|
59
|
-
},
|
|
60
|
-
}))
|
|
61
|
-
.process(source, {
|
|
62
|
-
from: this.resourcePath,
|
|
63
|
-
})
|
|
64
|
-
.then(result => {
|
|
65
|
-
result.messages.forEach(({ file, type }) => {
|
|
66
|
-
if (type === 'dependency') {
|
|
67
|
-
this.addDependency(file);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
done(null, result.css);
|
|
71
|
-
})
|
|
72
|
-
.catch(error => {
|
|
73
|
-
done(error.name === 'CssSyntaxError' ? new CssSyntaxError_1.default(error) : error);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
module.exports = wxssLoader;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InjectorPlugin = void 0;
|
|
4
|
-
class InjectorPlugin {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.options = options;
|
|
7
|
-
}
|
|
8
|
-
apply(compiler) {
|
|
9
|
-
const { project, packSetting } = this.options;
|
|
10
|
-
compiler.project = project;
|
|
11
|
-
compiler.packSetting = packSetting;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.InjectorPlugin = InjectorPlugin;
|
package/dist/presets/prod.d.ts
DELETED
package/dist/presets/prod.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const const_1 = __importDefault(require("../utils/const"));
|
|
7
|
-
// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
|
8
|
-
const getProdConfig = (chain, options) => {
|
|
9
|
-
const { project, packSetting, otherSetting = {} } = options;
|
|
10
|
-
const { compressJs } = packSetting;
|
|
11
|
-
chain.mode('production');
|
|
12
|
-
if (!otherSetting.noJs) {
|
|
13
|
-
// 生产环境使用 babel-loader
|
|
14
|
-
if (project.appMode === 'miniprogram') {
|
|
15
|
-
chain.module
|
|
16
|
-
.rule('js')
|
|
17
|
-
.use('js-loader')
|
|
18
|
-
.loader(require.resolve('babel-loader'))
|
|
19
|
-
.options({
|
|
20
|
-
configFile: false,
|
|
21
|
-
babelrc: false,
|
|
22
|
-
sourceType: 'unambiguous',
|
|
23
|
-
presets: [
|
|
24
|
-
[
|
|
25
|
-
require.resolve('@babel/preset-env'),
|
|
26
|
-
{
|
|
27
|
-
useBuiltIns: false,
|
|
28
|
-
corejs: {
|
|
29
|
-
version: 3,
|
|
30
|
-
proposals: true
|
|
31
|
-
},
|
|
32
|
-
shippedProposals: true,
|
|
33
|
-
targets: const_1.default.PROD_BROWSERSLIST
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
],
|
|
37
|
-
plugins: [[require.resolve('@babel/plugin-transform-runtime'), { corejs: false }]]
|
|
38
|
-
});
|
|
39
|
-
chain.module
|
|
40
|
-
.rule('ts')
|
|
41
|
-
.use('ts-loader')
|
|
42
|
-
.loader(require.resolve('babel-loader'))
|
|
43
|
-
.options({
|
|
44
|
-
sourceType: 'unambiguous',
|
|
45
|
-
presets: [
|
|
46
|
-
[
|
|
47
|
-
require.resolve('@babel/preset-typescript'),
|
|
48
|
-
{
|
|
49
|
-
allExtensions: true,
|
|
50
|
-
isTSX: true
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
require.resolve('@babel/preset-env'),
|
|
55
|
-
{
|
|
56
|
-
useBuiltIns: false,
|
|
57
|
-
corejs: {
|
|
58
|
-
version: 3,
|
|
59
|
-
proposals: true
|
|
60
|
-
},
|
|
61
|
-
shippedProposals: true,
|
|
62
|
-
targets: const_1.default.PROD_BROWSERSLIST
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
],
|
|
66
|
-
plugins: [[require.resolve('@babel/plugin-transform-runtime'), { corejs: false }]]
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
chain.optimization.minimizer('js').use(require.resolve('terser-webpack-plugin'), [
|
|
70
|
-
{
|
|
71
|
-
terserOptions: {
|
|
72
|
-
safari10: true,
|
|
73
|
-
compress: { drop_console: false }
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
chain.optimization.minimize(!!compressJs);
|
|
79
|
-
};
|
|
80
|
-
exports.default = getProdConfig;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import type { MPPackSetting } from "xhs-mp-pack";
|
|
2
|
-
import type { Project } from "xhs-mp-project";
|
|
3
|
-
export declare enum ENV {
|
|
4
|
-
development = 0,
|
|
5
|
-
production = 1
|
|
6
|
-
}
|
|
7
|
-
export interface Component {
|
|
8
|
-
index?: number;
|
|
9
|
-
usingComponents?: {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
};
|
|
12
|
-
componentPlaceholder?: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface Page {
|
|
17
|
-
path: string;
|
|
18
|
-
usingComponents?: {
|
|
19
|
-
[key: string]: string;
|
|
20
|
-
};
|
|
21
|
-
componentPlaceholder?: {
|
|
22
|
-
[key: string]: string;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export interface SubPackage {
|
|
26
|
-
root: string;
|
|
27
|
-
pages: Page[];
|
|
28
|
-
independent?: boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare enum CodePackageMode {
|
|
31
|
-
default = "default",
|
|
32
|
-
requiredComponents = "requiredComponents"
|
|
33
|
-
}
|
|
34
|
-
export interface AppJSON {
|
|
35
|
-
pages: Page[];
|
|
36
|
-
subPackages: SubPackage[];
|
|
37
|
-
subpackages: SubPackage[];
|
|
38
|
-
usingComponents?: {
|
|
39
|
-
[key: string]: string;
|
|
40
|
-
};
|
|
41
|
-
lazyCodeLoading?: CodePackageMode;
|
|
42
|
-
componentsMap: {
|
|
43
|
-
[key: string]: Component;
|
|
44
|
-
};
|
|
45
|
-
xhsVersionStrategy: {
|
|
46
|
-
[key: string]: string | boolean;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export interface ICompilerConfig {
|
|
50
|
-
/**
|
|
51
|
-
* 小程序入口目录
|
|
52
|
-
*/
|
|
53
|
-
projectPath: string;
|
|
54
|
-
miniprogramDir: string;
|
|
55
|
-
/**
|
|
56
|
-
* 构建产物目录
|
|
57
|
-
*/
|
|
58
|
-
distDir?: string;
|
|
59
|
-
action: "dev" | "build";
|
|
60
|
-
watch?: boolean;
|
|
61
|
-
env: ENV;
|
|
62
|
-
tsConfigPath?: string;
|
|
63
|
-
/**
|
|
64
|
-
* ext json path
|
|
65
|
-
*/
|
|
66
|
-
extJsonPath?: string;
|
|
67
|
-
cacheDirectory?: string;
|
|
68
|
-
/**
|
|
69
|
-
* 是否开启 Js 编译压缩
|
|
70
|
-
*/
|
|
71
|
-
compressJs?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* 打包是否包含 js 文件
|
|
74
|
-
*/
|
|
75
|
-
noJs?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* dev 模式是否开启 sourcemap,默认开启
|
|
78
|
-
*/
|
|
79
|
-
enableSourcemap?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* 服务端口
|
|
82
|
-
*/
|
|
83
|
-
port?: number;
|
|
84
|
-
enableV1?: boolean;
|
|
85
|
-
enableV2?: boolean;
|
|
86
|
-
enableVDom?: boolean;
|
|
87
|
-
}
|
|
88
|
-
type CliPick = 'projectPath' | 'distDir' | 'watch' | 'tsConfigPath' | 'extJsonPath' | 'cacheDirectory' | 'compressJs' | 'enableSourcemap' | 'enableV1' | 'enableV2' | 'enableVDom';
|
|
89
|
-
export interface IStart extends Pick<ICompilerConfig, CliPick> {
|
|
90
|
-
packMode?: 'webpack' | 'mp-pack';
|
|
91
|
-
/**
|
|
92
|
-
* 调用的能力,dev 还是 build
|
|
93
|
-
*/
|
|
94
|
-
action: 'dev' | 'build';
|
|
95
|
-
/**
|
|
96
|
-
* 是否启动dev-server
|
|
97
|
-
*/
|
|
98
|
-
enableDevServer?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* 每次构建完毕的回调函数
|
|
101
|
-
*/
|
|
102
|
-
callback?: () => void;
|
|
103
|
-
/**
|
|
104
|
-
* 构建产物目录
|
|
105
|
-
*/
|
|
106
|
-
distDir?: string;
|
|
107
|
-
platform?: 'wx' | 'xhs';
|
|
108
|
-
/**
|
|
109
|
-
* 服务端口
|
|
110
|
-
*/
|
|
111
|
-
devServerPort?: number;
|
|
112
|
-
}
|
|
113
|
-
export type IPresetOptions = {
|
|
114
|
-
project: Project;
|
|
115
|
-
packSetting: MPPackSetting;
|
|
116
|
-
otherSetting?: any;
|
|
117
|
-
};
|
|
118
|
-
export {};
|
package/dist/types/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CodePackageMode = exports.ENV = void 0;
|
|
4
|
-
var ENV;
|
|
5
|
-
(function (ENV) {
|
|
6
|
-
ENV[ENV["development"] = 0] = "development";
|
|
7
|
-
ENV[ENV["production"] = 1] = "production";
|
|
8
|
-
})(ENV || (exports.ENV = ENV = {}));
|
|
9
|
-
var CodePackageMode;
|
|
10
|
-
(function (CodePackageMode) {
|
|
11
|
-
CodePackageMode["default"] = "default";
|
|
12
|
-
CodePackageMode["requiredComponents"] = "requiredComponents";
|
|
13
|
-
})(CodePackageMode || (exports.CodePackageMode = CodePackageMode = {}));
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
16
|
-
const webpackCompile = (config, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
return new Promise((res, rej) => {
|
|
18
|
-
(0, webpack_1.default)(config, (err, stats) => {
|
|
19
|
-
if (err) {
|
|
20
|
-
// eslint-disable-next-line
|
|
21
|
-
console.log(err);
|
|
22
|
-
rej(err);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// eslint-disable-next-line
|
|
26
|
-
console.log(stats === null || stats === void 0 ? void 0 : stats.toString({
|
|
27
|
-
modules: true,
|
|
28
|
-
chunks: true,
|
|
29
|
-
children: false,
|
|
30
|
-
colors: true,
|
|
31
|
-
}));
|
|
32
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
33
|
-
res(stats);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
exports.default = webpackCompile;
|
package/dist/utils/common.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const getTsConfigPath: (projectPath: string) => string | undefined;
|
|
2
|
-
export declare const isString: (val: unknown) => val is string;
|
|
3
|
-
export declare const toUnixPath: (pathStr?: string) => string;
|
|
4
|
-
export declare const unixJoin: (...paths: string[]) => string;
|
|
5
|
-
export declare const unixResolve: (...paths: string[]) => string;
|
|
6
|
-
export declare const getShortPath: (miniprogramDir: string, rootContext: string) => string;
|
|
7
|
-
export declare const md5: (str: string) => string;
|
|
8
|
-
export declare const DEFAULT_ENTRY = "game";
|
package/dist/utils/common.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_ENTRY = exports.md5 = exports.getShortPath = exports.unixResolve = exports.unixJoin = exports.toUnixPath = exports.isString = exports.getTsConfigPath = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
10
|
-
const getSuffixName_1 = require("./getSuffixName");
|
|
11
|
-
const getTsConfigPath = (projectPath) => {
|
|
12
|
-
if (fs_extra_1.default.existsSync(`${projectPath}/tsconfig.json`)) {
|
|
13
|
-
return `${projectPath}/tsconfig.json`;
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
};
|
|
17
|
-
exports.getTsConfigPath = getTsConfigPath;
|
|
18
|
-
const isString = (val) => typeof val === 'string';
|
|
19
|
-
exports.isString = isString;
|
|
20
|
-
const toUnixPath = (pathStr = '') => pathStr.split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
21
|
-
exports.toUnixPath = toUnixPath;
|
|
22
|
-
const unixJoin = (...paths) => (0, exports.toUnixPath)(path_1.default.join(...paths));
|
|
23
|
-
exports.unixJoin = unixJoin;
|
|
24
|
-
const unixResolve = (...paths) => (0, exports.toUnixPath)(path_1.default.resolve(...paths));
|
|
25
|
-
exports.unixResolve = unixResolve;
|
|
26
|
-
const getShortPath = (miniprogramDir, rootContext) => {
|
|
27
|
-
const suffix = (0, getSuffixName_1.getMlSuffixName)();
|
|
28
|
-
miniprogramDir = (0, exports.toUnixPath)(miniprogramDir);
|
|
29
|
-
miniprogramDir = miniprogramDir.endsWith('/') ? miniprogramDir : `${miniprogramDir}/`;
|
|
30
|
-
const reg = new RegExp(`.${suffix}$`, 'g');
|
|
31
|
-
return (0, exports.toUnixPath)(rootContext).replace(reg, '').replace(miniprogramDir, '');
|
|
32
|
-
};
|
|
33
|
-
exports.getShortPath = getShortPath;
|
|
34
|
-
const md5 = (str) => crypto_1.default.createHash('md5').update(str).digest('hex');
|
|
35
|
-
exports.md5 = md5;
|
|
36
|
-
exports.DEFAULT_ENTRY = "game";
|
package/dist/utils/const.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
declare const CONSTANTS: {
|
|
2
|
-
PROD_BROWSERSLIST: string[];
|
|
3
|
-
DEV_BROWSERSLIST: string[];
|
|
4
|
-
DEV_TARGETS: {
|
|
5
|
-
chrome: string;
|
|
6
|
-
};
|
|
7
|
-
PROD_TARGETS: {
|
|
8
|
-
chrome: string;
|
|
9
|
-
ios: string;
|
|
10
|
-
};
|
|
11
|
-
ENTRY_CSS_NAME: string;
|
|
12
|
-
FULL_PKG: string;
|
|
13
|
-
MAIN_PKG: string;
|
|
14
|
-
SUB_PKG: string;
|
|
15
|
-
BUILD_REASON: {
|
|
16
|
-
INIT: string;
|
|
17
|
-
FILE_CHANGE: string;
|
|
18
|
-
ACTIVATE_PKG: string;
|
|
19
|
-
RECOMPILE: string;
|
|
20
|
-
};
|
|
21
|
-
ASSETS_EXTS: string[];
|
|
22
|
-
PACK_MODE: {
|
|
23
|
-
MPPACK: string;
|
|
24
|
-
WEBPACK: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export default CONSTANTS;
|
package/dist/utils/const.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CONSTANTS = {
|
|
4
|
-
PROD_BROWSERSLIST: ['ios_saf >= 10', 'chrome >= 83'],
|
|
5
|
-
DEV_BROWSERSLIST: ['last 2 chrome version'],
|
|
6
|
-
DEV_TARGETS: {
|
|
7
|
-
chrome: '90',
|
|
8
|
-
},
|
|
9
|
-
PROD_TARGETS: {
|
|
10
|
-
chrome: '83',
|
|
11
|
-
ios: '10'
|
|
12
|
-
},
|
|
13
|
-
ENTRY_CSS_NAME: 'app',
|
|
14
|
-
FULL_PKG: 'xhs-full',
|
|
15
|
-
MAIN_PKG: 'xhs-main',
|
|
16
|
-
SUB_PKG: 'xhs-sub',
|
|
17
|
-
BUILD_REASON: {
|
|
18
|
-
INIT: 'INIT',
|
|
19
|
-
FILE_CHANGE: 'FILE_CHANGE',
|
|
20
|
-
ACTIVATE_PKG: 'ACTIVATE_PKG',
|
|
21
|
-
RECOMPILE: 'RECOMPILE',
|
|
22
|
-
},
|
|
23
|
-
ASSETS_EXTS: [
|
|
24
|
-
'png',
|
|
25
|
-
'jpg',
|
|
26
|
-
'jpeg',
|
|
27
|
-
'gif',
|
|
28
|
-
'svg',
|
|
29
|
-
'webp',
|
|
30
|
-
'cer',
|
|
31
|
-
'mp3',
|
|
32
|
-
'aac',
|
|
33
|
-
'm4a',
|
|
34
|
-
'mp4',
|
|
35
|
-
'wav',
|
|
36
|
-
'ogg',
|
|
37
|
-
'silk',
|
|
38
|
-
'wasm',
|
|
39
|
-
'br',
|
|
40
|
-
'plist',
|
|
41
|
-
],
|
|
42
|
-
PACK_MODE: {
|
|
43
|
-
MPPACK: 'mp-pack',
|
|
44
|
-
WEBPACK: 'webpack'
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.default = CONSTANTS;
|
package/dist/utils/css.d.ts
DELETED