@tuya-sat/micro-script 1.1.1 → 1.1.4
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.
|
@@ -27,9 +27,11 @@ exports.runBundleServer = exports.createServerCompiler = void 0;
|
|
|
27
27
|
const webpack_1 = __importDefault(require("webpack"));
|
|
28
28
|
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
|
|
29
29
|
const ora_1 = __importDefault(require("ora"));
|
|
30
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
30
31
|
const paths_1 = __importDefault(require("../config/paths"));
|
|
31
32
|
const webpack_config_1 = __importDefault(require("../config/webpack.config"));
|
|
32
33
|
const options_1 = __importDefault(require("./options"));
|
|
34
|
+
const onceFactory_1 = require("../utils/onceFactory");
|
|
33
35
|
function createServerCompiler() {
|
|
34
36
|
const config = Object.assign(Object.assign({}, (0, webpack_config_1.default)()), {
|
|
35
37
|
//下面所有配置都是为了精简terminal输出
|
|
@@ -64,6 +66,10 @@ function runBundleServer({ port, compiler, internalDevConfig = {}, }) {
|
|
|
64
66
|
spinner.isSpinning && spinner.succeed();
|
|
65
67
|
console.log(`compiled time ~${endTime - startTime}ms`);
|
|
66
68
|
});
|
|
69
|
+
//临时提示
|
|
70
|
+
compiler.hooks.done.tap("once-tip", (0, onceFactory_1.onceFactory)(() => {
|
|
71
|
+
console.log(chalk_1.default.yellow(`Tip: 如果HMR失效且保存文件时造成多次compile,请考虑调高aggregateTimeout参数(可以尝试100)`));
|
|
72
|
+
}));
|
|
67
73
|
server.start();
|
|
68
74
|
});
|
|
69
75
|
}
|
package/dist/module/mock.js
CHANGED
|
@@ -19,9 +19,10 @@ function useMocks(app) {
|
|
|
19
19
|
if (!mock) {
|
|
20
20
|
return next();
|
|
21
21
|
}
|
|
22
|
-
const mockItem = data.find((
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const mockItem = data.find(({ path, mock, method: configMethod }) => {
|
|
23
|
+
return (configMethod.toUpperCase() === reqMethod &&
|
|
24
|
+
isPath(url.split("?")[0], path) &&
|
|
25
|
+
mock);
|
|
25
26
|
});
|
|
26
27
|
if (mockItem) {
|
|
27
28
|
res.status(200).send(mockItem.res);
|
|
@@ -20,16 +20,6 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
20
20
|
const mainServer_1 = __importDefault(require("../module/mainServer"));
|
|
21
21
|
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
22
22
|
const bundleServer_1 = require("../module/bundleServer");
|
|
23
|
-
function onceFactory(fn, count = 1) {
|
|
24
|
-
let executeCount = 0;
|
|
25
|
-
return () => {
|
|
26
|
-
if (executeCount >= count) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
executeCount++;
|
|
30
|
-
return fn();
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
23
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
24
|
console.log(chalk_1.default.yellow(`Tip: 目前--main命令是个体验命令,请知悉`));
|
|
35
25
|
let defaultPort = 9000;
|
|
@@ -55,10 +45,6 @@ function onceFactory(fn, count = 1) {
|
|
|
55
45
|
port: bundledServerPort,
|
|
56
46
|
compiler,
|
|
57
47
|
});
|
|
58
|
-
//临时提示
|
|
59
|
-
compiler.hooks.done.tap("once-tip", onceFactory(() => {
|
|
60
|
-
console.log(chalk_1.default.yellow(`Tip: 如果HMR失效且保存文件时造成多次compile,请考虑调高aggregateTimeout参数(可以尝试100)`));
|
|
61
|
-
}));
|
|
62
48
|
}))().catch((err) => {
|
|
63
49
|
console.log(err);
|
|
64
50
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function onceFactory(fn: Function, count?: number): () => any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onceFactory = void 0;
|
|
4
|
+
function onceFactory(fn, count = 1) {
|
|
5
|
+
let executeCount = 0;
|
|
6
|
+
return () => {
|
|
7
|
+
if (executeCount >= count) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
executeCount++;
|
|
11
|
+
return fn();
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.onceFactory = onceFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"@babel/preset-react": "^7.14.5",
|
|
16
16
|
"@babel/preset-typescript": "^7.15.0",
|
|
17
17
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
18
|
-
"@tuya-sat/micro-dev-loader": "1.1.
|
|
19
|
-
"@tuya-sat/micro-dev-proxy": "1.1.
|
|
20
|
-
"@tuya-sat/micro-utils": "1.1.
|
|
18
|
+
"@tuya-sat/micro-dev-loader": "1.1.4",
|
|
19
|
+
"@tuya-sat/micro-dev-proxy": "1.1.4",
|
|
20
|
+
"@tuya-sat/micro-utils": "1.1.4",
|
|
21
21
|
"babel-loader": "^8.2.2",
|
|
22
22
|
"babel-plugin-import": "^1.13.3",
|
|
23
23
|
"chalk": "4.1.2",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"path-to-regexp": "^6.2.0",
|
|
37
37
|
"portfinder": "^1.0.28",
|
|
38
38
|
"postcss": "^8.4.5",
|
|
39
|
-
"postcss-loader": "^6.
|
|
40
|
-
"postcss-preset-env": "^
|
|
39
|
+
"postcss-loader": "^6.2.1",
|
|
40
|
+
"postcss-preset-env": "^7.4.2",
|
|
41
41
|
"react-refresh": "^0.10.0",
|
|
42
42
|
"resolve-url-loader": "^4.0.0",
|
|
43
43
|
"sass": "^1.42.1",
|
|
@@ -57,6 +57,9 @@
|
|
|
57
57
|
"@types/webpack-dev-server": "^4.5.0",
|
|
58
58
|
"typescript": "^4.4.4"
|
|
59
59
|
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@tuya-sat/micro-dev-component": "^1.1.4"
|
|
62
|
+
},
|
|
60
63
|
"keywords": [
|
|
61
64
|
"saturn-project",
|
|
62
65
|
"micro-frontend",
|