@tarojs/service 3.5.0-canary.1 → 3.5.0
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/dist/Config.js +8 -7
- package/dist/Config.js.map +1 -0
- package/dist/Kernel.d.ts +3 -4
- package/dist/Kernel.js +36 -35
- package/dist/Kernel.js.map +1 -0
- package/dist/Plugin.d.ts +1 -1
- package/dist/Plugin.js +2 -1
- package/dist/Plugin.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/platform-plugin-base.d.ts +1 -0
- package/dist/platform-plugin-base.js +36 -15
- package/dist/platform-plugin-base.js.map +1 -0
- package/dist/utils/constants.js +1 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +12 -5
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/types.js +1 -0
- package/dist/utils/types.js.map +1 -0
- package/index.js +1 -0
- package/package.json +18 -19
- package/src/Config.ts +16 -11
- package/src/Kernel.ts +48 -40
- package/src/Plugin.ts +1 -1
- package/src/platform-plugin-base.ts +40 -14
- package/src/utils/index.ts +10 -7
- package/src/utils/types.ts +2 -2
- package/types/index.d.ts +1 -1
package/dist/Config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const helper_1 = require("@tarojs/helper");
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
|
+
const path = require("path");
|
|
5
6
|
const merge = require("webpack-merge");
|
|
6
|
-
const helper_1 = require("@tarojs/helper");
|
|
7
7
|
const constants_1 = require("./utils/constants");
|
|
8
8
|
class Config {
|
|
9
9
|
constructor(opts) {
|
|
@@ -11,19 +11,19 @@ class Config {
|
|
|
11
11
|
this.init();
|
|
12
12
|
}
|
|
13
13
|
init() {
|
|
14
|
-
this.configPath = helper_1.resolveScriptPath(path.join(this.appPath, constants_1.CONFIG_DIR_NAME, constants_1.DEFAULT_CONFIG_FILE));
|
|
14
|
+
this.configPath = (0, helper_1.resolveScriptPath)(path.join(this.appPath, constants_1.CONFIG_DIR_NAME, constants_1.DEFAULT_CONFIG_FILE));
|
|
15
15
|
if (!fs.existsSync(this.configPath)) {
|
|
16
16
|
this.initialConfig = {};
|
|
17
17
|
this.isInitSuccess = false;
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
helper_1.
|
|
20
|
+
(0, helper_1.createSwcRegister)({
|
|
21
21
|
only: [
|
|
22
22
|
filePath => filePath.indexOf(path.join(this.appPath, constants_1.CONFIG_DIR_NAME)) >= 0
|
|
23
23
|
]
|
|
24
24
|
});
|
|
25
25
|
try {
|
|
26
|
-
this.initialConfig = helper_1.getModuleDefaultExport(require(this.configPath))(merge);
|
|
26
|
+
this.initialConfig = (0, helper_1.getModuleDefaultExport)(require(this.configPath))(merge);
|
|
27
27
|
this.isInitSuccess = true;
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
@@ -39,11 +39,12 @@ class Config {
|
|
|
39
39
|
const outputDirName = initialConfig.outputRoot || helper_1.OUTPUT_DIR;
|
|
40
40
|
const sourceDir = path.join(this.appPath, sourceDirName);
|
|
41
41
|
const entryName = helper_1.ENTRY;
|
|
42
|
-
const entryFilePath = helper_1.resolveScriptPath(path.join(sourceDir, entryName));
|
|
42
|
+
const entryFilePath = (0, helper_1.resolveScriptPath)(path.join(sourceDir, entryName));
|
|
43
43
|
const entry = {
|
|
44
44
|
[entryName]: [entryFilePath]
|
|
45
45
|
};
|
|
46
|
-
return Object.assign({ entry, alias: initialConfig.alias || {}, copy: initialConfig.copy, sourceRoot: sourceDirName, outputRoot: outputDirName, platform, framework: initialConfig.framework, baseLevel: initialConfig.baseLevel, csso: initialConfig.csso, sass: initialConfig.sass, uglify: initialConfig.uglify, plugins: initialConfig.plugins, projectName: initialConfig.projectName, env: initialConfig.env, defineConstants: initialConfig.defineConstants, designWidth: initialConfig.designWidth, deviceRatio: initialConfig.deviceRatio, projectConfigName: initialConfig.projectConfigName, terser: initialConfig.terser }, initialConfig[useConfigName]);
|
|
46
|
+
return Object.assign({ entry, alias: initialConfig.alias || {}, copy: initialConfig.copy, sourceRoot: sourceDirName, outputRoot: outputDirName, platform, framework: initialConfig.framework, compiler: initialConfig.compiler, cache: initialConfig.cache, logger: initialConfig.logger, baseLevel: initialConfig.baseLevel, csso: initialConfig.csso, sass: initialConfig.sass, uglify: initialConfig.uglify, plugins: initialConfig.plugins, projectName: initialConfig.projectName, env: initialConfig.env, defineConstants: initialConfig.defineConstants, designWidth: initialConfig.designWidth, deviceRatio: initialConfig.deviceRatio, projectConfigName: initialConfig.projectConfigName, jsMinimizer: initialConfig.jsMinimizer, cssMinimizer: initialConfig.cssMinimizer, terser: initialConfig.terser, esbuild: initialConfig.esbuild }, initialConfig[useConfigName]);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
exports.default = Config;
|
|
50
|
+
//# sourceMappingURL=Config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":";;AAAA,2CAOuB;AAEvB,+BAA8B;AAC9B,6BAA4B;AAC5B,uCAAsC;AAEtC,iDAG0B;AAM1B,MAAqB,MAAM;IAKzB,YAAa,IAAoB;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,GAAG,IAAA,0BAAiB,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,2BAAe,EAAE,+BAAmB,CAAC,CAAC,CAAA;QAClG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACnC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAA;YACvB,IAA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AAC,IAAI,EACxB,UAAU,EAAE,aAAa,EACzB,UAAU,EAAE,aAAa,EACzB,QAAQ,EACR,SAAS,EAAE,aAAa,CAAC,SAAS,EAClC,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAChC,KAAK,EAAE,aAAa,CAAC,KAAK,EAC1B,MAAM,EAAE,aAAa,CAAC,MAAM,EAC5B,SAAS,EAAE,aAAa,CAAC,SAAS,EAClC,IAAI,EAAE,aAAa,CAAC,IAAI,EACxB,IAAI,EAAE,aAAa,CAAC,IAAI,EACxB,MAAM,EAAE,aAAa,CAAC,MAAM,EAC5B,OAAO,EAAE,aAAa,CAAC,OAAO,EAC9B,WAAW,EAAE,aAAa,CAAC,WAAW,EACtC,GAAG,EAAE,aAAa,CAAC,GAAG,EACtB,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,WAAW,EAAE,aAAa,CAAC,WAAW,EACtC,WAAW,EAAE,aAAa,CAAC,WAAW,EACtC,iBAAiB,EAAE,aAAa,CAAC,iBAAiB,EAClD,WAAW,EAAE,aAAa,CAAC,WAAW,EACtC,YAAY,EAAE,aAAa,CAAC,YAAY,EACxC,MAAM,EAAE,aAAa,CAAC,MAAM,EAC5B,OAAO,EAAE,aAAa,CAAC,OAAO,IAC3B,aAAa,CAAC,aAAa,CAAC,EAChC;IACH,CAAC;CACF;AAzED,yBAyEC"}
|
package/dist/Kernel.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
2
|
import { IProjectConfig, PluginItem } from '@tarojs/taro/types/compile';
|
|
4
|
-
import {
|
|
5
|
-
import Plugin from './Plugin';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
6
4
|
import Config from './Config';
|
|
5
|
+
import Plugin from './Plugin';
|
|
6
|
+
import { ICommand, IHook, IPaths, IPlatform, IPlugin, IPluginsObject, IPreset } from './utils/types';
|
|
7
7
|
interface IKernelOptions {
|
|
8
8
|
appPath: string;
|
|
9
9
|
presets?: PluginItem[];
|
|
@@ -28,7 +28,6 @@ export default class Kernel extends EventEmitter {
|
|
|
28
28
|
runOpts: any;
|
|
29
29
|
debugger: any;
|
|
30
30
|
constructor(options: IKernelOptions);
|
|
31
|
-
init(): Promise<void>;
|
|
32
31
|
initConfig(): void;
|
|
33
32
|
initPaths(): void;
|
|
34
33
|
initHelper(): void;
|
package/dist/Kernel.js
CHANGED
|
@@ -9,21 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const helper_1 = require("@tarojs/helper");
|
|
13
|
+
const helper = require("@tarojs/helper");
|
|
13
14
|
const events_1 = require("events");
|
|
14
15
|
const lodash_1 = require("lodash");
|
|
16
|
+
const path = require("path");
|
|
15
17
|
const tapable_1 = require("tapable");
|
|
16
|
-
const helper_1 = require("@tarojs/helper");
|
|
17
|
-
const helper = require("@tarojs/helper");
|
|
18
|
-
const joi = require("@hapi/joi");
|
|
19
|
-
const constants_1 = require("./utils/constants");
|
|
20
|
-
const utils_1 = require("./utils");
|
|
21
|
-
const Plugin_1 = require("./Plugin");
|
|
22
18
|
const Config_1 = require("./Config");
|
|
19
|
+
const Plugin_1 = require("./Plugin");
|
|
20
|
+
const utils_1 = require("./utils");
|
|
21
|
+
const constants_1 = require("./utils/constants");
|
|
23
22
|
class Kernel extends events_1.EventEmitter {
|
|
24
23
|
constructor(options) {
|
|
25
24
|
super();
|
|
26
|
-
this.debugger = helper_1.createDebug('Taro:Kernel');
|
|
25
|
+
this.debugger = process.env.DEBUG === 'Taro:Kernel' ? (0, helper_1.createDebug)('Taro:Kernel') : function () { };
|
|
27
26
|
this.appPath = options.appPath || process.cwd();
|
|
28
27
|
this.optsPresets = options.presets;
|
|
29
28
|
this.optsPlugins = options.plugins;
|
|
@@ -32,15 +31,8 @@ class Kernel extends events_1.EventEmitter {
|
|
|
32
31
|
this.commands = new Map();
|
|
33
32
|
this.platforms = new Map();
|
|
34
33
|
this.initHelper();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
this.debugger('init');
|
|
39
|
-
this.initConfig();
|
|
40
|
-
this.initPaths();
|
|
41
|
-
this.initPresetsAndPlugins();
|
|
42
|
-
yield this.applyPlugins('onReady');
|
|
43
|
-
});
|
|
34
|
+
this.initConfig();
|
|
35
|
+
this.initPaths();
|
|
44
36
|
}
|
|
45
37
|
initConfig() {
|
|
46
38
|
this.config = new Config_1.default({
|
|
@@ -52,13 +44,13 @@ class Kernel extends events_1.EventEmitter {
|
|
|
52
44
|
initPaths() {
|
|
53
45
|
this.paths = {
|
|
54
46
|
appPath: this.appPath,
|
|
55
|
-
nodeModulesPath: helper_1.recursiveFindNodeModules(path.join(this.appPath, helper_1.NODE_MODULES))
|
|
47
|
+
nodeModulesPath: (0, helper_1.recursiveFindNodeModules)(path.join(this.appPath, helper_1.NODE_MODULES))
|
|
56
48
|
};
|
|
57
49
|
if (this.config.isInitSuccess) {
|
|
58
50
|
Object.assign(this.paths, {
|
|
59
51
|
configPath: this.config.configPath,
|
|
60
52
|
sourcePath: path.join(this.appPath, this.initialConfig.sourceRoot),
|
|
61
|
-
outputPath: path.
|
|
53
|
+
outputPath: path.join(this.appPath, this.initialConfig.outputRoot)
|
|
62
54
|
});
|
|
63
55
|
}
|
|
64
56
|
this.debugger(`initPaths:${JSON.stringify(this.paths, null, 2)}`);
|
|
@@ -69,11 +61,11 @@ class Kernel extends events_1.EventEmitter {
|
|
|
69
61
|
}
|
|
70
62
|
initPresetsAndPlugins() {
|
|
71
63
|
const initialConfig = this.initialConfig;
|
|
72
|
-
const allConfigPresets = utils_1.mergePlugins(this.optsPresets || [], initialConfig.presets || [])();
|
|
73
|
-
const allConfigPlugins = utils_1.mergePlugins(this.optsPlugins || [], initialConfig.plugins || [])();
|
|
64
|
+
const allConfigPresets = (0, utils_1.mergePlugins)(this.optsPresets || [], initialConfig.presets || [])();
|
|
65
|
+
const allConfigPlugins = (0, utils_1.mergePlugins)(this.optsPlugins || [], initialConfig.plugins || [])();
|
|
74
66
|
this.debugger('initPresetsAndPlugins', allConfigPresets, allConfigPlugins);
|
|
75
67
|
process.env.NODE_ENV !== 'test' &&
|
|
76
|
-
helper_1.
|
|
68
|
+
(0, helper_1.createSwcRegister)({
|
|
77
69
|
only: [...Object.keys(allConfigPresets), ...Object.keys(allConfigPlugins)]
|
|
78
70
|
});
|
|
79
71
|
this.plugins = new Map();
|
|
@@ -82,14 +74,14 @@ class Kernel extends events_1.EventEmitter {
|
|
|
82
74
|
this.resolvePlugins(allConfigPlugins);
|
|
83
75
|
}
|
|
84
76
|
resolvePresets(presets) {
|
|
85
|
-
const allPresets = utils_1.resolvePresetsOrPlugins(this.appPath, presets, constants_1.PluginType.Preset);
|
|
77
|
+
const allPresets = (0, utils_1.resolvePresetsOrPlugins)(this.appPath, presets, constants_1.PluginType.Preset);
|
|
86
78
|
while (allPresets.length) {
|
|
87
79
|
this.initPreset(allPresets.shift());
|
|
88
80
|
}
|
|
89
81
|
}
|
|
90
82
|
resolvePlugins(plugins) {
|
|
91
|
-
plugins = lodash_1.merge(this.extraPlugins, plugins);
|
|
92
|
-
const allPlugins = utils_1.resolvePresetsOrPlugins(this.appPath, plugins, constants_1.PluginType.Plugin);
|
|
83
|
+
plugins = (0, lodash_1.merge)(this.extraPlugins, plugins);
|
|
84
|
+
const allPlugins = (0, utils_1.resolvePresetsOrPlugins)(this.appPath, plugins, constants_1.PluginType.Plugin);
|
|
93
85
|
while (allPlugins.length) {
|
|
94
86
|
this.initPlugin(allPlugins.shift());
|
|
95
87
|
}
|
|
@@ -102,13 +94,13 @@ class Kernel extends events_1.EventEmitter {
|
|
|
102
94
|
const { presets, plugins } = apply()(pluginCtx, opts) || {};
|
|
103
95
|
this.registerPlugin(preset);
|
|
104
96
|
if (Array.isArray(presets)) {
|
|
105
|
-
const _presets = utils_1.resolvePresetsOrPlugins(this.appPath, utils_1.convertPluginsToObject(presets)(), constants_1.PluginType.Preset);
|
|
97
|
+
const _presets = (0, utils_1.resolvePresetsOrPlugins)(this.appPath, (0, utils_1.convertPluginsToObject)(presets)(), constants_1.PluginType.Preset);
|
|
106
98
|
while (_presets.length) {
|
|
107
99
|
this.initPreset(_presets.shift());
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
if (Array.isArray(plugins)) {
|
|
111
|
-
this.extraPlugins = lodash_1.merge(this.extraPlugins, utils_1.convertPluginsToObject(plugins)());
|
|
103
|
+
this.extraPlugins = (0, lodash_1.merge)(this.extraPlugins, (0, utils_1.convertPluginsToObject)(plugins)());
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
initPlugin(plugin) {
|
|
@@ -123,6 +115,8 @@ class Kernel extends events_1.EventEmitter {
|
|
|
123
115
|
if (typeof pluginCtx.optsSchema !== 'function') {
|
|
124
116
|
return;
|
|
125
117
|
}
|
|
118
|
+
this.debugger('checkPluginOpts', pluginCtx);
|
|
119
|
+
const joi = require('joi');
|
|
126
120
|
const schema = pluginCtx.optsSchema(joi);
|
|
127
121
|
if (!joi.isSchema(schema)) {
|
|
128
122
|
throw new Error(`插件${pluginCtx.id}中设置参数检查 schema 有误,请检查!`);
|
|
@@ -134,6 +128,7 @@ class Kernel extends events_1.EventEmitter {
|
|
|
134
128
|
}
|
|
135
129
|
}
|
|
136
130
|
registerPlugin(plugin) {
|
|
131
|
+
this.debugger('registerPlugin', plugin);
|
|
137
132
|
if (this.plugins.has(plugin.id)) {
|
|
138
133
|
throw new Error(`插件 ${plugin.id} 已被注册`);
|
|
139
134
|
}
|
|
@@ -198,6 +193,9 @@ class Kernel extends events_1.EventEmitter {
|
|
|
198
193
|
throw new Error('调用失败,未传入正确的名称!');
|
|
199
194
|
}
|
|
200
195
|
const hooks = this.hooks.get(name) || [];
|
|
196
|
+
if (!hooks.length) {
|
|
197
|
+
return yield initialVal;
|
|
198
|
+
}
|
|
201
199
|
const waterfall = new tapable_1.AsyncSeriesWaterfallHook(['arg']);
|
|
202
200
|
if (hooks.length) {
|
|
203
201
|
const resArr = [];
|
|
@@ -242,7 +240,7 @@ class Kernel extends events_1.EventEmitter {
|
|
|
242
240
|
customOptionsMap = new Map(Object.entries(command === null || command === void 0 ? void 0 : command.optionsMap));
|
|
243
241
|
}
|
|
244
242
|
const optionsMap = new Map([...customOptionsMap, ...defaultOptionsMap]);
|
|
245
|
-
utils_1.printHelpLog(name, optionsMap, (command === null || command === void 0 ? void 0 : command.synopsisList) ? new Set(command === null || command === void 0 ? void 0 : command.synopsisList) : new Set());
|
|
243
|
+
(0, utils_1.printHelpLog)(name, optionsMap, (command === null || command === void 0 ? void 0 : command.synopsisList) ? new Set(command === null || command === void 0 ? void 0 : command.synopsisList) : new Set());
|
|
246
244
|
}
|
|
247
245
|
run(args) {
|
|
248
246
|
var _a;
|
|
@@ -261,7 +259,9 @@ class Kernel extends events_1.EventEmitter {
|
|
|
261
259
|
this.debugger('command:runOpts');
|
|
262
260
|
this.debugger(`command:runOpts:${JSON.stringify(opts, null, 2)}`);
|
|
263
261
|
this.setRunOpts(opts);
|
|
264
|
-
|
|
262
|
+
this.debugger('initPresetsAndPlugins');
|
|
263
|
+
this.initPresetsAndPlugins();
|
|
264
|
+
yield this.applyPlugins('onReady');
|
|
265
265
|
this.debugger('command:onStart');
|
|
266
266
|
yield this.applyPlugins('onStart');
|
|
267
267
|
if (!this.commands.has(name)) {
|
|
@@ -272,13 +272,13 @@ class Kernel extends events_1.EventEmitter {
|
|
|
272
272
|
}
|
|
273
273
|
if ((_a = opts === null || opts === void 0 ? void 0 : opts.options) === null || _a === void 0 ? void 0 : _a.platform) {
|
|
274
274
|
opts.config = this.runWithPlatform(opts.options.platform);
|
|
275
|
+
yield this.applyPlugins({
|
|
276
|
+
name: 'modifyRunnerOpts',
|
|
277
|
+
opts: {
|
|
278
|
+
opts: opts === null || opts === void 0 ? void 0 : opts.config
|
|
279
|
+
}
|
|
280
|
+
});
|
|
275
281
|
}
|
|
276
|
-
yield this.applyPlugins({
|
|
277
|
-
name: 'modifyRunnerOpts',
|
|
278
|
-
opts: {
|
|
279
|
-
opts: opts === null || opts === void 0 ? void 0 : opts.config
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
282
|
yield this.applyPlugins({
|
|
283
283
|
name,
|
|
284
284
|
opts
|
|
@@ -287,3 +287,4 @@ class Kernel extends events_1.EventEmitter {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
exports.default = Kernel;
|
|
290
|
+
//# sourceMappingURL=Kernel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kernel.js","sourceRoot":"","sources":["../src/Kernel.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAKuB;AACvB,yCAAwC;AAExC,mCAAqC;AACrC,mCAA8B;AAC9B,6BAA4B;AAC5B,qCAAkD;AAElD,qCAA6B;AAC7B,qCAA6B;AAC7B,mCAAqG;AACrG,iDAK0B;AAiB1B,MAAqB,MAAO,SAAQ,qBAAY;IAmB9C,YAAa,OAAuB;QAClC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,aAAa,CAAC,CAAC,CAAC,IAAA,oBAAW,EAAC,aAAa,CAAC,CAAC,CAAC,CAAC,cAAa,CAAC,CAAA;QACjG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;QAC/C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAA;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAA;QACxB,IAAI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A;;KACH;CACF;AA7SD,yBA6SC"}
|
package/dist/Plugin.d.ts
CHANGED
package/dist/Plugin.js
CHANGED
|
@@ -29,7 +29,7 @@ class Plugin {
|
|
|
29
29
|
if (this.ctx.platforms.has(platform.name)) {
|
|
30
30
|
throw new Error(`适配平台 ${platform.name} 已存在`);
|
|
31
31
|
}
|
|
32
|
-
helper_1.addPlatforms(platform.name);
|
|
32
|
+
(0, helper_1.addPlatforms)(platform.name);
|
|
33
33
|
this.ctx.platforms.set(platform.name, platform);
|
|
34
34
|
this.register(platform);
|
|
35
35
|
}
|
|
@@ -69,3 +69,4 @@ function processArgs(args) {
|
|
|
69
69
|
}
|
|
70
70
|
return { name, fn };
|
|
71
71
|
}
|
|
72
|
+
//# sourceMappingURL=Plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../src/Plugin.ts"],"names":[],"mappings":";;AAAA,2CAA6C;AAK7C,MAAqB,MAAM;IAMzB,YAAa,IAAI;QACf,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACrB,CAAC;IAED,QAAQ,CAAE,IAAW;QACnB,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,uCAAuC,CAAC,CAAA;SACtE;QACD,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,UAAU,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,uCAAuC,CAAC,CAAA;SACtE;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QACjD,IAAI,CAAC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AAQ,CAAC;gBACZ,IAAI;gBACJ,EAAE;aACH,CAAC,CAAA;QACJ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACb,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC;IAED,mBAAmB,CAAE,MAAM;QACzB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;IAC1B,CAAC;CACF;AAxDD,yBAwDC;AAED,SAAS,WAAW,CAAE,IAAI;IACxB,IAAI,IAAI,EAAE,EAAE,CAAA;IACZ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;KACxB;SAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC/B,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;SACf;aAAM;YACL,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YACnB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;SAChB;KACF;SAAM;QACL,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACd,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACb;IACD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;AACrB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,3 +6,4 @@ exports.Kernel = Kernel_1.default;
|
|
|
6
6
|
const platform_plugin_base_1 = require("./platform-plugin-base");
|
|
7
7
|
Object.defineProperty(exports, "TaroPlatformBase", { enumerable: true, get: function () { return platform_plugin_base_1.TaroPlatformBase; } });
|
|
8
8
|
exports.default = { Kernel: Kernel_1.default, TaroPlatformBase: platform_plugin_base_1.TaroPlatformBase };
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAA6B;AAGpB,iBAHF,gBAAM,CAGE;AAFf,iEAAyD;AAGhD,iGAHA,uCAAgB,OAGA;AACzB,kBAAe,EAAE,MAAM,EAAN,gBAAM,EAAE,gBAAgB,EAAhB,uCAAgB,EAAE,CAAA"}
|
|
@@ -40,6 +40,8 @@ class TaroPlatformBase {
|
|
|
40
40
|
this.ctx = ctx;
|
|
41
41
|
this.helper = ctx.helper;
|
|
42
42
|
this.config = config;
|
|
43
|
+
const _compiler = config.compiler;
|
|
44
|
+
this.compiler = typeof _compiler === 'object' ? _compiler.type : _compiler;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* 1. 清空 dist 文件夹
|
|
@@ -54,36 +56,46 @@ class TaroPlatformBase {
|
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
setupImpl() {
|
|
59
|
+
var _a;
|
|
57
60
|
const { needClearOutput } = this.config;
|
|
58
61
|
if (typeof needClearOutput === 'undefined' || !!needClearOutput) {
|
|
59
62
|
this.emptyOutputDir();
|
|
60
63
|
}
|
|
61
64
|
this.printDevelopmentTip(this.platform);
|
|
62
|
-
const { printLog, processTypeEnum } = this.ctx.helper;
|
|
63
|
-
printLog("start" /* START */, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`);
|
|
64
65
|
if (this.projectConfigJson) {
|
|
65
66
|
this.generateProjectConfig(this.projectConfigJson);
|
|
66
67
|
}
|
|
68
|
+
if (((_a = this.ctx.initialConfig.logger) === null || _a === void 0 ? void 0 : _a.quiet) === false) {
|
|
69
|
+
const { printLog, processTypeEnum } = this.ctx.helper;
|
|
70
|
+
printLog(processTypeEnum.START, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`);
|
|
71
|
+
}
|
|
67
72
|
}
|
|
68
73
|
emptyOutputDir() {
|
|
69
74
|
const { outputPath } = this.ctx.paths;
|
|
70
75
|
this.helper.emptyDirectory(outputPath);
|
|
71
76
|
}
|
|
72
77
|
printDevelopmentTip(platform) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
const tips = [];
|
|
80
|
+
const config = this.config;
|
|
81
|
+
const { chalk } = this.helper;
|
|
82
|
+
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
|
83
|
+
const { isWindows } = this.helper;
|
|
84
|
+
const exampleCommand = isWindows
|
|
85
|
+
? `$ set NODE_ENV=production && taro build --type ${platform} --watch`
|
|
86
|
+
: `$ NODE_ENV=production taro build --type ${platform} --watch`;
|
|
87
|
+
tips.push(chalk.yellowBright(`预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
|
|
88
|
+
Example:
|
|
89
|
+
${exampleCommand}`));
|
|
79
90
|
}
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
if (this.compiler === 'webpack5' && !((_a = config.cache) === null || _a === void 0 ? void 0 : _a.enable)) {
|
|
92
|
+
tips.push(chalk.yellowBright('建议开启持久化缓存功能,能有效提升二次编译速度,详情请参考: https://docs.taro.zone/docs/config-detail#cache。'));
|
|
93
|
+
}
|
|
94
|
+
if (tips.length) {
|
|
95
|
+
console.log(chalk.yellowBright('Tips:'));
|
|
96
|
+
tips.forEach((item, index) => console.log(`${chalk.yellowBright(index + 1)}. ${item}`));
|
|
97
|
+
console.log('\n');
|
|
82
98
|
}
|
|
83
|
-
console.log(chalk.yellowBright(`Tips: 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
|
|
84
|
-
Example:
|
|
85
|
-
${exampleCommand}
|
|
86
|
-
`));
|
|
87
99
|
}
|
|
88
100
|
/**
|
|
89
101
|
* 返回当前项目内的 @tarojs/mini-runner 包
|
|
@@ -92,7 +104,15 @@ ${exampleCommand}
|
|
|
92
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
105
|
const { appPath } = this.ctx.paths;
|
|
94
106
|
const { npm } = this.helper;
|
|
95
|
-
|
|
107
|
+
let runnerPkg;
|
|
108
|
+
switch (this.compiler) {
|
|
109
|
+
case 'webpack5':
|
|
110
|
+
runnerPkg = '@tarojs/webpack5-runner';
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
runnerPkg = '@tarojs/mini-runner';
|
|
114
|
+
}
|
|
115
|
+
const runner = yield npm.getNpmPkg(runnerPkg, appPath);
|
|
96
116
|
return runner.bind(null, appPath);
|
|
97
117
|
});
|
|
98
118
|
}
|
|
@@ -171,3 +191,4 @@ ${exampleCommand}
|
|
|
171
191
|
}
|
|
172
192
|
}
|
|
173
193
|
exports.TaroPlatformBase = TaroPlatformBase;
|
|
194
|
+
//# sourceMappingURL=platform-plugin-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-plugin-base.js","sourceRoot":"","sources":["../src/platform-plugin-base.ts"],"names":[],"mappings":";;;;;;;;;;;;AAiBA,MAAM,WAAW;IAAjB;QACE,aAAQ,GAAe,EAAE,CAAA;IAqB3B,CAAC;IAnBO,OAAO,CAAE,EAA4B,EAAE,KAAuB,EAAE,GAAG,IAAI;;YAC3E,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;YAC7B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;KAAA;IAED,OAAO,CAAE,KAAK;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,WAAC,OAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,IAAI,CAAC,KAAK,CAAC,CAAA,EAAA,CAAC,CAAA;IACxD,CAAC;IAED,QAAQ,CAAE,KAAK;QACb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CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;iBAC1D;gBACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAA;aAChB;iBAAM,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE;gBAChC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAA;aAChB;iBAAM,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;gBACvC,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;aAClD;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACU,KAAK;;YAChB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAClB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;KAAA;CACF;AAlLD,4CAkLC"}
|
package/dist/utils/constants.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA;AAC1B,QAAA,mBAAmB,GAAG,OAAO,CAAA;AAE7B,QAAA,aAAa,GAAG,iBAAiB,CAAA;AACjC,QAAA,aAAa,GAAG,iBAAiB,CAAA;AAEjC,QAAA,aAAa,GAAG,KAAK,CAAA;AACrB,QAAA,WAAW,GAAG,MAAM,CAAA;AACpB,QAAA,cAAc,GAAG,SAAS,CAAA;AAE1B,QAAA,uBAAuB,GAAG,IAAI,MAAM,CAAC,IAAI,qBAAa,IAAI,qBAAa,EAAE,CAAC,CAAA;AAEvF,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAEY,QAAA,gBAAgB,GAAG;IAC9B,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,qBAAa;IAClC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,qBAAa;CACnC,CAAA"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PluginItem } from '@tarojs/taro/types/compile';
|
|
1
|
+
import type { PluginItem } from '@tarojs/taro/types/compile';
|
|
2
2
|
import { PluginType } from './constants';
|
|
3
|
-
import {
|
|
3
|
+
import { IPlugin, IPluginsObject } from './types';
|
|
4
4
|
export declare const isNpmPkg: (name: string) => boolean;
|
|
5
5
|
export declare function getPluginPath(pluginPath: string): string;
|
|
6
6
|
export declare function convertPluginsToObject(items: PluginItem[]): () => IPluginsObject;
|
package/dist/utils/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printHelpLog = exports.resolvePresetsOrPlugins = exports.mergePlugins = exports.convertPluginsToObject = exports.getPluginPath = exports.isNpmPkg = void 0;
|
|
4
|
-
const
|
|
4
|
+
const helper_1 = require("@tarojs/helper");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
|
+
const path = require("path");
|
|
6
7
|
const resolve = require("resolve");
|
|
7
|
-
const helper_1 = require("@tarojs/helper");
|
|
8
8
|
const isNpmPkg = name => !(/^(\.|\/)/.test(name));
|
|
9
9
|
exports.isNpmPkg = isNpmPkg;
|
|
10
10
|
function getPluginPath(pluginPath) {
|
|
11
|
-
if (exports.isNpmPkg(pluginPath) || path.isAbsolute(pluginPath))
|
|
11
|
+
if ((0, exports.isNpmPkg)(pluginPath) || path.isAbsolute(pluginPath))
|
|
12
12
|
return pluginPath;
|
|
13
13
|
throw new Error('plugin 和 preset 配置必须为绝对路径或者包名');
|
|
14
14
|
}
|
|
@@ -36,7 +36,7 @@ function mergePlugins(dist, src) {
|
|
|
36
36
|
return () => {
|
|
37
37
|
const srcObj = convertPluginsToObject(src)();
|
|
38
38
|
const distObj = convertPluginsToObject(dist)();
|
|
39
|
-
return lodash_1.merge(distObj, srcObj);
|
|
39
|
+
return (0, lodash_1.merge)(distObj, srcObj);
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
exports.mergePlugins = mergePlugins;
|
|
@@ -67,7 +67,13 @@ function resolvePresetsOrPlugins(root, args, type) {
|
|
|
67
67
|
type,
|
|
68
68
|
opts: args[item] || {},
|
|
69
69
|
apply() {
|
|
70
|
-
|
|
70
|
+
try {
|
|
71
|
+
return (0, helper_1.getModuleDefaultExport)(require(fPath));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error(error);
|
|
75
|
+
throw new Error(`插件依赖 "${item}" 加载失败,请检查插件配置`);
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
};
|
|
73
79
|
});
|
|
@@ -97,3 +103,4 @@ function printHelpLog(command, optionsList, synopsisList) {
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
exports.printHelpLog = printHelpLog;
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAE9D,mCAA8B;AAC9B,6BAA4B;AAC5B,mCAAkC;AAK3B,MAAM,QAAQ,GAA8B,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAAtE,QAAA,QAAQ,YAA8D;AAEnF,SAAgB,aAAa,CAAE,UAAkB;IAC/C,IAAI,IAAA,gBAAQ,EAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAA;IAC1E,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;AAClD,CAAC;AAHD,sCAGC;AAED,SAAgB,sBAAsB,CAAE,KAAmB;IACzD,OAAO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AA;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACvC,OAAO,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACxC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IACb,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3B,MAAM,qBAAqB,GAAG,SAAS,GAAG,CAAC,CAAC,MAAM,CAAA;QAClD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;IACF,IAAI,YAAY,IAAI,YAAY,CAAC,IAAI,EAAE;QACrC,OAAO,CAAC,GAAG,EAAE,CAAA;QACb,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACxB,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;KACH;AACH,CAAC;AAnBD,oCAmBC"}
|
package/dist/utils/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/service",
|
|
3
|
-
"version": "3.5.0
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Taro Service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "run-s clean prod",
|
|
9
|
-
"dev": "tsc -w",
|
|
10
|
-
"prod": "tsc",
|
|
11
|
-
"clean": "rimraf dist",
|
|
12
|
-
"prepack": "npm run build",
|
|
13
|
-
"test": "jest",
|
|
14
|
-
"test:dev": "jest --watch"
|
|
15
|
-
},
|
|
16
7
|
"repository": {
|
|
17
8
|
"type": "git",
|
|
18
9
|
"url": "git+https://github.com/NervJS/taro.git"
|
|
@@ -33,14 +24,22 @@
|
|
|
33
24
|
},
|
|
34
25
|
"homepage": "https://github.com/NervJS/taro#readme",
|
|
35
26
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@tarojs/
|
|
38
|
-
"@tarojs/
|
|
39
|
-
"
|
|
40
|
-
"
|
|
27
|
+
"@tarojs/helper": "3.5.0",
|
|
28
|
+
"@tarojs/shared": "3.5.0",
|
|
29
|
+
"@tarojs/taro": "3.5.0",
|
|
30
|
+
"fs-extra": "^8.1.0",
|
|
31
|
+
"joi": "^17.6.0",
|
|
41
32
|
"lodash": "^4.17.21",
|
|
42
|
-
"resolve": "^1.
|
|
43
|
-
"tapable": "^1.1.3"
|
|
33
|
+
"resolve": "^1.22.0",
|
|
34
|
+
"tapable": "^1.1.3",
|
|
35
|
+
"webpack-merge": "^4.2.2"
|
|
44
36
|
},
|
|
45
|
-
"
|
|
46
|
-
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "run-s clean prod",
|
|
39
|
+
"dev": "tsc -w",
|
|
40
|
+
"prod": "tsc",
|
|
41
|
+
"clean": "rimraf dist",
|
|
42
|
+
"test": "jest",
|
|
43
|
+
"test:dev": "jest --watch"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/Config.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
import * as fs from 'fs-extra'
|
|
3
|
-
|
|
4
|
-
import * as merge from 'webpack-merge'
|
|
5
|
-
import { IProjectConfig } from '@tarojs/taro/types/compile'
|
|
6
1
|
import {
|
|
7
|
-
|
|
8
|
-
OUTPUT_DIR,
|
|
2
|
+
createSwcRegister,
|
|
9
3
|
ENTRY,
|
|
4
|
+
getModuleDefaultExport,
|
|
5
|
+
OUTPUT_DIR,
|
|
10
6
|
resolveScriptPath,
|
|
11
|
-
|
|
12
|
-
getModuleDefaultExport
|
|
7
|
+
SOURCE_DIR
|
|
13
8
|
} from '@tarojs/helper'
|
|
9
|
+
import { IProjectConfig } from '@tarojs/taro/types/compile'
|
|
10
|
+
import * as fs from 'fs-extra'
|
|
11
|
+
import * as path from 'path'
|
|
12
|
+
import * as merge from 'webpack-merge'
|
|
14
13
|
|
|
15
14
|
import {
|
|
16
15
|
CONFIG_DIR_NAME,
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
} from './utils/constants'
|
|
19
18
|
|
|
20
19
|
interface IConfigOptions {
|
|
21
|
-
appPath: string
|
|
20
|
+
appPath: string
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export default class Config {
|
|
@@ -37,7 +36,7 @@ export default class Config {
|
|
|
37
36
|
this.initialConfig = {}
|
|
38
37
|
this.isInitSuccess = false
|
|
39
38
|
} else {
|
|
40
|
-
|
|
39
|
+
createSwcRegister({
|
|
41
40
|
only: [
|
|
42
41
|
filePath => filePath.indexOf(path.join(this.appPath, CONFIG_DIR_NAME)) >= 0
|
|
43
42
|
]
|
|
@@ -73,6 +72,9 @@ export default class Config {
|
|
|
73
72
|
outputRoot: outputDirName,
|
|
74
73
|
platform,
|
|
75
74
|
framework: initialConfig.framework,
|
|
75
|
+
compiler: initialConfig.compiler,
|
|
76
|
+
cache: initialConfig.cache,
|
|
77
|
+
logger: initialConfig.logger,
|
|
76
78
|
baseLevel: initialConfig.baseLevel,
|
|
77
79
|
csso: initialConfig.csso,
|
|
78
80
|
sass: initialConfig.sass,
|
|
@@ -84,7 +86,10 @@ export default class Config {
|
|
|
84
86
|
designWidth: initialConfig.designWidth,
|
|
85
87
|
deviceRatio: initialConfig.deviceRatio,
|
|
86
88
|
projectConfigName: initialConfig.projectConfigName,
|
|
89
|
+
jsMinimizer: initialConfig.jsMinimizer,
|
|
90
|
+
cssMinimizer: initialConfig.cssMinimizer,
|
|
87
91
|
terser: initialConfig.terser,
|
|
92
|
+
esbuild: initialConfig.esbuild,
|
|
88
93
|
...initialConfig[useConfigName]
|
|
89
94
|
}
|
|
90
95
|
}
|
package/src/Kernel.ts
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
import { EventEmitter } from 'events'
|
|
3
|
-
import { merge } from 'lodash'
|
|
4
|
-
import { AsyncSeriesWaterfallHook } from 'tapable'
|
|
5
|
-
import { IProjectConfig, PluginItem } from '@tarojs/taro/types/compile'
|
|
6
1
|
import {
|
|
2
|
+
createDebug,
|
|
3
|
+
createSwcRegister,
|
|
7
4
|
NODE_MODULES,
|
|
8
|
-
recursiveFindNodeModules
|
|
9
|
-
createBabelRegister,
|
|
10
|
-
createDebug
|
|
5
|
+
recursiveFindNodeModules
|
|
11
6
|
} from '@tarojs/helper'
|
|
12
7
|
import * as helper from '@tarojs/helper'
|
|
13
|
-
import
|
|
8
|
+
import { IProjectConfig, PluginItem } from '@tarojs/taro/types/compile'
|
|
9
|
+
import { EventEmitter } from 'events'
|
|
10
|
+
import { merge } from 'lodash'
|
|
11
|
+
import * as path from 'path'
|
|
12
|
+
import { AsyncSeriesWaterfallHook } from 'tapable'
|
|
14
13
|
|
|
14
|
+
import Config from './Config'
|
|
15
|
+
import Plugin from './Plugin'
|
|
16
|
+
import { convertPluginsToObject, mergePlugins, printHelpLog, resolvePresetsOrPlugins } from './utils'
|
|
15
17
|
import {
|
|
16
|
-
IPreset,
|
|
17
|
-
IPluginsObject,
|
|
18
|
-
IPlugin,
|
|
19
|
-
IPaths,
|
|
20
|
-
IHook,
|
|
21
|
-
ICommand,
|
|
22
|
-
IPlatform
|
|
23
|
-
} from './utils/types'
|
|
24
|
-
import {
|
|
25
|
-
PluginType,
|
|
26
|
-
IS_MODIFY_HOOK,
|
|
27
18
|
IS_ADD_HOOK,
|
|
28
|
-
IS_EVENT_HOOK
|
|
19
|
+
IS_EVENT_HOOK,
|
|
20
|
+
IS_MODIFY_HOOK,
|
|
21
|
+
PluginType
|
|
29
22
|
} from './utils/constants'
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
import {
|
|
24
|
+
ICommand,
|
|
25
|
+
IHook,
|
|
26
|
+
IPaths,
|
|
27
|
+
IPlatform,
|
|
28
|
+
IPlugin,
|
|
29
|
+
IPluginsObject,
|
|
30
|
+
IPreset
|
|
31
|
+
} from './utils/types'
|
|
33
32
|
|
|
34
33
|
interface IKernelOptions {
|
|
35
34
|
appPath: string
|
|
@@ -58,7 +57,7 @@ export default class Kernel extends EventEmitter {
|
|
|
58
57
|
|
|
59
58
|
constructor (options: IKernelOptions) {
|
|
60
59
|
super()
|
|
61
|
-
this.debugger = createDebug('Taro:Kernel')
|
|
60
|
+
this.debugger = process.env.DEBUG === 'Taro:Kernel' ? createDebug('Taro:Kernel') : function () {}
|
|
62
61
|
this.appPath = options.appPath || process.cwd()
|
|
63
62
|
this.optsPresets = options.presets
|
|
64
63
|
this.optsPlugins = options.plugins
|
|
@@ -67,14 +66,8 @@ export default class Kernel extends EventEmitter {
|
|
|
67
66
|
this.commands = new Map()
|
|
68
67
|
this.platforms = new Map()
|
|
69
68
|
this.initHelper()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async init () {
|
|
73
|
-
this.debugger('init')
|
|
74
69
|
this.initConfig()
|
|
75
70
|
this.initPaths()
|
|
76
|
-
this.initPresetsAndPlugins()
|
|
77
|
-
await this.applyPlugins('onReady')
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
initConfig () {
|
|
@@ -94,7 +87,7 @@ export default class Kernel extends EventEmitter {
|
|
|
94
87
|
Object.assign(this.paths, {
|
|
95
88
|
configPath: this.config.configPath,
|
|
96
89
|
sourcePath: path.join(this.appPath, this.initialConfig.sourceRoot as string),
|
|
97
|
-
outputPath: path.
|
|
90
|
+
outputPath: path.join(this.appPath, this.initialConfig.outputRoot as string)
|
|
98
91
|
})
|
|
99
92
|
}
|
|
100
93
|
this.debugger(`initPaths:${JSON.stringify(this.paths, null, 2)}`)
|
|
@@ -111,7 +104,7 @@ export default class Kernel extends EventEmitter {
|
|
|
111
104
|
const allConfigPlugins = mergePlugins(this.optsPlugins || [], initialConfig.plugins || [])()
|
|
112
105
|
this.debugger('initPresetsAndPlugins', allConfigPresets, allConfigPlugins)
|
|
113
106
|
process.env.NODE_ENV !== 'test' &&
|
|
114
|
-
|
|
107
|
+
createSwcRegister({
|
|
115
108
|
only: [...Object.keys(allConfigPresets), ...Object.keys(allConfigPlugins)]
|
|
116
109
|
})
|
|
117
110
|
this.plugins = new Map()
|
|
@@ -167,6 +160,8 @@ export default class Kernel extends EventEmitter {
|
|
|
167
160
|
if (typeof pluginCtx.optsSchema !== 'function') {
|
|
168
161
|
return
|
|
169
162
|
}
|
|
163
|
+
this.debugger('checkPluginOpts', pluginCtx)
|
|
164
|
+
const joi = require('joi')
|
|
170
165
|
const schema = pluginCtx.optsSchema(joi)
|
|
171
166
|
if (!joi.isSchema(schema)) {
|
|
172
167
|
throw new Error(`插件${pluginCtx.id}中设置参数检查 schema 有误,请检查!`)
|
|
@@ -179,6 +174,7 @@ export default class Kernel extends EventEmitter {
|
|
|
179
174
|
}
|
|
180
175
|
|
|
181
176
|
registerPlugin (plugin: IPlugin) {
|
|
177
|
+
this.debugger('registerPlugin', plugin)
|
|
182
178
|
if (this.plugins.has(plugin.id)) {
|
|
183
179
|
throw new Error(`插件 ${plugin.id} 已被注册`)
|
|
184
180
|
}
|
|
@@ -243,6 +239,9 @@ export default class Kernel extends EventEmitter {
|
|
|
243
239
|
throw new Error('调用失败,未传入正确的名称!')
|
|
244
240
|
}
|
|
245
241
|
const hooks = this.hooks.get(name) || []
|
|
242
|
+
if (!hooks.length) {
|
|
243
|
+
return await initialVal
|
|
244
|
+
}
|
|
246
245
|
const waterfall = new AsyncSeriesWaterfallHook(['arg'])
|
|
247
246
|
if (hooks.length) {
|
|
248
247
|
const resArr: any[] = []
|
|
@@ -306,24 +305,33 @@ export default class Kernel extends EventEmitter {
|
|
|
306
305
|
this.debugger('command:runOpts')
|
|
307
306
|
this.debugger(`command:runOpts:${JSON.stringify(opts, null, 2)}`)
|
|
308
307
|
this.setRunOpts(opts)
|
|
309
|
-
|
|
308
|
+
|
|
309
|
+
this.debugger('initPresetsAndPlugins')
|
|
310
|
+
this.initPresetsAndPlugins()
|
|
311
|
+
|
|
312
|
+
await this.applyPlugins('onReady')
|
|
313
|
+
|
|
310
314
|
this.debugger('command:onStart')
|
|
311
315
|
await this.applyPlugins('onStart')
|
|
316
|
+
|
|
312
317
|
if (!this.commands.has(name)) {
|
|
313
318
|
throw new Error(`${name} 命令不存在`)
|
|
314
319
|
}
|
|
320
|
+
|
|
315
321
|
if (opts?.isHelp) {
|
|
316
322
|
return this.runHelp(name)
|
|
317
323
|
}
|
|
324
|
+
|
|
318
325
|
if (opts?.options?.platform) {
|
|
319
326
|
opts.config = this.runWithPlatform(opts.options.platform)
|
|
327
|
+
await this.applyPlugins({
|
|
328
|
+
name: 'modifyRunnerOpts',
|
|
329
|
+
opts: {
|
|
330
|
+
opts: opts?.config
|
|
331
|
+
}
|
|
332
|
+
})
|
|
320
333
|
}
|
|
321
|
-
|
|
322
|
-
name: 'modifyRunnerOpts',
|
|
323
|
-
opts: {
|
|
324
|
-
opts: opts?.config
|
|
325
|
-
}
|
|
326
|
-
})
|
|
334
|
+
|
|
327
335
|
await this.applyPlugins({
|
|
328
336
|
name,
|
|
329
337
|
opts
|
package/src/Plugin.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
|
|
2
|
+
|
|
2
3
|
import type { IPluginContext } from '../types/index'
|
|
3
4
|
|
|
4
5
|
interface IFileType {
|
|
@@ -42,6 +43,7 @@ export abstract class TaroPlatformBase {
|
|
|
42
43
|
ctx: IPluginContext
|
|
43
44
|
helper: IPluginContext['helper']
|
|
44
45
|
config: any
|
|
46
|
+
compiler: string
|
|
45
47
|
|
|
46
48
|
abstract platform: string
|
|
47
49
|
abstract globalObject: string
|
|
@@ -58,6 +60,8 @@ export abstract class TaroPlatformBase {
|
|
|
58
60
|
this.ctx = ctx
|
|
59
61
|
this.helper = ctx.helper
|
|
60
62
|
this.config = config
|
|
63
|
+
const _compiler = config.compiler
|
|
64
|
+
this.compiler = typeof _compiler === 'object' ? _compiler.type : _compiler
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
/**
|
|
@@ -76,11 +80,13 @@ export abstract class TaroPlatformBase {
|
|
|
76
80
|
this.emptyOutputDir()
|
|
77
81
|
}
|
|
78
82
|
this.printDevelopmentTip(this.platform)
|
|
79
|
-
const { printLog, processTypeEnum } = this.ctx.helper
|
|
80
|
-
printLog(processTypeEnum.START, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`)
|
|
81
83
|
if (this.projectConfigJson) {
|
|
82
84
|
this.generateProjectConfig(this.projectConfigJson)
|
|
83
85
|
}
|
|
86
|
+
if (this.ctx.initialConfig.logger?.quiet === false) {
|
|
87
|
+
const { printLog, processTypeEnum } = this.ctx.helper
|
|
88
|
+
printLog(processTypeEnum.START, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`)
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
protected emptyOutputDir () {
|
|
@@ -89,21 +95,30 @@ export abstract class TaroPlatformBase {
|
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
protected printDevelopmentTip (platform: string) {
|
|
92
|
-
|
|
98
|
+
const tips: string[] = []
|
|
99
|
+
const config = this.config
|
|
100
|
+
const { chalk } = this.helper
|
|
101
|
+
|
|
102
|
+
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
|
103
|
+
const { isWindows } = this.helper
|
|
104
|
+
const exampleCommand = isWindows
|
|
105
|
+
? `$ set NODE_ENV=production && taro build --type ${platform} --watch`
|
|
106
|
+
: `$ NODE_ENV=production taro build --type ${platform} --watch`
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
tips.push(chalk.yellowBright(`预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
|
|
109
|
+
Example:
|
|
110
|
+
${exampleCommand}`))
|
|
111
|
+
}
|
|
96
112
|
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
} else {
|
|
100
|
-
exampleCommand = `$ NODE_ENV=production taro build --type ${platform} --watch`
|
|
113
|
+
if (this.compiler === 'webpack5' && !config.cache?.enable) {
|
|
114
|
+
tips.push(chalk.yellowBright('建议开启持久化缓存功能,能有效提升二次编译速度,详情请参考: https://docs.taro.zone/docs/config-detail#cache。'))
|
|
101
115
|
}
|
|
102
116
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
${
|
|
106
|
-
|
|
117
|
+
if (tips.length) {
|
|
118
|
+
console.log(chalk.yellowBright('Tips:'))
|
|
119
|
+
tips.forEach((item, index) => console.log(`${chalk.yellowBright(index + 1)}. ${item}`))
|
|
120
|
+
console.log('\n')
|
|
121
|
+
}
|
|
107
122
|
}
|
|
108
123
|
|
|
109
124
|
/**
|
|
@@ -112,7 +127,18 @@ ${exampleCommand}
|
|
|
112
127
|
protected async getRunner () {
|
|
113
128
|
const { appPath } = this.ctx.paths
|
|
114
129
|
const { npm } = this.helper
|
|
115
|
-
|
|
130
|
+
|
|
131
|
+
let runnerPkg: string
|
|
132
|
+
switch (this.compiler) {
|
|
133
|
+
case 'webpack5':
|
|
134
|
+
runnerPkg = '@tarojs/webpack5-runner'
|
|
135
|
+
break
|
|
136
|
+
default:
|
|
137
|
+
runnerPkg = '@tarojs/mini-runner'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const runner = await npm.getNpmPkg(runnerPkg, appPath)
|
|
141
|
+
|
|
116
142
|
return runner.bind(null, appPath)
|
|
117
143
|
}
|
|
118
144
|
|
package/src/utils/index.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { chalk, getModuleDefaultExport } from '@tarojs/helper'
|
|
2
|
+
import type { PluginItem } from '@tarojs/taro/types/compile'
|
|
3
3
|
import { merge } from 'lodash'
|
|
4
|
+
import * as path from 'path'
|
|
4
5
|
import * as resolve from 'resolve'
|
|
5
|
-
import { getModuleDefaultExport, chalk } from '@tarojs/helper'
|
|
6
|
-
|
|
7
|
-
import { PluginItem } from '@tarojs/taro/types/compile'
|
|
8
6
|
|
|
9
7
|
import { PluginType } from './constants'
|
|
10
|
-
import {
|
|
8
|
+
import { IPlugin, IPluginsObject } from './types'
|
|
11
9
|
|
|
12
10
|
export const isNpmPkg: (name: string) => boolean = name => !(/^(\.|\/)/.test(name))
|
|
13
11
|
|
|
@@ -66,7 +64,12 @@ export function resolvePresetsOrPlugins (root: string, args, type: PluginType):
|
|
|
66
64
|
type,
|
|
67
65
|
opts: args[item] || {},
|
|
68
66
|
apply () {
|
|
69
|
-
|
|
67
|
+
try {
|
|
68
|
+
return getModuleDefaultExport(require(fPath))
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(error)
|
|
71
|
+
throw new Error(`插件依赖 "${item}" 加载失败,请检查插件配置`)
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
})
|
package/src/utils/types.ts
CHANGED
package/types/index.d.ts
CHANGED