@tarojs/service 3.4.8 → 3.5.0-alpha.10
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 +5 -5
- package/dist/Kernel.js +11 -11
- package/dist/Plugin.js +1 -1
- package/dist/platform-plugin-base.d.ts +1 -0
- package/dist/platform-plugin-base.js +35 -15
- package/dist/utils/index.js +3 -3
- package/package.json +5 -5
- package/src/Config.ts +8 -2
- package/src/Kernel.ts +2 -2
- package/src/platform-plugin-base.ts +39 -14
package/dist/Config.js
CHANGED
|
@@ -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,11 @@ 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;
|
package/dist/Kernel.js
CHANGED
|
@@ -22,7 +22,7 @@ const Config_1 = require("./Config");
|
|
|
22
22
|
class Kernel extends events_1.EventEmitter {
|
|
23
23
|
constructor(options) {
|
|
24
24
|
super();
|
|
25
|
-
this.debugger = process.env.DEBUG === 'Taro:Kernel' ? helper_1.createDebug('Taro:Kernel') : function () { };
|
|
25
|
+
this.debugger = process.env.DEBUG === 'Taro:Kernel' ? (0, helper_1.createDebug)('Taro:Kernel') : function () { };
|
|
26
26
|
this.appPath = options.appPath || process.cwd();
|
|
27
27
|
this.optsPresets = options.presets;
|
|
28
28
|
this.optsPlugins = options.plugins;
|
|
@@ -44,7 +44,7 @@ class Kernel extends events_1.EventEmitter {
|
|
|
44
44
|
initPaths() {
|
|
45
45
|
this.paths = {
|
|
46
46
|
appPath: this.appPath,
|
|
47
|
-
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))
|
|
48
48
|
};
|
|
49
49
|
if (this.config.isInitSuccess) {
|
|
50
50
|
Object.assign(this.paths, {
|
|
@@ -61,11 +61,11 @@ class Kernel extends events_1.EventEmitter {
|
|
|
61
61
|
}
|
|
62
62
|
initPresetsAndPlugins() {
|
|
63
63
|
const initialConfig = this.initialConfig;
|
|
64
|
-
const allConfigPresets = utils_1.mergePlugins(this.optsPresets || [], initialConfig.presets || [])();
|
|
65
|
-
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 || [])();
|
|
66
66
|
this.debugger('initPresetsAndPlugins', allConfigPresets, allConfigPlugins);
|
|
67
67
|
process.env.NODE_ENV !== 'test' &&
|
|
68
|
-
helper_1.
|
|
68
|
+
(0, helper_1.createSwcRegister)({
|
|
69
69
|
only: [...Object.keys(allConfigPresets), ...Object.keys(allConfigPlugins)]
|
|
70
70
|
});
|
|
71
71
|
this.plugins = new Map();
|
|
@@ -74,14 +74,14 @@ class Kernel extends events_1.EventEmitter {
|
|
|
74
74
|
this.resolvePlugins(allConfigPlugins);
|
|
75
75
|
}
|
|
76
76
|
resolvePresets(presets) {
|
|
77
|
-
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);
|
|
78
78
|
while (allPresets.length) {
|
|
79
79
|
this.initPreset(allPresets.shift());
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
resolvePlugins(plugins) {
|
|
83
|
-
plugins = lodash_1.merge(this.extraPlugins, plugins);
|
|
84
|
-
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);
|
|
85
85
|
while (allPlugins.length) {
|
|
86
86
|
this.initPlugin(allPlugins.shift());
|
|
87
87
|
}
|
|
@@ -94,13 +94,13 @@ class Kernel extends events_1.EventEmitter {
|
|
|
94
94
|
const { presets, plugins } = apply()(pluginCtx, opts) || {};
|
|
95
95
|
this.registerPlugin(preset);
|
|
96
96
|
if (Array.isArray(presets)) {
|
|
97
|
-
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);
|
|
98
98
|
while (_presets.length) {
|
|
99
99
|
this.initPreset(_presets.shift());
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
if (Array.isArray(plugins)) {
|
|
103
|
-
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)());
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
initPlugin(plugin) {
|
|
@@ -238,7 +238,7 @@ class Kernel extends events_1.EventEmitter {
|
|
|
238
238
|
customOptionsMap = new Map(Object.entries(command === null || command === void 0 ? void 0 : command.optionsMap));
|
|
239
239
|
}
|
|
240
240
|
const optionsMap = new Map([...customOptionsMap, ...defaultOptionsMap]);
|
|
241
|
-
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());
|
|
241
|
+
(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());
|
|
242
242
|
}
|
|
243
243
|
run(args) {
|
|
244
244
|
var _a;
|
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
|
}
|
|
@@ -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("start" /* 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
|
}
|
package/dist/utils/index.js
CHANGED
|
@@ -8,7 +8,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,7 @@ function resolvePresetsOrPlugins(root, args, type) {
|
|
|
67
67
|
type,
|
|
68
68
|
opts: args[item] || {},
|
|
69
69
|
apply() {
|
|
70
|
-
return helper_1.getModuleDefaultExport(require(fPath));
|
|
70
|
+
return (0, helper_1.getModuleDefaultExport)(require(fPath));
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/service",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0-alpha.10",
|
|
4
4
|
"description": "Taro Service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/NervJS/taro#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tarojs/helper": "3.
|
|
37
|
-
"@tarojs/shared": "3.
|
|
38
|
-
"@tarojs/taro": "3.
|
|
36
|
+
"@tarojs/helper": "3.5.0-alpha.10",
|
|
37
|
+
"@tarojs/shared": "3.5.0-alpha.10",
|
|
38
|
+
"@tarojs/taro": "3.5.0-alpha.10",
|
|
39
39
|
"fs-extra": "^8.1.0",
|
|
40
40
|
"joi": "^17.6.0",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"tapable": "^1.1.3",
|
|
44
44
|
"webpack-merge": "^4.2.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "8569f73a71cd11c697e66662d584c17175c7343b"
|
|
47
47
|
}
|
package/src/Config.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
OUTPUT_DIR,
|
|
9
9
|
ENTRY,
|
|
10
10
|
resolveScriptPath,
|
|
11
|
-
|
|
11
|
+
createSwcRegister,
|
|
12
12
|
getModuleDefaultExport
|
|
13
13
|
} from '@tarojs/helper'
|
|
14
14
|
|
|
@@ -37,7 +37,7 @@ export default class Config {
|
|
|
37
37
|
this.initialConfig = {}
|
|
38
38
|
this.isInitSuccess = false
|
|
39
39
|
} else {
|
|
40
|
-
|
|
40
|
+
createSwcRegister({
|
|
41
41
|
only: [
|
|
42
42
|
filePath => filePath.indexOf(path.join(this.appPath, CONFIG_DIR_NAME)) >= 0
|
|
43
43
|
]
|
|
@@ -73,6 +73,9 @@ export default class Config {
|
|
|
73
73
|
outputRoot: outputDirName,
|
|
74
74
|
platform,
|
|
75
75
|
framework: initialConfig.framework,
|
|
76
|
+
compiler: initialConfig.compiler,
|
|
77
|
+
cache: initialConfig.cache,
|
|
78
|
+
logger: initialConfig.logger,
|
|
76
79
|
baseLevel: initialConfig.baseLevel,
|
|
77
80
|
csso: initialConfig.csso,
|
|
78
81
|
sass: initialConfig.sass,
|
|
@@ -84,7 +87,10 @@ export default class Config {
|
|
|
84
87
|
designWidth: initialConfig.designWidth,
|
|
85
88
|
deviceRatio: initialConfig.deviceRatio,
|
|
86
89
|
projectConfigName: initialConfig.projectConfigName,
|
|
90
|
+
jsMinimizer: initialConfig.jsMinimizer,
|
|
91
|
+
cssMinimizer: initialConfig.cssMinimizer,
|
|
87
92
|
terser: initialConfig.terser,
|
|
93
|
+
esbuild: initialConfig.esbuild,
|
|
88
94
|
...initialConfig[useConfigName]
|
|
89
95
|
}
|
|
90
96
|
}
|
package/src/Kernel.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { IProjectConfig, PluginItem } from '@tarojs/taro/types/compile'
|
|
|
6
6
|
import {
|
|
7
7
|
NODE_MODULES,
|
|
8
8
|
recursiveFindNodeModules,
|
|
9
|
-
|
|
9
|
+
createSwcRegister,
|
|
10
10
|
createDebug
|
|
11
11
|
} from '@tarojs/helper'
|
|
12
12
|
import * as helper from '@tarojs/helper'
|
|
@@ -104,7 +104,7 @@ export default class Kernel extends EventEmitter {
|
|
|
104
104
|
const allConfigPlugins = mergePlugins(this.optsPlugins || [], initialConfig.plugins || [])()
|
|
105
105
|
this.debugger('initPresetsAndPlugins', allConfigPresets, allConfigPlugins)
|
|
106
106
|
process.env.NODE_ENV !== 'test' &&
|
|
107
|
-
|
|
107
|
+
createSwcRegister({
|
|
108
108
|
only: [...Object.keys(allConfigPresets), ...Object.keys(allConfigPlugins)]
|
|
109
109
|
})
|
|
110
110
|
this.plugins = new Map()
|
|
@@ -42,6 +42,7 @@ export abstract class TaroPlatformBase {
|
|
|
42
42
|
ctx: IPluginContext
|
|
43
43
|
helper: IPluginContext['helper']
|
|
44
44
|
config: any
|
|
45
|
+
compiler: string
|
|
45
46
|
|
|
46
47
|
abstract platform: string
|
|
47
48
|
abstract globalObject: string
|
|
@@ -58,6 +59,8 @@ export abstract class TaroPlatformBase {
|
|
|
58
59
|
this.ctx = ctx
|
|
59
60
|
this.helper = ctx.helper
|
|
60
61
|
this.config = config
|
|
62
|
+
const _compiler = config.compiler
|
|
63
|
+
this.compiler = typeof _compiler === 'object' ? _compiler.type : _compiler
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
/**
|
|
@@ -76,11 +79,13 @@ export abstract class TaroPlatformBase {
|
|
|
76
79
|
this.emptyOutputDir()
|
|
77
80
|
}
|
|
78
81
|
this.printDevelopmentTip(this.platform)
|
|
79
|
-
const { printLog, processTypeEnum } = this.ctx.helper
|
|
80
|
-
printLog(processTypeEnum.START, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`)
|
|
81
82
|
if (this.projectConfigJson) {
|
|
82
83
|
this.generateProjectConfig(this.projectConfigJson)
|
|
83
84
|
}
|
|
85
|
+
if (this.ctx.initialConfig.logger?.quiet === false) {
|
|
86
|
+
const { printLog, processTypeEnum } = this.ctx.helper
|
|
87
|
+
printLog(processTypeEnum.START, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`)
|
|
88
|
+
}
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
protected emptyOutputDir () {
|
|
@@ -89,21 +94,30 @@ export abstract class TaroPlatformBase {
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
protected printDevelopmentTip (platform: string) {
|
|
92
|
-
|
|
97
|
+
const tips: string[] = []
|
|
98
|
+
const config = this.config
|
|
99
|
+
const { chalk } = this.helper
|
|
93
100
|
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
|
|
102
|
+
const { isWindows } = this.helper
|
|
103
|
+
const exampleCommand = isWindows
|
|
104
|
+
? `$ set NODE_ENV=production && taro build --type ${platform} --watch`
|
|
105
|
+
: `$ NODE_ENV=production taro build --type ${platform} --watch`
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
exampleCommand = `$ NODE_ENV=production taro build --type ${platform} --watch`
|
|
107
|
+
tips.push(chalk.yellowBright(`预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
|
|
108
|
+
Example:
|
|
109
|
+
${exampleCommand}`))
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
if (this.compiler === 'webpack5' && !config.cache?.enable) {
|
|
113
|
+
tips.push(chalk.yellowBright('建议开启持久化缓存功能,能有效提升二次编译速度,详情请参考: https://docs.taro.zone/docs/config-detail#cache。'))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (tips.length) {
|
|
117
|
+
console.log(chalk.yellowBright('Tips:'))
|
|
118
|
+
tips.forEach((item, index) => console.log(`${chalk.yellowBright(index + 1)}. ${item}`))
|
|
119
|
+
console.log('\n')
|
|
120
|
+
}
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
/**
|
|
@@ -112,7 +126,18 @@ ${exampleCommand}
|
|
|
112
126
|
protected async getRunner () {
|
|
113
127
|
const { appPath } = this.ctx.paths
|
|
114
128
|
const { npm } = this.helper
|
|
115
|
-
|
|
129
|
+
|
|
130
|
+
let runnerPkg: string
|
|
131
|
+
switch (this.compiler) {
|
|
132
|
+
case 'webpack5':
|
|
133
|
+
runnerPkg = '@tarojs/webpack5-runner'
|
|
134
|
+
break
|
|
135
|
+
default:
|
|
136
|
+
runnerPkg = '@tarojs/mini-runner'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const runner = await npm.getNpmPkg(runnerPkg, appPath)
|
|
140
|
+
|
|
116
141
|
return runner.bind(null, appPath)
|
|
117
142
|
}
|
|
118
143
|
|