@dcloudio/uni-cli-shared 3.0.0-alpha-3030520211229003 → 3.0.0-alpha-3030520211229004
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/logs/console.d.ts
CHANGED
package/dist/logs/console.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.rewriteConsoleExpr = void 0;
|
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const F = '__f__';
|
|
10
|
-
function rewriteConsoleExpr(filename, code) {
|
|
10
|
+
function rewriteConsoleExpr(id, filename, code, sourceMap = false) {
|
|
11
11
|
filename = (0, utils_1.normalizePath)(filename);
|
|
12
12
|
const re = /(console\.(log|info|debug|warn|error))\(([^)]+)\)/g;
|
|
13
13
|
const locate = getLocator(code);
|
|
@@ -17,7 +17,10 @@ function rewriteConsoleExpr(filename, code) {
|
|
|
17
17
|
const [, expr, type] = match;
|
|
18
18
|
s.overwrite(match.index, match.index + expr.length + 1, F + `('${type}','at ${filename}:${locate(match.index).line + 1}',`);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
code: s.toString(),
|
|
22
|
+
map: sourceMap ? s.generateMap({ source: id, hires: true }) : null,
|
|
23
|
+
};
|
|
21
24
|
}
|
|
22
25
|
exports.rewriteConsoleExpr = rewriteConsoleExpr;
|
|
23
26
|
function getLocator(source) {
|
package/dist/scripts.js
CHANGED
|
@@ -4,27 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseScripts = void 0;
|
|
7
|
+
const shared_1 = require("@vue/shared");
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
function parseScripts(name, pkgPath) {
|
|
9
|
-
var _a, _b
|
|
10
|
+
var _a, _b;
|
|
10
11
|
if (!fs_1.default.existsSync(pkgPath)) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
14
|
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
|
|
14
|
-
const
|
|
15
|
+
const scripts = ((_a = pkg['uni-app']) === null || _a === void 0 ? void 0 : _a.scripts) || {};
|
|
16
|
+
const options = scripts[name];
|
|
15
17
|
if (!options) {
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
|
-
if (!((
|
|
20
|
+
if (!((_b = options.env) === null || _b === void 0 ? void 0 : _b.UNI_PLATFORM)) {
|
|
19
21
|
console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
|
|
20
22
|
process.exit(0);
|
|
21
23
|
}
|
|
22
24
|
const { UNI_PLATFORM, ...define } = options.env;
|
|
25
|
+
const context = options.define || {};
|
|
26
|
+
// 补充当前编译环境未定义的其他编译环境 define
|
|
27
|
+
Object.keys(scripts).forEach((scriptName) => {
|
|
28
|
+
if (scriptName !== name) {
|
|
29
|
+
const scriptDefine = scripts[scriptName].define || {};
|
|
30
|
+
Object.keys(scriptDefine).forEach((key) => {
|
|
31
|
+
if (!(0, shared_1.hasOwn)(context, key)) {
|
|
32
|
+
context[key] = false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
23
37
|
return {
|
|
24
38
|
name: name,
|
|
25
39
|
platform: UNI_PLATFORM,
|
|
26
40
|
define,
|
|
27
|
-
context
|
|
41
|
+
context,
|
|
28
42
|
};
|
|
29
43
|
}
|
|
30
44
|
exports.parseScripts = parseScripts;
|
|
@@ -8,12 +8,17 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
8
8
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const console_1 = require("../../logs/console");
|
|
11
|
+
const utils_2 = require("../../vite/utils/utils");
|
|
11
12
|
const debugConsole = (0, debug_1.default)('vite:uni:console');
|
|
12
13
|
function uniConsolePlugin(options) {
|
|
13
14
|
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
15
|
+
let resolvedConfig;
|
|
14
16
|
return {
|
|
15
17
|
name: 'vite:uni-console',
|
|
16
18
|
enforce: 'pre',
|
|
19
|
+
configResolved(config) {
|
|
20
|
+
resolvedConfig = config;
|
|
21
|
+
},
|
|
17
22
|
transform(code, id) {
|
|
18
23
|
if (!filter(id))
|
|
19
24
|
return null;
|
|
@@ -30,10 +35,7 @@ function uniConsolePlugin(options) {
|
|
|
30
35
|
return null;
|
|
31
36
|
}
|
|
32
37
|
debugConsole(id);
|
|
33
|
-
return
|
|
34
|
-
code: (0, console_1.rewriteConsoleExpr)(filename, code),
|
|
35
|
-
map: null,
|
|
36
|
-
};
|
|
38
|
+
return (0, console_1.rewriteConsoleExpr)(id, filename, code, (0, utils_2.withSourcemap)(resolvedConfig));
|
|
37
39
|
},
|
|
38
40
|
};
|
|
39
41
|
}
|
|
@@ -111,7 +111,9 @@ function uniViteInjectPlugin(options) {
|
|
|
111
111
|
if (reassignments.has(hash)) {
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
|
-
if (parent &&
|
|
114
|
+
if (parent &&
|
|
115
|
+
(0, utils_1.isAssignmentExpression)(parent) &&
|
|
116
|
+
parent.left === node) {
|
|
115
117
|
reassignments.add(hash);
|
|
116
118
|
return false;
|
|
117
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3030520211229004",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@babel/core": "^7.16.5",
|
|
22
22
|
"@babel/parser": "^7.16.4",
|
|
23
23
|
"@babel/types": "^7.16.0",
|
|
24
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
25
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
24
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3030520211229004",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3030520211229004",
|
|
26
26
|
"@rollup/pluginutils": "^4.1.2",
|
|
27
27
|
"@vue/compiler-core": "3.2.26",
|
|
28
28
|
"@vue/compiler-dom": "3.2.26",
|