@dcloudio/uni-cli-shared 3.0.0-alpha-5010120260522001 → 3.0.0-alpha-1000920260525813
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/hbx/alias.js +21 -2
- package/dist/hbx/index.d.ts +1 -1
- package/dist/i18n.js +32 -17
- package/dist/json/app/pages/definePage.js +1 -1
- package/dist/logs/console.js +15 -1
- package/dist/messages/en.d.ts +0 -1
- package/dist/messages/en.js +0 -1
- package/dist/messages/index.d.ts +0 -2
- package/dist/messages/zh_CN.d.ts +0 -1
- package/dist/messages/zh_CN.js +0 -1
- package/dist/mp/imports.d.ts +3 -1
- package/dist/mp/template.d.ts +2 -1
- package/dist/mp/usingComponents.d.ts +2 -1
- package/dist/vite/cloud.js +2 -5
- package/dist/vite/index.d.ts +2 -3
- package/dist/vite/plugins/console.js +31 -27
- package/dist/vite/plugins/copy.js +1 -0
- package/dist/vite/plugins/cssScoped.js +25 -16
- package/dist/vite/plugins/dynamicImportPolyfill.d.ts +8 -1
- package/dist/vite/plugins/easycom.js +46 -43
- package/dist/vite/plugins/inject.js +132 -113
- package/dist/vite/plugins/json.js +17 -14
- package/dist/vite/plugins/jsonJs.d.ts +2 -2
- package/dist/vite/plugins/jsonJs.js +7 -0
- package/dist/vite/plugins/mainJs.d.ts +1 -1
- package/dist/vite/plugins/mainJs.js +7 -0
- package/dist/vite/plugins/pre.js +35 -30
- package/dist/vite/plugins/sfc.js +15 -2
- package/dist/vite/plugins/sourceMap.js +4 -1
- package/dist/vite/plugins/stats.js +0 -26
- package/dist/vite/plugins/uts/ext-api.js +23 -17
- package/dist/vite/plugins/uts/uni_modules.js +66 -39
- package/dist/vite/plugins/uts/uvue.js +55 -48
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +12 -4
- package/dist/vite/plugins/vitejs/plugins/asset.js +7 -2
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +102 -82
- package/dist/vite/utils/utils.d.ts +3 -2
- package/dist/vue/transforms/x/transformDirection.js +4 -33
- package/dist/watcher.d.ts +1 -0
- package/dist/x.d.ts +1 -0
- package/dist/x.js +5 -1
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +16 -23
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +16 -23
- package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +16 -23
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +23 -66
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +67 -115
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +1 -1
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +1 -1
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +1 -1
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +1 -1
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +3 -3
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +43 -201
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +41 -199
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +12 -50
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +42 -212
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +1 -1
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +1 -1
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +1 -1
- package/package.json +7 -8
package/dist/hbx/alias.js
CHANGED
|
@@ -78,8 +78,27 @@ function initModuleAlias() {
|
|
|
78
78
|
if (process.env.UNI_APP_PLATFORM ||
|
|
79
79
|
process.env.UNI_PLATFORM === 'app-harmony') {
|
|
80
80
|
if (!process.env.UNI_APP_X_VAPOR_RENDER_TARGET) {
|
|
81
|
-
//
|
|
82
|
-
process.env.
|
|
81
|
+
// ios 和 harmony 平台默认使用 bytecode 目标,存在 .native 文件时使用 native 目标;其他平台如果存在 .dynamic 文件则使用 bytecode 目标,否则使用 native 目标
|
|
82
|
+
if (process.env.UNI_APP_PLATFORM === 'ios' ||
|
|
83
|
+
process.env.UNI_APP_PLATFORM === 'harmony' ||
|
|
84
|
+
process.env.UNI_PLATFORM === 'app-harmony') {
|
|
85
|
+
if (process.env.UNI_INPUT_DIR &&
|
|
86
|
+
fs_1.default.existsSync(path_1.default.resolve(process.env.UNI_INPUT_DIR, '.native'))) {
|
|
87
|
+
process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'nativecode';
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (process.env.UNI_INPUT_DIR &&
|
|
95
|
+
fs_1.default.existsSync(path_1.default.resolve(process.env.UNI_INPUT_DIR, '.dynamic'))) {
|
|
96
|
+
process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'nativecode';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
83
102
|
}
|
|
84
103
|
if (process.env.UNI_APP_X_VAPOR_RENDER_TARGET?.includes('bytecode')) {
|
|
85
104
|
process.env.UNI_APP_X_DOM2_DYNAMIC = 'true';
|
package/dist/hbx/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { formatAtFilename, createErrorWithBlockFlag } from './log';
|
|
2
2
|
export * from './env';
|
|
3
3
|
export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
|
|
4
|
-
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
|
|
4
|
+
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite/dist/node").Plugin<any>;
|
|
5
5
|
export declare function isEnableConsole(): boolean;
|
package/dist/i18n.js
CHANGED
|
@@ -47,36 +47,51 @@ function isUniAppLocaleFile(filepath) {
|
|
|
47
47
|
return localeJsonRE.test(path_1.default.basename(filepath));
|
|
48
48
|
}
|
|
49
49
|
exports.isUniAppLocaleFile = isUniAppLocaleFile;
|
|
50
|
+
const localeJsonCache = new Map();
|
|
50
51
|
function parseLocaleJson(filepath) {
|
|
52
|
+
const { mtimeMs, size } = fs_1.default.statSync(filepath);
|
|
53
|
+
const cached = localeJsonCache.get(filepath);
|
|
54
|
+
if (cached && cached.mtimeMs === mtimeMs && cached.size === size) {
|
|
55
|
+
return cached.json;
|
|
56
|
+
}
|
|
51
57
|
let jsonObj = (0, json_1.parseJson)(fs_1.default.readFileSync(filepath, 'utf8'), false, filepath);
|
|
52
58
|
if (isUniAppLocaleFile(filepath)) {
|
|
53
59
|
jsonObj = jsonObj.common || {};
|
|
54
60
|
}
|
|
61
|
+
localeJsonCache.set(filepath, { mtimeMs, size, json: jsonObj });
|
|
55
62
|
return jsonObj;
|
|
56
63
|
}
|
|
64
|
+
const localeFilesCache = new Map();
|
|
57
65
|
function getLocaleFiles(cwd) {
|
|
58
|
-
|
|
66
|
+
let mtimeMs;
|
|
67
|
+
try {
|
|
68
|
+
mtimeMs = fs_1.default.statSync(cwd).mtimeMs;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const cached = localeFilesCache.get(cwd);
|
|
74
|
+
if (cached && cached.mtimeMs === mtimeMs) {
|
|
75
|
+
return cached.files;
|
|
76
|
+
}
|
|
77
|
+
const files = (0, fast_glob_1.sync)('*.json', { cwd, absolute: true });
|
|
78
|
+
localeFilesCache.set(cwd, { mtimeMs, files });
|
|
79
|
+
return files;
|
|
59
80
|
}
|
|
60
81
|
exports.getLocaleFiles = getLocaleFiles;
|
|
61
82
|
function initLocales(dir, withMessages = true) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (withMessages) {
|
|
72
|
-
(0, shared_1.extend)(res[locale] || (res[locale] = {}), parseLocaleJson(path_1.default.join(dir, filename)));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
res[locale] = {};
|
|
76
|
-
}
|
|
83
|
+
return getLocaleFiles(dir).reduce((res, filepath) => {
|
|
84
|
+
const filename = path_1.default.basename(filepath);
|
|
85
|
+
try {
|
|
86
|
+
const locale = filename.replace(/(uni-app.)?(.*).json/, '$2');
|
|
87
|
+
if (withMessages) {
|
|
88
|
+
(0, shared_1.extend)(res[locale] || (res[locale] = {}), parseLocaleJson(filepath));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
res[locale] = {};
|
|
77
92
|
}
|
|
78
|
-
catch (e) { }
|
|
79
93
|
}
|
|
94
|
+
catch { }
|
|
80
95
|
return res;
|
|
81
96
|
}, {});
|
|
82
97
|
}
|
|
@@ -46,7 +46,7 @@ function defineNVuePageCode(pagesJson) {
|
|
|
46
46
|
}
|
|
47
47
|
const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
|
|
48
48
|
if (pagePathWithExtname) {
|
|
49
|
-
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>
|
|
49
|
+
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>res.default)`);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
return importNVuePagesCode.join('\n');
|
package/dist/logs/console.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.appendConsoleExpr = exports.restoreConsoleExpr = exports.rewriteConsoleExpr = void 0;
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const x_1 = require("../x");
|
|
9
10
|
function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
10
11
|
filename = (0, utils_1.normalizePath)(filename);
|
|
11
12
|
const re = /(console\.(log|info|debug|warn|error))\s*\(([^)]+)\)/g;
|
|
@@ -19,12 +20,25 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
|
19
20
|
if (s.hasChanged()) {
|
|
20
21
|
return {
|
|
21
22
|
code: s.toString(),
|
|
22
|
-
map: sourceMap
|
|
23
|
+
map: sourceMap
|
|
24
|
+
? normalizeSourceMap(s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() }))
|
|
25
|
+
: { mappings: '' },
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
28
|
return { code, map: null };
|
|
26
29
|
}
|
|
27
30
|
exports.rewriteConsoleExpr = rewriteConsoleExpr;
|
|
31
|
+
function normalizeSourceMap(map) {
|
|
32
|
+
return {
|
|
33
|
+
...map,
|
|
34
|
+
file: map.file || '',
|
|
35
|
+
names: map.names || [],
|
|
36
|
+
sources: map.sources || [],
|
|
37
|
+
sourcesContent: map.sourcesContent || [],
|
|
38
|
+
toString: () => map.toString(),
|
|
39
|
+
toUrl: () => map.toUrl(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
28
42
|
function restoreConsoleExpr(code) {
|
|
29
43
|
return code.replace(/(?:uni\.)?__f__\('([^']+)','at ([^:]+):(\d+)',/g, 'console.$1(');
|
|
30
44
|
}
|
package/dist/messages/en.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ declare const _default: {
|
|
|
15
15
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
16
16
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
17
17
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. Switching vapor mode requires restarting to take effect.";
|
|
18
|
-
readonly 'dev.watching.vapor.render.target': "vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.";
|
|
19
18
|
readonly 'build.failed': "DONE Build failed.";
|
|
20
19
|
readonly 'compiler.build.failed': "Build failed with errors.";
|
|
21
20
|
readonly 'stat.warn.appid': "The current application is not configured with Appid, and uni statistics cannot be used. For details, see https://ask.dcloud.net.cn/article/36303";
|
package/dist/messages/en.js
CHANGED
|
@@ -17,7 +17,6 @@ exports.default = {
|
|
|
17
17
|
'dev.watching.end.pages': 'DONE Build complete. PAGES:{pages}',
|
|
18
18
|
'dev.watching.end.files': 'DONE Build complete. FILES:{files}',
|
|
19
19
|
'dev.watching.restart.vapor': 'DONE Restart required. Switching vapor mode requires restarting to take effect.',
|
|
20
|
-
'dev.watching.vapor.render.target': 'vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.',
|
|
21
20
|
'build.failed': 'DONE Build failed.',
|
|
22
21
|
'compiler.build.failed': 'Build failed with errors.',
|
|
23
22
|
'stat.warn.appid': 'The current application is not configured with Appid, and uni statistics cannot be used. For details, see https://ask.dcloud.net.cn/article/36303',
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare const M: {
|
|
|
15
15
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
16
16
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
17
17
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. 切换蒸汽模式需要重新运行才能生效。";
|
|
18
|
-
readonly 'dev.watching.vapor.render.target': "manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。";
|
|
19
18
|
readonly 'build.failed': "DONE Build failed.";
|
|
20
19
|
readonly 'compiler.build.failed': "编译失败";
|
|
21
20
|
readonly 'stat.warn.appid': "当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303";
|
|
@@ -72,7 +71,6 @@ export declare const M: {
|
|
|
72
71
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
73
72
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
74
73
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. Switching vapor mode requires restarting to take effect.";
|
|
75
|
-
readonly 'dev.watching.vapor.render.target': "vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.";
|
|
76
74
|
readonly 'build.failed': "DONE Build failed.";
|
|
77
75
|
readonly 'compiler.build.failed': "Build failed with errors.";
|
|
78
76
|
readonly 'stat.warn.appid': "The current application is not configured with Appid, and uni statistics cannot be used. For details, see https://ask.dcloud.net.cn/article/36303";
|
package/dist/messages/zh_CN.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ declare const _default: {
|
|
|
15
15
|
readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
|
|
16
16
|
readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
|
|
17
17
|
readonly 'dev.watching.restart.vapor': "DONE Restart required. 切换蒸汽模式需要重新运行才能生效。";
|
|
18
|
-
readonly 'dev.watching.vapor.render.target': "manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。";
|
|
19
18
|
readonly 'build.failed': "DONE Build failed.";
|
|
20
19
|
readonly 'compiler.build.failed': "编译失败";
|
|
21
20
|
readonly 'stat.warn.appid': "当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303";
|
package/dist/messages/zh_CN.js
CHANGED
|
@@ -17,7 +17,6 @@ exports.default = {
|
|
|
17
17
|
'dev.watching.end.pages': 'DONE Build complete. PAGES:{pages}',
|
|
18
18
|
'dev.watching.end.files': 'DONE Build complete. FILES:{files}',
|
|
19
19
|
'dev.watching.restart.vapor': 'DONE Restart required. 切换蒸汽模式需要重新运行才能生效。',
|
|
20
|
-
'dev.watching.vapor.render.target': 'manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。',
|
|
21
20
|
'build.failed': 'DONE Build failed.',
|
|
22
21
|
'compiler.build.failed': '编译失败',
|
|
23
22
|
'stat.warn.appid': '当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303',
|
package/dist/mp/imports.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { PluginContext } from 'rollup';
|
|
2
1
|
import { type ImportSpecifier } from 'es-module-lexer';
|
|
2
|
+
import type { Rolldown } from 'vite';
|
|
3
|
+
type PluginContext = Rolldown.PluginContext;
|
|
3
4
|
/**
|
|
4
5
|
* 暂时没用
|
|
5
6
|
* @param source
|
|
@@ -10,3 +11,4 @@ import { type ImportSpecifier } from 'es-module-lexer';
|
|
|
10
11
|
export declare function findVueComponentImports(source: string, importer: string, resolve: PluginContext['resolve']): Promise<(ImportSpecifier & {
|
|
11
12
|
i: string;
|
|
12
13
|
})[]>;
|
|
14
|
+
export {};
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Rolldown } from 'vite';
|
|
2
2
|
import type { AttributeNode, DirectiveNode, ElementNode } from '@vue/compiler-core';
|
|
3
3
|
import type { MiniProgramComponentsType } from '../json/mp/types';
|
|
4
|
+
type EmittedAsset = Rolldown.EmittedAsset;
|
|
4
5
|
type LazyElementFn = (node: ElementNode, context: {
|
|
5
6
|
isMiniProgramComponent(name: string): MiniProgramComponentsType | undefined;
|
|
6
7
|
}) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ImportDeclaration, type Program } from '@babel/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Rolldown } from 'vite';
|
|
3
|
+
type PluginContext = Rolldown.PluginContext;
|
|
3
4
|
type BindingComponents = Record<string, {
|
|
4
5
|
tag: string;
|
|
5
6
|
type: 'unknown' | 'setup' | 'self';
|
package/dist/vite/cloud.js
CHANGED
|
@@ -131,16 +131,13 @@ function uniEncryptUniModulesPlugin() {
|
|
|
131
131
|
}
|
|
132
132
|
delete bundle[fileName];
|
|
133
133
|
const pkg = `uni_modules/${uniModuleId}/package.json`;
|
|
134
|
-
|
|
134
|
+
this.emitFile({
|
|
135
135
|
type: 'asset',
|
|
136
136
|
fileName: pkg,
|
|
137
|
-
name: pkg,
|
|
138
|
-
originalFileName: null,
|
|
139
|
-
needsCodeReference: false,
|
|
140
137
|
source: genUniModulesPackageJson(uniModuleId, process.env.UNI_INPUT_DIR, {
|
|
141
138
|
env: (0, uni_modules_cloud_1.initCheckEnv)(),
|
|
142
139
|
}),
|
|
143
|
-
};
|
|
140
|
+
});
|
|
144
141
|
}
|
|
145
142
|
else if (fileName.endsWith('.js')) {
|
|
146
143
|
if (isMp) {
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
import type { EmittedAsset } from 'rollup';
|
|
1
|
+
import type { Plugin, Rolldown } from 'vite';
|
|
3
2
|
import type { ParserOptions } from '@vue/compiler-core';
|
|
4
3
|
import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
|
|
5
4
|
import type { UniViteCopyPluginOptions } from './plugins/copy';
|
|
@@ -17,7 +16,7 @@ interface UniVitePluginUniOptions {
|
|
|
17
16
|
styleOptions?: Pick<SFCStyleCompileOptions, 'postcssPlugins'>;
|
|
18
17
|
compilerOptions?: {
|
|
19
18
|
miniProgram?: {
|
|
20
|
-
emitFile?: (emittedFile: EmittedAsset) => string;
|
|
19
|
+
emitFile?: (emittedFile: Rolldown.EmittedAsset) => string;
|
|
21
20
|
};
|
|
22
21
|
isNativeTag?: ParserOptions['isNativeTag'];
|
|
23
22
|
isVoidTag?: ParserOptions['isVoidTag'];
|
|
@@ -22,38 +22,42 @@ function uniConsolePlugin(options) {
|
|
|
22
22
|
resolvedConfig = config;
|
|
23
23
|
// 理论上发行模式就不应该有这个逻辑了,只不过为了尽量不引发兼容性问题,目前严谨一些判断是否配置了 drop_console
|
|
24
24
|
if (process.env.NODE_ENV !== 'development') {
|
|
25
|
-
const compressOptions = resolvedConfig.build.terserOptions
|
|
25
|
+
const compressOptions = resolvedConfig.build.terserOptions
|
|
26
|
+
?.compress;
|
|
26
27
|
if (compressOptions && typeof compressOptions === 'object') {
|
|
27
28
|
dropConsole = !!compressOptions.drop_console;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
|
-
transform
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
filename =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
32
|
+
transform: {
|
|
33
|
+
filter: { code: /console\.|__f__/ },
|
|
34
|
+
handler(code, id) {
|
|
35
|
+
if (dropConsole) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if ((0, filter_1.isRenderjs)(id) || (0, filter_1.isWxs)(id)) {
|
|
39
|
+
return {
|
|
40
|
+
code: (0, console_1.restoreConsoleExpr)(code),
|
|
41
|
+
map: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (!filter(id))
|
|
45
|
+
return null;
|
|
46
|
+
if (!(0, utils_1.isJsFile)(id))
|
|
47
|
+
return null;
|
|
48
|
+
let { filename } = (0, utils_1.parseVueRequest)(id);
|
|
49
|
+
if (options.filename) {
|
|
50
|
+
filename = options.filename(filename);
|
|
51
|
+
}
|
|
52
|
+
if (!filename) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (!code.includes('console.')) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
debugConsole(id);
|
|
59
|
+
return (0, console_1.rewriteConsoleExpr)(options.method, id, filename, code, (0, utils_2.withSourcemap)(resolvedConfig));
|
|
60
|
+
},
|
|
57
61
|
},
|
|
58
62
|
};
|
|
59
63
|
}
|
|
@@ -13,6 +13,7 @@ const utils_1 = require("../../utils");
|
|
|
13
13
|
const utils_2 = require("../../vue/utils");
|
|
14
14
|
const debugScoped = (0, debug_1.default)('uni:scoped');
|
|
15
15
|
const SCOPED_RE = /<style\s[^>]*scoped[^>]*>/i;
|
|
16
|
+
const VUE_SFC_ID_RE = /\.(?:vue|nvue|uvue)(?:$|\?(?!vue(?:&|=|$)))/;
|
|
16
17
|
function addScoped(code) {
|
|
17
18
|
return code.replace(/(<style\b[^><]*)>/gi, (str, $1) => {
|
|
18
19
|
if ($1.includes('scoped')) {
|
|
@@ -32,14 +33,18 @@ function uniRemoveCssScopedPlugin(_ = { filter: () => false }) {
|
|
|
32
33
|
return {
|
|
33
34
|
name: 'uni:css-remove-scoped',
|
|
34
35
|
enforce: 'pre',
|
|
35
|
-
transform
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
transform: {
|
|
37
|
+
// 仅 SFC 主模块需要移除 scoped,跳过 script/style/template 等子模块。
|
|
38
|
+
filter: { id: VUE_SFC_ID_RE },
|
|
39
|
+
handler(code, id) {
|
|
40
|
+
if (!(0, utils_2.isVueSfcFile)(id))
|
|
41
|
+
return null;
|
|
42
|
+
debugScoped(id);
|
|
43
|
+
return {
|
|
44
|
+
code: removeScoped(code),
|
|
45
|
+
map: null,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
43
48
|
},
|
|
44
49
|
};
|
|
45
50
|
}
|
|
@@ -49,14 +54,18 @@ function uniCssScopedPlugin({ filter } = { filter: () => false }) {
|
|
|
49
54
|
return {
|
|
50
55
|
name: 'uni:css-scoped',
|
|
51
56
|
enforce: 'pre',
|
|
52
|
-
transform
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
transform: {
|
|
58
|
+
// 仅 SFC 主模块需要补 scoped,跳过 script/style/template 等子模块。
|
|
59
|
+
filter: { id: VUE_SFC_ID_RE },
|
|
60
|
+
handler(code, id) {
|
|
61
|
+
if (!filter(id))
|
|
62
|
+
return null;
|
|
63
|
+
debugScoped(id);
|
|
64
|
+
return {
|
|
65
|
+
code: addScoped(code),
|
|
66
|
+
map: null,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
60
69
|
},
|
|
61
70
|
// 仅 h5
|
|
62
71
|
handleHotUpdate(ctx) {
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
|
|
2
|
+
interface DynamicImportPolyfillPlugin extends Plugin {
|
|
3
|
+
renderDynamicImport(): {
|
|
4
|
+
left: string;
|
|
5
|
+
right: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function dynamicImportPolyfill(promise?: boolean): DynamicImportPolyfillPlugin;
|
|
9
|
+
export {};
|
|
@@ -16,53 +16,56 @@ function uniEasycomPlugin(options) {
|
|
|
16
16
|
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
17
17
|
return {
|
|
18
18
|
name: 'uni:app-easycom',
|
|
19
|
-
transform
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? (0, shared_1.capitalize)((0, shared_1.camelize)(name))
|
|
41
|
-
: '')
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const utsCustomElement = (0, uts_1.getUTSCustomElement)(name);
|
|
45
|
-
if (utsCustomElement) {
|
|
46
|
-
(0, easycom_1.addImportDeclaration)(importDeclarations, '', utsCustomElement.source, '');
|
|
47
|
-
return `'${name}'`;
|
|
19
|
+
transform: {
|
|
20
|
+
filter: { id: /\.(vue|uvue)(\?|$)/, code: /_resolveComponent/ },
|
|
21
|
+
handler(code, id) {
|
|
22
|
+
if (!filter(id)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const { filename } = (0, url_1.parseVueRequest)(id);
|
|
26
|
+
if (!constants_1.EXTNAME_VUE_TEMPLATE.includes(path_1.default.extname(filename))) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!code.includes('_resolveComponent')) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let i = 0;
|
|
33
|
+
const importDeclarations = [];
|
|
34
|
+
code = code.replace(/_resolveComponent\("(.+?)"(, true)?\)/g, (str, name) => {
|
|
35
|
+
if (name && !name.startsWith('_')) {
|
|
36
|
+
const source = (0, easycom_1.matchEasycom)(name);
|
|
37
|
+
if (source) {
|
|
38
|
+
// 处理easycom组件优先级
|
|
39
|
+
return (0, easycom_1.genResolveEasycomCode)(importDeclarations, str, (0, easycom_1.addImportDeclaration)(importDeclarations, `__easycom_${i++}`, source, source.includes('uts-proxy')
|
|
40
|
+
? (0, shared_1.capitalize)((0, shared_1.camelize)(name)) + 'Component'
|
|
41
|
+
: source.includes('uni_helpers')
|
|
42
|
+
? (0, shared_1.capitalize)((0, shared_1.camelize)(name))
|
|
43
|
+
: ''));
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
else {
|
|
46
|
+
const utsCustomElement = (0, uts_1.getUTSCustomElement)(name);
|
|
47
|
+
if (utsCustomElement) {
|
|
48
|
+
(0, easycom_1.addImportDeclaration)(importDeclarations, '', utsCustomElement.source, '');
|
|
49
|
+
return `'${name}'`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
53
|
+
if ((0, uni_shared_1.isAppUVueBuiltInEasyComponent)(name)) {
|
|
54
|
+
// 内置easycom组件不传入self参数
|
|
55
|
+
return str.replace(', true)', ')');
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
}
|
|
59
|
+
return str;
|
|
60
|
+
});
|
|
61
|
+
if (importDeclarations.length) {
|
|
62
|
+
code = importDeclarations.join('') + code;
|
|
56
63
|
}
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
code,
|
|
64
|
-
map: null,
|
|
65
|
-
};
|
|
64
|
+
return {
|
|
65
|
+
code,
|
|
66
|
+
map: null,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
66
69
|
},
|
|
67
70
|
};
|
|
68
71
|
}
|