@tarojs/helper 3.5.0-canary.1 → 3.5.0-theta.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/constants.js +9 -5
- package/dist/index.js +3 -3
- package/dist/npm.js +3 -2
- package/dist/swcRegister.js +38 -0
- package/dist/utils.js +37 -34
- package/index.js +1 -0
- package/package.json +6 -6
- package/types/constants.d.ts +3 -3
- package/types/index.d.ts +127 -121
- package/types/swcRegister.d.ts +3 -0
- package/types/utils.d.ts +2 -2
- package/LICENSE +0 -21
package/dist/constants.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TARO_BASE_CONFIG = exports.
|
|
3
|
+
exports.TARO_BASE_CONFIG = exports.TARO_CONFIG_FOLDER = exports.DEFAULT_TEMPLATE_SRC_GITEE = exports.DEFAULT_TEMPLATE_SRC = exports.isWindows = exports.DEVICE_RATIO_NAME = exports.taroJsMobxCommon = exports.taroJsMobx = exports.taroJsRedux = exports.taroJsFramework = exports.taroJsQuickAppComponents = exports.taroJsComponents = exports.META_TYPE = exports.UPDATE_PACKAGE_LIST = exports.FILE_PROCESSOR_MAP = exports.DEVICE_RATIO = exports.PROJECT_CONFIG = exports.NODE_MODULES_REG = exports.NODE_MODULES = exports.CSS_IMPORT_REG = exports.REG_URL = exports.REG_WXML_IMPORT = exports.REG_TEMPLATE = exports.REG_UX = exports.REG_JSON = exports.REG_FONT = exports.REG_IMAGE = exports.REG_MEDIA = exports.REG_CSS = exports.REG_STYLE = exports.REG_STYLUS = exports.REG_LESS = exports.REG_SASS_SCSS = exports.REG_SASS_SASS = exports.REG_SASS = exports.REG_VUE = exports.REG_SCRIPTS = exports.REG_TYPESCRIPT = exports.REG_SCRIPT = exports.REG_JS = exports.VUE_EXT = exports.SCRIPT_EXT = exports.UX_EXT = exports.TS_EXT = exports.JS_EXT = exports.SCSS_EXT = exports.CSS_EXT = exports.processTypeMap = exports.processTypeEnum = exports.PLATFORMS = void 0;
|
|
4
4
|
exports.FRAMEWORK_EXT_MAP = exports.FRAMEWORK_MAP = exports.ENTRY = exports.NPM_DIR = exports.TEMP_DIR = exports.SOURCE_DIR = exports.OUTPUT_DIR = void 0;
|
|
5
|
-
const os = require("os");
|
|
6
5
|
const chalk = require("chalk");
|
|
6
|
+
const os = require("os");
|
|
7
7
|
// eslint-disable-next-line dot-notation
|
|
8
8
|
exports.PLATFORMS = global['PLATFORMS'] = global['PLATFORMS'] || {};
|
|
9
9
|
var processTypeEnum;
|
|
@@ -126,10 +126,13 @@ exports.UPDATE_PACKAGE_LIST = [
|
|
|
126
126
|
'@tarojs/cli',
|
|
127
127
|
'@tarojs/components',
|
|
128
128
|
'@tarojs/taro-h5',
|
|
129
|
+
'@tarojs/taro-rn',
|
|
130
|
+
'@tarojs/rn-runner',
|
|
129
131
|
'@tarojs/helper',
|
|
130
132
|
'@tarojs/taro-loader',
|
|
131
133
|
'@tarojs/mini-runner',
|
|
132
134
|
'@tarojs/react',
|
|
135
|
+
'@tarojs/plugin-framework-react',
|
|
133
136
|
'@tarojs/router',
|
|
134
137
|
'@tarojs/runner-utils',
|
|
135
138
|
'@tarojs/runtime',
|
|
@@ -143,6 +146,7 @@ exports.UPDATE_PACKAGE_LIST = [
|
|
|
143
146
|
'@tarojs/plugin-platform-tt',
|
|
144
147
|
'@tarojs/plugin-platform-qq',
|
|
145
148
|
'@tarojs/plugin-platform-jd',
|
|
149
|
+
'@tarojs/plugin-html',
|
|
146
150
|
'nervjs',
|
|
147
151
|
'nerv-devtools'
|
|
148
152
|
];
|
|
@@ -164,9 +168,9 @@ exports.taroJsMobx = '@tarojs/mobx';
|
|
|
164
168
|
exports.taroJsMobxCommon = '@tarojs/mobx-common';
|
|
165
169
|
exports.DEVICE_RATIO_NAME = 'deviceRatio';
|
|
166
170
|
exports.isWindows = os.platform() === 'win32';
|
|
167
|
-
exports.DEFAULT_TEMPLATE_SRC = 'github:NervJS/taro-project-templates#v3.
|
|
168
|
-
exports.DEFAULT_TEMPLATE_SRC_GITEE = 'direct:https://gitee.com/o2team/taro-project-templates.git#v3.
|
|
169
|
-
exports.
|
|
171
|
+
exports.DEFAULT_TEMPLATE_SRC = 'github:NervJS/taro-project-templates#v3.5';
|
|
172
|
+
exports.DEFAULT_TEMPLATE_SRC_GITEE = 'direct:https://gitee.com/o2team/taro-project-templates.git#v3.5';
|
|
173
|
+
exports.TARO_CONFIG_FOLDER = '.taro3.5';
|
|
170
174
|
exports.TARO_BASE_CONFIG = 'index.json';
|
|
171
175
|
exports.OUTPUT_DIR = 'dist';
|
|
172
176
|
exports.SOURCE_DIR = 'src';
|
package/dist/index.js
CHANGED
|
@@ -4,16 +4,16 @@ exports.helper = void 0;
|
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const chokidar = require("chokidar");
|
|
7
|
-
const debug_1 = require("debug");
|
|
8
7
|
const constants = require("./constants");
|
|
9
8
|
const utils = require("./utils");
|
|
10
9
|
const npm = require("./npm");
|
|
11
10
|
const babelRegister_1 = require("./babelRegister");
|
|
11
|
+
const swcRegister_1 = require("./swcRegister");
|
|
12
12
|
exports.helper = Object.assign(Object.assign(Object.assign({}, constants), utils), { npm,
|
|
13
13
|
createBabelRegister: babelRegister_1.default,
|
|
14
14
|
injectDefineConfigHeader: babelRegister_1.injectDefineConfigHeader,
|
|
15
|
+
createSwcRegister: swcRegister_1.default,
|
|
15
16
|
fs,
|
|
16
17
|
chalk,
|
|
17
|
-
chokidar,
|
|
18
|
-
createDebug: debug_1.default });
|
|
18
|
+
chokidar, createDebug: id => require('debug')(id) });
|
|
19
19
|
exports.default = exports.helper;
|
package/dist/npm.js
CHANGED
|
@@ -10,8 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getNpmPkg = exports.getNpmPkgSync = exports.callPluginSync = exports.callPlugin = exports.installNpmPkg = exports.resolveNpmSync = exports.resolveNpm = exports.taroPluginPrefix = void 0;
|
|
13
|
-
const resolvePath = require("resolve");
|
|
14
|
-
const spawn = require("cross-spawn");
|
|
15
13
|
const chalk = require("chalk");
|
|
16
14
|
const Util = require("./utils");
|
|
17
15
|
const PEERS = /UNMET PEER DEPENDENCY ([a-z\-0-9.]+)@(.+)/gm;
|
|
@@ -23,6 +21,7 @@ const defaultInstallOptions = {
|
|
|
23
21
|
};
|
|
24
22
|
exports.taroPluginPrefix = '@tarojs/plugin-';
|
|
25
23
|
function resolveNpm(pluginName, root) {
|
|
24
|
+
const resolvePath = require('resolve');
|
|
26
25
|
if (!npmCached[pluginName]) {
|
|
27
26
|
return new Promise((resolve, reject) => {
|
|
28
27
|
resolvePath(`${pluginName}`, { basedir: root }, (err, res) => {
|
|
@@ -38,6 +37,7 @@ function resolveNpm(pluginName, root) {
|
|
|
38
37
|
}
|
|
39
38
|
exports.resolveNpm = resolveNpm;
|
|
40
39
|
function resolveNpmSync(pluginName, root) {
|
|
40
|
+
const resolvePath = require('resolve');
|
|
41
41
|
try {
|
|
42
42
|
if (!npmCached[pluginName]) {
|
|
43
43
|
const res = resolvePath.sync(pluginName, { basedir: root });
|
|
@@ -103,6 +103,7 @@ function installNpmPkg(pkgList, options) {
|
|
|
103
103
|
args.push('--save');
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
const spawn = require('cross-spawn');
|
|
106
107
|
const output = spawn.sync(installer, args, {
|
|
107
108
|
stdio: ['ignore', 'pipe', 'inherit']
|
|
108
109
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InjectDefineConfigHeader = void 0;
|
|
4
|
+
const Visitor_js_1 = require("@swc/core/Visitor.js");
|
|
5
|
+
class InjectDefineConfigHeader extends Visitor_js_1.Visitor {
|
|
6
|
+
visitTsType(expression) {
|
|
7
|
+
return expression;
|
|
8
|
+
}
|
|
9
|
+
visitCallExpression(expression) {
|
|
10
|
+
const callee = expression.callee;
|
|
11
|
+
if (callee.type === 'Identifier' && (callee.value === 'definePageConfig' || callee.value === 'defineAppConfig')) {
|
|
12
|
+
return expression.arguments[0].expression;
|
|
13
|
+
}
|
|
14
|
+
return expression;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.InjectDefineConfigHeader = InjectDefineConfigHeader;
|
|
18
|
+
function createSwcRegister({ only, plugin }) {
|
|
19
|
+
const config = {
|
|
20
|
+
only: Array.from(new Set([...only])),
|
|
21
|
+
jsc: {
|
|
22
|
+
parser: {
|
|
23
|
+
syntax: 'typescript',
|
|
24
|
+
decorators: true
|
|
25
|
+
},
|
|
26
|
+
transform: {
|
|
27
|
+
legacyDecorator: true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
module: {
|
|
31
|
+
type: 'commonjs'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if (plugin)
|
|
35
|
+
config.plugin = plugin;
|
|
36
|
+
require('@swc/register')(config);
|
|
37
|
+
}
|
|
38
|
+
exports.default = createSwcRegister;
|
package/dist/utils.js
CHANGED
|
@@ -9,20 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.readConfig = exports.readPageConfig = exports.removeHeadSlash = exports.getModuleDefaultExport = exports.addPlatforms = exports.extnameExpRegOf = exports.readDirWithFileTypes = exports.
|
|
13
|
-
const fs = require("fs-extra");
|
|
14
|
-
const path = require("path");
|
|
15
|
-
const os = require("os");
|
|
16
|
-
const stream_1 = require("stream");
|
|
17
|
-
const child_process = require("child_process");
|
|
18
|
-
const parser = require("@babel/parser");
|
|
19
|
-
const traverse_1 = require("@babel/traverse");
|
|
12
|
+
exports.readConfig = exports.readPageConfig = exports.removeHeadSlash = exports.getModuleDefaultExport = exports.addPlatforms = exports.extnameExpRegOf = exports.readDirWithFileTypes = exports.getAllFilesInFolder = exports.unzip = exports.applyArrayedVisitors = exports.mergeVisitors = exports.recursiveMerge = exports.getInstalledNpmPkgVersion = exports.getInstalledNpmPkgPath = exports.pascalCase = exports.emptyDirectory = exports.cssImports = exports.generateConstantsList = exports.generateEnvList = exports.resolveScriptPath = exports.resolveMainFilePath = exports.isEmptyObject = exports.shouldUseCnpm = exports.shouldUseYarn = exports.getSystemUsername = exports.getConfig = exports.getTaroPath = exports.getUserHomeDir = exports.recursiveFindNodeModules = exports.printLog = exports.resolveStylePath = exports.promoteRelativePath = exports.replaceAliasPath = exports.isAliasPath = exports.isQuickAppPkg = exports.isNpmPkg = exports.isNodeModule = exports.normalizePath = void 0;
|
|
20
13
|
const chalk = require("chalk");
|
|
21
|
-
const
|
|
14
|
+
const child_process = require("child_process");
|
|
15
|
+
const fs = require("fs-extra");
|
|
22
16
|
const lodash_1 = require("lodash");
|
|
23
|
-
const
|
|
17
|
+
const os = require("os");
|
|
18
|
+
const path = require("path");
|
|
24
19
|
const constants_1 = require("./constants");
|
|
25
|
-
const
|
|
20
|
+
const swcRegister_1 = require("./swcRegister");
|
|
26
21
|
const execSync = child_process.execSync;
|
|
27
22
|
function normalizePath(path) {
|
|
28
23
|
return path.replace(/\\/g, '/').replace(/\/{2,}/g, '/');
|
|
@@ -121,6 +116,7 @@ function printLog(type, tag, filePath) {
|
|
|
121
116
|
}
|
|
122
117
|
exports.printLog = printLog;
|
|
123
118
|
function recursiveFindNodeModules(filePath, lastFindPath) {
|
|
119
|
+
const findWorkspaceRoot = require('find-yarn-workspace-root');
|
|
124
120
|
if (lastFindPath && (normalizePath(filePath) === normalizePath(lastFindPath))) {
|
|
125
121
|
return filePath;
|
|
126
122
|
}
|
|
@@ -157,7 +153,7 @@ function getUserHomeDir() {
|
|
|
157
153
|
}
|
|
158
154
|
exports.getUserHomeDir = getUserHomeDir;
|
|
159
155
|
function getTaroPath() {
|
|
160
|
-
const taroPath = path.join(getUserHomeDir(), constants_1.
|
|
156
|
+
const taroPath = path.join(getUserHomeDir(), constants_1.TARO_CONFIG_FOLDER);
|
|
161
157
|
if (!fs.existsSync(taroPath)) {
|
|
162
158
|
fs.ensureDirSync(taroPath);
|
|
163
159
|
}
|
|
@@ -259,7 +255,7 @@ function generateConstantsList(constants) {
|
|
|
259
255
|
const res = {};
|
|
260
256
|
if (constants && !isEmptyObject(constants)) {
|
|
261
257
|
for (const key in constants) {
|
|
262
|
-
if (lodash_1.isPlainObject(constants[key])) {
|
|
258
|
+
if ((0, lodash_1.isPlainObject)(constants[key])) {
|
|
263
259
|
res[key] = generateConstantsList(constants[key]);
|
|
264
260
|
}
|
|
265
261
|
else {
|
|
@@ -319,7 +315,7 @@ function emptyDirectory(dirPath, opts = { excludes: [] }) {
|
|
|
319
315
|
}
|
|
320
316
|
exports.emptyDirectory = emptyDirectory;
|
|
321
317
|
/* eslint-enable */
|
|
322
|
-
const pascalCase = (str) => str.charAt(0).toUpperCase() + lodash_1.camelCase(str.substr(1));
|
|
318
|
+
const pascalCase = (str) => str.charAt(0).toUpperCase() + (0, lodash_1.camelCase)(str.substr(1));
|
|
323
319
|
exports.pascalCase = pascalCase;
|
|
324
320
|
function getInstalledNpmPkgPath(pkgName, basedir) {
|
|
325
321
|
const resolvePath = require('resolve');
|
|
@@ -340,7 +336,7 @@ function getInstalledNpmPkgVersion(pkgName, basedir) {
|
|
|
340
336
|
}
|
|
341
337
|
exports.getInstalledNpmPkgVersion = getInstalledNpmPkgVersion;
|
|
342
338
|
const recursiveMerge = (src, ...args) => {
|
|
343
|
-
return lodash_1.mergeWith(src, ...args, (value, srcValue) => {
|
|
339
|
+
return (0, lodash_1.mergeWith)(src, ...args, (value, srcValue) => {
|
|
344
340
|
const typeValue = typeof value;
|
|
345
341
|
const typeSrcValue = typeof srcValue;
|
|
346
342
|
if (typeValue !== typeSrcValue)
|
|
@@ -349,20 +345,20 @@ const recursiveMerge = (src, ...args) => {
|
|
|
349
345
|
return value.concat(srcValue);
|
|
350
346
|
}
|
|
351
347
|
if (typeValue === 'object') {
|
|
352
|
-
return exports.recursiveMerge(value, srcValue);
|
|
348
|
+
return (0, exports.recursiveMerge)(value, srcValue);
|
|
353
349
|
}
|
|
354
350
|
});
|
|
355
351
|
};
|
|
356
352
|
exports.recursiveMerge = recursiveMerge;
|
|
357
353
|
const mergeVisitors = (src, ...args) => {
|
|
358
354
|
const validFuncs = ['exit', 'enter'];
|
|
359
|
-
return lodash_1.mergeWith(src, ...args, (value, srcValue, key, object, srcObject) => {
|
|
355
|
+
return (0, lodash_1.mergeWith)(src, ...args, (value, srcValue, key, object, srcObject) => {
|
|
360
356
|
if (!object.hasOwnProperty(key) || !srcObject.hasOwnProperty(key)) {
|
|
361
357
|
return undefined;
|
|
362
358
|
}
|
|
363
359
|
const shouldMergeToArray = validFuncs.indexOf(key) > -1;
|
|
364
360
|
if (shouldMergeToArray) {
|
|
365
|
-
return lodash_1.flatMap([value, srcValue]);
|
|
361
|
+
return (0, lodash_1.flatMap)([value, srcValue]);
|
|
366
362
|
}
|
|
367
363
|
const [newValue, newSrcValue] = [value, srcValue].map(v => {
|
|
368
364
|
if (typeof v === 'function') {
|
|
@@ -374,7 +370,7 @@ const mergeVisitors = (src, ...args) => {
|
|
|
374
370
|
return v;
|
|
375
371
|
}
|
|
376
372
|
});
|
|
377
|
-
return exports.mergeVisitors(newValue, newSrcValue);
|
|
373
|
+
return (0, exports.mergeVisitors)(newValue, newSrcValue);
|
|
378
374
|
});
|
|
379
375
|
};
|
|
380
376
|
exports.mergeVisitors = mergeVisitors;
|
|
@@ -390,13 +386,15 @@ const applyArrayedVisitors = obj => {
|
|
|
390
386
|
};
|
|
391
387
|
}
|
|
392
388
|
else if (typeof funcs === 'object') {
|
|
393
|
-
exports.applyArrayedVisitors(funcs);
|
|
389
|
+
(0, exports.applyArrayedVisitors)(funcs);
|
|
394
390
|
}
|
|
395
391
|
}
|
|
396
392
|
return obj;
|
|
397
393
|
};
|
|
398
394
|
exports.applyArrayedVisitors = applyArrayedVisitors;
|
|
399
395
|
function unzip(zipPath) {
|
|
396
|
+
const Transform = require('stream').Transform;
|
|
397
|
+
const yauzl = require('yauzl');
|
|
400
398
|
return new Promise((resolve, reject) => {
|
|
401
399
|
yauzl.open(zipPath, { lazyEntries: true }, (err, zipfile) => {
|
|
402
400
|
if (err || !zipfile)
|
|
@@ -421,7 +419,7 @@ function unzip(zipPath) {
|
|
|
421
419
|
zipfile.openReadStream(entry, (err, readStream) => {
|
|
422
420
|
if (err || !readStream)
|
|
423
421
|
throw err;
|
|
424
|
-
const filter = new
|
|
422
|
+
const filter = new Transform();
|
|
425
423
|
filter._transform = function (chunk, _encoding, cb) {
|
|
426
424
|
cb(undefined, chunk);
|
|
427
425
|
};
|
|
@@ -444,13 +442,13 @@ function unzip(zipPath) {
|
|
|
444
442
|
});
|
|
445
443
|
}
|
|
446
444
|
exports.unzip = unzip;
|
|
447
|
-
const
|
|
445
|
+
const getAllFilesInFolder = (folder, filter = []) => __awaiter(void 0, void 0, void 0, function* () {
|
|
448
446
|
let files = [];
|
|
449
|
-
const list = readDirWithFileTypes(
|
|
447
|
+
const list = readDirWithFileTypes(folder);
|
|
450
448
|
yield Promise.all(list.map((item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
451
|
-
const itemPath = path.join(
|
|
449
|
+
const itemPath = path.join(folder, item.name);
|
|
452
450
|
if (item.isDirectory) {
|
|
453
|
-
const _files = yield exports.
|
|
451
|
+
const _files = yield (0, exports.getAllFilesInFolder)(itemPath, filter);
|
|
454
452
|
files = [...files, ..._files];
|
|
455
453
|
}
|
|
456
454
|
else if (item.isFile) {
|
|
@@ -460,11 +458,11 @@ const getAllFilesInFloder = (floder, filter = []) => __awaiter(void 0, void 0, v
|
|
|
460
458
|
})));
|
|
461
459
|
return files;
|
|
462
460
|
});
|
|
463
|
-
exports.
|
|
464
|
-
function readDirWithFileTypes(
|
|
465
|
-
const list = fs.readdirSync(
|
|
461
|
+
exports.getAllFilesInFolder = getAllFilesInFolder;
|
|
462
|
+
function readDirWithFileTypes(folder) {
|
|
463
|
+
const list = fs.readdirSync(folder);
|
|
466
464
|
const res = list.map(name => {
|
|
467
|
-
const stat = fs.statSync(path.join(
|
|
465
|
+
const stat = fs.statSync(path.join(folder, name));
|
|
468
466
|
return {
|
|
469
467
|
name,
|
|
470
468
|
isDirectory: stat.isDirectory(),
|
|
@@ -492,6 +490,8 @@ function removeHeadSlash(str) {
|
|
|
492
490
|
}
|
|
493
491
|
exports.removeHeadSlash = removeHeadSlash;
|
|
494
492
|
function analyzeImport(filePath) {
|
|
493
|
+
const parser = require('@babel/parser');
|
|
494
|
+
const traverse = require('@babel/traverse').default;
|
|
495
495
|
const code = fs.readFileSync(filePath).toString();
|
|
496
496
|
let importPaths = [];
|
|
497
497
|
filePath = path.dirname(filePath);
|
|
@@ -504,7 +504,7 @@ function analyzeImport(filePath) {
|
|
|
504
504
|
'optionalChaining'
|
|
505
505
|
]
|
|
506
506
|
});
|
|
507
|
-
|
|
507
|
+
traverse(ast, {
|
|
508
508
|
ImportDeclaration({ node }) {
|
|
509
509
|
const list = [];
|
|
510
510
|
const source = node.source.value;
|
|
@@ -522,7 +522,9 @@ function analyzeImport(filePath) {
|
|
|
522
522
|
if (!dep)
|
|
523
523
|
return;
|
|
524
524
|
importPaths.push(dep);
|
|
525
|
-
|
|
525
|
+
if (path.extname(dep) !== '.json') {
|
|
526
|
+
importPaths = importPaths.concat(analyzeImport(dep));
|
|
527
|
+
}
|
|
526
528
|
}
|
|
527
529
|
});
|
|
528
530
|
return importPaths;
|
|
@@ -615,16 +617,17 @@ function readConfig(configPath) {
|
|
|
615
617
|
let result = {};
|
|
616
618
|
if (fs.existsSync(configPath)) {
|
|
617
619
|
const importPaths = constants_1.REG_SCRIPTS.test(configPath) ? analyzeImport(configPath) : [];
|
|
618
|
-
|
|
620
|
+
(0, swcRegister_1.default)({
|
|
619
621
|
only: [
|
|
620
622
|
configPath,
|
|
621
623
|
filepath => importPaths.includes(filepath)
|
|
622
|
-
]
|
|
624
|
+
],
|
|
625
|
+
plugin: m => new swcRegister_1.InjectDefineConfigHeader().visitProgram(m)
|
|
623
626
|
});
|
|
624
627
|
importPaths.concat([configPath]).forEach(item => {
|
|
625
628
|
delete require.cache[item];
|
|
626
629
|
});
|
|
627
|
-
result = exports.getModuleDefaultExport(require(configPath));
|
|
630
|
+
result = (0, exports.getModuleDefaultExport)(require(configPath));
|
|
628
631
|
}
|
|
629
632
|
else {
|
|
630
633
|
result = readPageConfig(configPath);
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/helper",
|
|
3
|
-
"version": "3.5.0-
|
|
3
|
+
"version": "3.5.0-theta.0",
|
|
4
4
|
"description": "Taro Helper",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dev": "tsc -w",
|
|
10
10
|
"prod": "tsc",
|
|
11
11
|
"clean": "rimraf dist",
|
|
12
|
-
"prepack": "
|
|
12
|
+
"prepack": "pnpm run build",
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"test:dev": "jest --watch"
|
|
15
15
|
},
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"@babel/preset-typescript": "^7.14.5",
|
|
41
41
|
"@babel/register": "^7.14.5",
|
|
42
42
|
"@babel/runtime": "^7.14.5",
|
|
43
|
-
"@
|
|
43
|
+
"@swc/core": "^1.2.204",
|
|
44
|
+
"@swc/register": "^0.1.10",
|
|
44
45
|
"chalk": "3.0.0",
|
|
45
46
|
"chokidar": "^3.3.1",
|
|
46
47
|
"cross-spawn": "^7.0.3",
|
|
@@ -48,8 +49,7 @@
|
|
|
48
49
|
"find-yarn-workspace-root": "2.0.0",
|
|
49
50
|
"fs-extra": "^8.0.1",
|
|
50
51
|
"lodash": "^4.17.21",
|
|
51
|
-
"resolve": "^1.
|
|
52
|
+
"resolve": "^1.22.0",
|
|
52
53
|
"yauzl": "2.10.0"
|
|
53
|
-
}
|
|
54
|
-
"gitHead": "c61624d2f763e6d31e67d6cf9c564efc8b0d0887"
|
|
54
|
+
}
|
|
55
55
|
}
|
package/types/constants.d.ts
CHANGED
|
@@ -73,9 +73,9 @@ export declare const taroJsMobx = "@tarojs/mobx";
|
|
|
73
73
|
export declare const taroJsMobxCommon = "@tarojs/mobx-common";
|
|
74
74
|
export declare const DEVICE_RATIO_NAME = "deviceRatio";
|
|
75
75
|
export declare const isWindows: boolean;
|
|
76
|
-
export declare const DEFAULT_TEMPLATE_SRC = "github:NervJS/taro-project-templates#v3.
|
|
77
|
-
export declare const DEFAULT_TEMPLATE_SRC_GITEE = "direct:https://gitee.com/o2team/taro-project-templates.git#v3.
|
|
78
|
-
export declare const
|
|
76
|
+
export declare const DEFAULT_TEMPLATE_SRC = "github:NervJS/taro-project-templates#v3.5";
|
|
77
|
+
export declare const DEFAULT_TEMPLATE_SRC_GITEE = "direct:https://gitee.com/o2team/taro-project-templates.git#v3.5";
|
|
78
|
+
export declare const TARO_CONFIG_FOLDER = ".taro3.5";
|
|
79
79
|
export declare const TARO_BASE_CONFIG = "index.json";
|
|
80
80
|
export declare const OUTPUT_DIR = "dist";
|
|
81
81
|
export declare const SOURCE_DIR = "src";
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import * as chokidar from 'chokidar'
|
|
3
|
-
import createDebug from 'debug'
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import * as chokidar from 'chokidar'
|
|
3
|
+
import createDebug from 'debug'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
|
|
6
|
+
import { processTypeEnum, IProcessTypeMap } from './constants'
|
|
7
|
+
import * as utils from './utils'
|
|
8
|
+
import * as npm from './npm'
|
|
9
|
+
import createBabelRegister, { injectDefineConfigHeader } from './babelRegister'
|
|
10
|
+
import createSwcRegister from './swcRegister'
|
|
9
11
|
|
|
10
12
|
export declare enum META_TYPE {
|
|
11
13
|
ENTRY = 'ENTRY',
|
|
@@ -25,123 +27,127 @@ export declare enum FRAMEWORK_MAP {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
declare interface helper {
|
|
28
|
-
npm: typeof npm
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
npm: typeof npm
|
|
31
|
+
createSwcRegister: typeof createSwcRegister
|
|
32
|
+
createBabelRegister: typeof createBabelRegister
|
|
33
|
+
injectDefineConfigHeader: typeof injectDefineConfigHeader
|
|
34
|
+
fs: typeof fs
|
|
35
|
+
chokidar: typeof chokidar
|
|
36
|
+
chalk: typeof chalk
|
|
34
37
|
createDebug: createDebug.Debug & {
|
|
35
|
-
debug: createDebug.Debug
|
|
36
|
-
default: createDebug.Debug
|
|
37
|
-
}
|
|
38
|
-
normalizePath(path: string): string
|
|
39
|
-
isNpmPkg(name: string): boolean
|
|
40
|
-
isQuickAppPkg(name: string): boolean
|
|
41
|
-
isAliasPath(name: string, pathAlias?: object): boolean
|
|
42
|
-
replaceAliasPath(filePath: string, name: string, pathAlias?: object): string
|
|
43
|
-
promoteRelativePath(fPath: string): string
|
|
44
|
-
resolveStylePath(p: string): string
|
|
45
|
-
printLog(type: processTypeEnum, tag: string, filePath?: string | undefined): void
|
|
46
|
-
recursiveFindNodeModules(filePath: string): string
|
|
47
|
-
getUserHomeDir(): string
|
|
48
|
-
getTaroPath(): string
|
|
49
|
-
getConfig(): object
|
|
50
|
-
getSystemUsername(): string
|
|
51
|
-
shouldUseYarn(): boolean
|
|
52
|
-
shouldUseCnpm(): boolean
|
|
53
|
-
isEmptyObject(obj: any): boolean
|
|
54
|
-
resolveScriptPath(p: string): string
|
|
38
|
+
debug: createDebug.Debug
|
|
39
|
+
default: createDebug.Debug
|
|
40
|
+
}
|
|
41
|
+
normalizePath(path: string): string
|
|
42
|
+
isNpmPkg(name: string): boolean
|
|
43
|
+
isQuickAppPkg(name: string): boolean
|
|
44
|
+
isAliasPath(name: string, pathAlias?: object): boolean
|
|
45
|
+
replaceAliasPath(filePath: string, name: string, pathAlias?: object): string
|
|
46
|
+
promoteRelativePath(fPath: string): string
|
|
47
|
+
resolveStylePath(p: string): string
|
|
48
|
+
printLog(type: processTypeEnum, tag: string, filePath?: string | undefined): void
|
|
49
|
+
recursiveFindNodeModules(filePath: string): string
|
|
50
|
+
getUserHomeDir(): string
|
|
51
|
+
getTaroPath(): string
|
|
52
|
+
getConfig(): object
|
|
53
|
+
getSystemUsername(): string
|
|
54
|
+
shouldUseYarn(): boolean
|
|
55
|
+
shouldUseCnpm(): boolean
|
|
56
|
+
isEmptyObject(obj: any): boolean
|
|
57
|
+
resolveScriptPath(p: string): string
|
|
55
58
|
resolveMainFilePath(p: string, extArrs?: string[]): string
|
|
56
|
-
generateEnvList(env: object): object
|
|
57
|
-
generateConstantsList(constants: object): object
|
|
58
|
-
cssImports(content: string): string[]
|
|
59
|
-
emptyDirectory(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
59
|
+
generateEnvList(env: object): object
|
|
60
|
+
generateConstantsList(constants: object): object
|
|
61
|
+
cssImports(content: string): string[]
|
|
62
|
+
emptyDirectory(
|
|
63
|
+
dirPath: string,
|
|
64
|
+
opts?: {
|
|
65
|
+
excludes: string[]
|
|
66
|
+
}
|
|
67
|
+
): void
|
|
68
|
+
getInstalledNpmPkgPath(pkgName: string, basedir: string): string | null
|
|
69
|
+
getInstalledNpmPkgVersion(pkgName: string, basedir: string): string | null
|
|
70
|
+
unzip(zipPath: any): Promise<unknown>
|
|
71
|
+
getBabelConfig(babel: any): any
|
|
72
|
+
readDirWithFileTypes(folder: string): utils.FileStat[]
|
|
73
|
+
extnameExpRegOf(filePath: string): RegExp
|
|
74
|
+
addPlatforms(platform: string): void
|
|
75
|
+
isNodeModule: (filename: string) => boolean
|
|
76
|
+
pascalCase: (str: string) => string
|
|
77
|
+
recursiveMerge: <T = any>(src: Partial<T>, ...args: (Partial<T> | undefined)[]) => any
|
|
78
|
+
mergeVisitors: (src: any, ...args: any[]) => any
|
|
79
|
+
applyArrayedVisitors: (obj: any) => any
|
|
80
|
+
getAllFilesInFolder: (folder: string, filter?: string[]) => Promise<string[]>
|
|
81
|
+
getModuleDefaultExport: (exports: any) => any
|
|
82
|
+
removeHeadSlash: (str: string) => string
|
|
83
|
+
readConfig: (configPath: string) => any
|
|
84
|
+
readPageConfig: (configPath: string) => any
|
|
85
|
+
PLATFORMS: any
|
|
86
|
+
processTypeEnum: typeof processTypeEnum
|
|
87
|
+
processTypeMap: IProcessTypeMap
|
|
88
|
+
CSS_EXT: string[]
|
|
89
|
+
SCSS_EXT: string[]
|
|
90
|
+
JS_EXT: string[]
|
|
91
|
+
TS_EXT: string[]
|
|
92
|
+
UX_EXT: string[]
|
|
93
|
+
SCRIPT_EXT: string[]
|
|
94
|
+
VUE_EXT: string[]
|
|
95
|
+
REG_JS: RegExp
|
|
96
|
+
REG_SCRIPT: RegExp
|
|
97
|
+
REG_TYPESCRIPT: RegExp
|
|
98
|
+
REG_SCRIPTS: RegExp
|
|
99
|
+
REG_VUE: RegExp
|
|
100
|
+
REG_SASS: RegExp
|
|
101
|
+
REG_SASS_SASS: RegExp
|
|
102
|
+
REG_SASS_SCSS: RegExp
|
|
103
|
+
REG_LESS: RegExp
|
|
104
|
+
REG_STYLUS: RegExp
|
|
105
|
+
REG_STYLE: RegExp
|
|
106
|
+
REG_CSS: RegExp
|
|
107
|
+
REG_MEDIA: RegExp
|
|
108
|
+
REG_IMAGE: RegExp
|
|
109
|
+
REG_FONT: RegExp
|
|
110
|
+
REG_JSON: RegExp
|
|
111
|
+
REG_UX: RegExp
|
|
112
|
+
REG_TEMPLATE: RegExp
|
|
113
|
+
REG_WXML_IMPORT: RegExp
|
|
114
|
+
REG_URL: RegExp
|
|
115
|
+
CSS_IMPORT_REG: RegExp
|
|
116
|
+
NODE_MODULES: 'node_modules'
|
|
117
|
+
NODE_MODULES_REG: RegExp
|
|
118
|
+
PROJECT_CONFIG: 'config/index'
|
|
113
119
|
DEVICE_RATIO: {
|
|
114
|
-
640: number
|
|
115
|
-
750: number
|
|
116
|
-
828: number
|
|
117
|
-
}
|
|
120
|
+
640: number
|
|
121
|
+
750: number
|
|
122
|
+
828: number
|
|
123
|
+
}
|
|
118
124
|
FILE_PROCESSOR_MAP: {
|
|
119
|
-
'.js': string
|
|
120
|
-
'.scss': string
|
|
121
|
-
'.sass': string
|
|
122
|
-
'.less': string
|
|
123
|
-
'.styl': string
|
|
124
|
-
}
|
|
125
|
-
META_TYPE: typeof META_TYPE
|
|
126
|
-
FRAMEWORK_MAP: typeof FRAMEWORK_MAP
|
|
127
|
-
UPDATE_PACKAGE_LIST: string[]
|
|
128
|
-
taroJsComponents:
|
|
129
|
-
taroJsQuickAppComponents:
|
|
130
|
-
taroJsFramework:
|
|
131
|
-
taroJsRedux:
|
|
132
|
-
taroJsMobx:
|
|
133
|
-
taroJsMobxCommon:
|
|
134
|
-
DEVICE_RATIO_NAME:
|
|
135
|
-
isWindows: boolean
|
|
136
|
-
DEFAULT_TEMPLATE_SRC:
|
|
137
|
-
DEFAULT_TEMPLATE_SRC_GITEE:
|
|
138
|
-
|
|
139
|
-
TARO_BASE_CONFIG:
|
|
140
|
-
OUTPUT_DIR:
|
|
141
|
-
SOURCE_DIR:
|
|
142
|
-
TEMP_DIR:
|
|
143
|
-
NPM_DIR:
|
|
144
|
-
ENTRY:
|
|
125
|
+
'.js': string
|
|
126
|
+
'.scss': string
|
|
127
|
+
'.sass': string
|
|
128
|
+
'.less': string
|
|
129
|
+
'.styl': string
|
|
130
|
+
}
|
|
131
|
+
META_TYPE: typeof META_TYPE
|
|
132
|
+
FRAMEWORK_MAP: typeof FRAMEWORK_MAP
|
|
133
|
+
UPDATE_PACKAGE_LIST: string[]
|
|
134
|
+
taroJsComponents: '@tarojs/components'
|
|
135
|
+
taroJsQuickAppComponents: '@tarojs/components-qa'
|
|
136
|
+
taroJsFramework: '@tarojs/taro'
|
|
137
|
+
taroJsRedux: '@tarojs/redux'
|
|
138
|
+
taroJsMobx: '@tarojs/mobx'
|
|
139
|
+
taroJsMobxCommon: '@tarojs/mobx-common'
|
|
140
|
+
DEVICE_RATIO_NAME: 'deviceRatio'
|
|
141
|
+
isWindows: boolean
|
|
142
|
+
DEFAULT_TEMPLATE_SRC: 'github:NervJS/taro-project-templates#v3.5'
|
|
143
|
+
DEFAULT_TEMPLATE_SRC_GITEE: 'direct:https://gitee.com/o2team/taro-project-templates.git#v3.5'
|
|
144
|
+
TARO_CONFIG_FOLDER: '.taro3.5'
|
|
145
|
+
TARO_BASE_CONFIG: 'index.json'
|
|
146
|
+
OUTPUT_DIR: 'dist'
|
|
147
|
+
SOURCE_DIR: 'src'
|
|
148
|
+
TEMP_DIR: '.temp'
|
|
149
|
+
NPM_DIR: 'npm'
|
|
150
|
+
ENTRY: 'app'
|
|
145
151
|
FRAMEWORK_EXT_MAP: Record<FRAMEWORK_MAP, string[]>
|
|
146
152
|
}
|
|
147
153
|
declare const helper: helper
|
package/types/utils.d.ts
CHANGED
|
@@ -31,13 +31,13 @@ export declare const mergeVisitors: (src: any, ...args: any[]) => any;
|
|
|
31
31
|
export declare const applyArrayedVisitors: (obj: any) => any;
|
|
32
32
|
export declare function unzip(zipPath: any): Promise<unknown>;
|
|
33
33
|
export declare function getBabelConfig(babel: any): any;
|
|
34
|
-
export declare const
|
|
34
|
+
export declare const getAllFilesInFolder: (folder: string, filter?: string[]) => Promise<string[]>;
|
|
35
35
|
export interface FileStat {
|
|
36
36
|
name: string;
|
|
37
37
|
isDirectory: boolean;
|
|
38
38
|
isFile: boolean;
|
|
39
39
|
}
|
|
40
|
-
export declare function readDirWithFileTypes(
|
|
40
|
+
export declare function readDirWithFileTypes(folder: string): FileStat[];
|
|
41
41
|
export declare function extnameExpRegOf(filePath: string): RegExp;
|
|
42
42
|
export declare function addPlatforms(platform: string): void;
|
|
43
43
|
export declare const getModuleDefaultExport: (exports: any) => any;
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|