@dcloudio/vite-plugin-uni 3.0.0-5000720260410001 → 3.0.0-5010420260703001
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/cli/action.js +54 -10
- package/dist/cli/utils.js +14 -9
- package/dist/cli/uvue.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -10
- package/dist/plugins/copy.js +55 -14
- package/dist/vue/options.js +7 -30
- package/package.json +5 -5
package/dist/cli/action.js
CHANGED
|
@@ -48,8 +48,7 @@ async function runDev(options) {
|
|
|
48
48
|
options.minify = true;
|
|
49
49
|
}
|
|
50
50
|
(0, utils_1.initEnv)('dev', options);
|
|
51
|
-
if (
|
|
52
|
-
process.env.UNI_UTS_PLATFORM === 'app-android') {
|
|
51
|
+
if ((0, uni_cli_shared_1.isUniAppXAndroidNative)()) {
|
|
53
52
|
return (0, uvue_1.runUVueAndroidDev)(options);
|
|
54
53
|
}
|
|
55
54
|
const createLogger = await Promise.resolve().then(() => __importStar(require('vite'))).then(({ createLogger }) => createLogger);
|
|
@@ -101,18 +100,27 @@ async function runDev(options) {
|
|
|
101
100
|
}
|
|
102
101
|
const utsChanged = process.env.UNI_APP_UTS_CHANGED === 'true';
|
|
103
102
|
process.env.UNI_APP_UTS_CHANGED = '';
|
|
103
|
+
let changedFiles = '';
|
|
104
|
+
let hasBinFiles = false;
|
|
104
105
|
if (options.platform === 'app') {
|
|
105
106
|
const files = process.env.UNI_APP_CHANGED_FILES;
|
|
106
107
|
const pages = process.env.UNI_APP_CHANGED_PAGES;
|
|
107
108
|
const dex = process.env.UNI_APP_UTS_CHANGED_FILES;
|
|
108
|
-
|
|
109
|
+
hasBinFiles = getHasBinFiles();
|
|
110
|
+
changedFiles = pages || files;
|
|
109
111
|
process.env.UNI_APP_CHANGED_PAGES = '';
|
|
110
112
|
process.env.UNI_APP_CHANGED_FILES = '';
|
|
111
113
|
process.env.UNI_APP_UTS_CHANGED_FILES = '';
|
|
112
|
-
if (
|
|
114
|
+
if (process.env.UNI_APP_X_DOM2_DYNAMIC === 'true') {
|
|
115
|
+
process.env.UNI_APP_X_DOM2_BIN_CHANGED_FILES = '';
|
|
116
|
+
}
|
|
117
|
+
const hasIncrementalFiles = changedFiles &&
|
|
113
118
|
!changedFiles.includes(uni_cli_shared_1.APP_CONFIG_SERVICE) &&
|
|
114
|
-
!changedFiles.includes(uni_cli_shared_1.APP_SERVICE_FILENAME)
|
|
115
|
-
|
|
119
|
+
!changedFiles.includes(uni_cli_shared_1.APP_SERVICE_FILENAME);
|
|
120
|
+
if (
|
|
121
|
+
// 目前动态渲染下,只要bin有变更,就需要全量同步,后续可以优化成bin变更时输出bin变更文件列表
|
|
122
|
+
!hasBinFiles &&
|
|
123
|
+
(hasIncrementalFiles || dex)) {
|
|
116
124
|
if (pages) {
|
|
117
125
|
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end.pages'].replace('{pages}', changedFiles));
|
|
118
126
|
}
|
|
@@ -121,10 +129,38 @@ async function runDev(options) {
|
|
|
121
129
|
}
|
|
122
130
|
else if (options.platform === 'app-harmony' ||
|
|
123
131
|
options.platform === 'mp-harmony') {
|
|
132
|
+
hasBinFiles = getHasBinFiles();
|
|
133
|
+
// 动态化且没有uts插件变更时,输出变更文件列表
|
|
134
|
+
if (process.env.UNI_APP_X_DOM2_DYNAMIC === 'true' &&
|
|
135
|
+
!utsChanged &&
|
|
136
|
+
!hasBinFiles) {
|
|
137
|
+
const changed = [];
|
|
138
|
+
const files = process.env.UNI_APP_CHANGED_FILES;
|
|
139
|
+
process.env.UNI_APP_CHANGED_PAGES = '';
|
|
140
|
+
if (files) {
|
|
141
|
+
try {
|
|
142
|
+
changed.push(...JSON.parse(files));
|
|
143
|
+
}
|
|
144
|
+
catch { }
|
|
145
|
+
}
|
|
146
|
+
// 鸿蒙平台暂不启用 bin 文件热更新,先不合并到 changes 中。
|
|
147
|
+
// const binFiles = process.env.UNI_APP_X_DOM2_BIN_CHANGED_FILES
|
|
148
|
+
process.env.UNI_APP_X_DOM2_BIN_CHANGED_FILES = '';
|
|
149
|
+
// if (binFiles) {
|
|
150
|
+
// try {
|
|
151
|
+
// changed.push(...JSON.parse(binFiles))
|
|
152
|
+
// } catch {}
|
|
153
|
+
// }
|
|
154
|
+
if (changed.length) {
|
|
155
|
+
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end.files'].replace('{files}', JSON.stringify(changed)));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
124
158
|
// 鸿蒙平台cpp/uts插件变更需要整体编译
|
|
125
159
|
if (process.env.UNI_APP_X_DOM2_CPP_CHANGED !== 'true' &&
|
|
126
|
-
!utsChanged
|
|
160
|
+
!utsChanged &&
|
|
161
|
+
!hasBinFiles) {
|
|
127
162
|
const files = process.env.UNI_APP_CHANGED_FILES;
|
|
163
|
+
process.env.UNI_APP_CHANGED_FILES = '';
|
|
128
164
|
if (files) {
|
|
129
165
|
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end.files'].replace('{files}', files));
|
|
130
166
|
}
|
|
@@ -138,7 +174,10 @@ async function runDev(options) {
|
|
|
138
174
|
utsChanged) {
|
|
139
175
|
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
|
|
140
176
|
}
|
|
141
|
-
|
|
177
|
+
// 没有cpp/uts插件变更,且没有增量js/bin文件变更,就输出无变更
|
|
178
|
+
if (!changedFiles && !hasBinFiles) {
|
|
179
|
+
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['uvue.dev.watching.end.empty']);
|
|
180
|
+
}
|
|
142
181
|
}
|
|
143
182
|
return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
|
|
144
183
|
}
|
|
@@ -174,8 +213,7 @@ async function runDev(options) {
|
|
|
174
213
|
exports.runDev = runDev;
|
|
175
214
|
async function runBuild(options) {
|
|
176
215
|
(0, utils_1.initEnv)('build', options);
|
|
177
|
-
if (
|
|
178
|
-
process.env.UNI_UTS_PLATFORM === 'app-android') {
|
|
216
|
+
if ((0, uni_cli_shared_1.isUniAppXAndroidNative)()) {
|
|
179
217
|
return (0, uvue_1.runUVueAndroidBuild)(options);
|
|
180
218
|
}
|
|
181
219
|
try {
|
|
@@ -230,3 +268,9 @@ const stopProfiler = (log) => {
|
|
|
230
268
|
});
|
|
231
269
|
};
|
|
232
270
|
exports.stopProfiler = stopProfiler;
|
|
271
|
+
function getHasBinFiles() {
|
|
272
|
+
const binFiles = process.env.UNI_APP_X_DOM2_DYNAMIC === 'true'
|
|
273
|
+
? process.env.UNI_APP_X_DOM2_BIN_CHANGED_FILES
|
|
274
|
+
: '';
|
|
275
|
+
return !!(binFiles && binFiles !== '[]');
|
|
276
|
+
}
|
package/dist/cli/utils.js
CHANGED
|
@@ -176,7 +176,7 @@ function initEnv(type, options) {
|
|
|
176
176
|
manifestJson['app-plus']?.['utsCompilerVersion'] === 'v1') {
|
|
177
177
|
process.env.UNI_APP_X_TSC = 'false';
|
|
178
178
|
}
|
|
179
|
-
if (manifestJson['uni-app-x']?.['styleIsolationVersion']
|
|
179
|
+
if (manifestJson['uni-app-x']?.['styleIsolationVersion'] == 2) {
|
|
180
180
|
process.env.UNI_APP_STYLE_ISOLATION_VERSION = '2';
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -226,14 +226,19 @@ function initEnv(type, options) {
|
|
|
226
226
|
? 'true'
|
|
227
227
|
: 'false';
|
|
228
228
|
(0, uni_cli_shared_1.initPreContext)(process.env.UNI_PLATFORM, process.env.UNI_CUSTOM_CONTEXT, process.env.UNI_UTS_PLATFORM, process.env.UNI_APP_X === 'true');
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
process.env.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
229
|
+
const isX = (0, uni_cli_shared_1.isUniAppX)();
|
|
230
|
+
console.log(uni_cli_shared_1.M['app.compiler.version'].replace('{version}', process.env.UNI_COMPILER_VERSION +
|
|
231
|
+
`(${isX ? 'uni-app x' : 'vue3'})` +
|
|
232
|
+
(process.env.UNI_APP_X_DOM2 === 'true' ? '蒸汽模式' : '')));
|
|
233
|
+
if ((0, uni_cli_shared_1.isUniAppXVapor)() &&
|
|
234
|
+
(process.env.UNI_PLATFORM === 'app' ||
|
|
235
|
+
process.env.UNI_PLATFORM === 'app-harmony')) {
|
|
236
|
+
console.log(uni_cli_shared_1.M['view.render.compiler.target'].replace('{target}', process.env.UNI_APP_X_DOM2_DYNAMIC === 'true'
|
|
237
|
+
? uni_cli_shared_1.M['view.render.compiler.target.bytecode']
|
|
238
|
+
: uni_cli_shared_1.M['view.render.compiler.target.nativecode']));
|
|
239
|
+
}
|
|
240
|
+
if (isX && !(0, uni_cli_shared_1.isUniAppXVapor)()) {
|
|
241
|
+
console.log(uni_cli_shared_1.M['style.isolation.version'].replace('{version}', (process.env.UNI_APP_STYLE_ISOLATION_VERSION || '1') + '.0'));
|
|
237
242
|
}
|
|
238
243
|
console.log(uni_cli_shared_1.M['compiling']);
|
|
239
244
|
}
|
package/dist/cli/uvue.js
CHANGED
|
@@ -26,8 +26,8 @@ function initUVueEnv() {
|
|
|
26
26
|
}
|
|
27
27
|
if (process.env.UNI_PLATFORM === 'app') {
|
|
28
28
|
process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE = 'native';
|
|
29
|
-
//
|
|
30
|
-
if (
|
|
29
|
+
// App X iOS 与 Android Vapor 统一使用 JS 引擎
|
|
30
|
+
if ((0, uni_cli_shared_1.isUniAppXIOS)() || (0, uni_cli_shared_1.isUniAppXAndroidVapor)()) {
|
|
31
31
|
process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE = 'js';
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,3 +25,4 @@ export interface VitePluginUniResolvedOptions extends VitePluginUniOptions {
|
|
|
25
25
|
}
|
|
26
26
|
export { runDev, runBuild } from './cli/action';
|
|
27
27
|
export default function uniPlugin(rawOptions?: VitePluginUniOptions): Plugin[];
|
|
28
|
+
export declare function shouldMoveSourceMapFromCache(): boolean | "";
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runBuild = exports.runDev = void 0;
|
|
6
|
+
exports.shouldMoveSourceMapFromCache = exports.runBuild = exports.runDev = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const vite_1 = __importDefault(require("unplugin-auto-import/vite"));
|
|
9
9
|
const plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
|
|
@@ -41,13 +41,11 @@ function uniPlugin(rawOptions = {}) {
|
|
|
41
41
|
};
|
|
42
42
|
options.platform = process.env.UNI_PLATFORM || 'h5';
|
|
43
43
|
options.inputDir = process.env.UNI_INPUT_DIR;
|
|
44
|
-
const plugins =
|
|
45
|
-
process.env.UNI_UTS_PLATFORM === 'app-android'
|
|
44
|
+
const plugins = (0, uni_cli_shared_1.isUniAppXAndroidNative)()
|
|
46
45
|
? createUVueAndroidPlugins(options)
|
|
47
46
|
: createPlugins(options);
|
|
48
47
|
// x 提供 auto import(非android、android自行处理)
|
|
49
|
-
if (process.env.UNI_APP_X === 'true' &&
|
|
50
|
-
process.env.UNI_UTS_PLATFORM !== 'app-android') {
|
|
48
|
+
if (process.env.UNI_APP_X === 'true' && !(0, uni_cli_shared_1.isUniAppXAndroidNative)()) {
|
|
51
49
|
plugins.unshift((0, vite_1.default)((0, uni_cli_shared_1.initAutoImportOptions)(process.env.UNI_UTS_PLATFORM, options.autoImportOptions || {})));
|
|
52
50
|
}
|
|
53
51
|
plugins.unshift((0, uni_cli_shared_1.uniJsonPlugin)());
|
|
@@ -63,7 +61,9 @@ function createPlugins(options) {
|
|
|
63
61
|
// iOS 暂不使用该机制
|
|
64
62
|
process.env.UNI_UTS_PLATFORM !== 'app-ios' &&
|
|
65
63
|
// harmony 同 iOS
|
|
66
|
-
process.env.UNI_UTS_PLATFORM !== 'app-harmony'
|
|
64
|
+
process.env.UNI_UTS_PLATFORM !== 'app-harmony' &&
|
|
65
|
+
// Android Vapor 暂不使用该机制(只有 Android Native 会进入该方法,不需要额外判断)
|
|
66
|
+
process.env.UNI_UTS_PLATFORM !== 'app-android') {
|
|
67
67
|
plugins.push((0, uni_cli_shared_1.uniUTSExtApiReplace)());
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
@@ -135,10 +135,7 @@ function createPlugins(options) {
|
|
|
135
135
|
if (fs_1.default.existsSync(sourceMapPath)) {
|
|
136
136
|
(0, uni_cli_shared_1.emptyDir)(sourceMapPath);
|
|
137
137
|
}
|
|
138
|
-
if (
|
|
139
|
-
process.env.UNI_UTS_PLATFORM === 'app-ios' &&
|
|
140
|
-
process.env.UNI_APP_X_CACHE_DIR &&
|
|
141
|
-
process.env.NODE_ENV !== 'development') {
|
|
138
|
+
if (shouldMoveSourceMapFromCache()) {
|
|
142
139
|
plugins.push((0, move_1.uniMovePlugin)({
|
|
143
140
|
apply: 'build',
|
|
144
141
|
enforce: 'post',
|
|
@@ -190,3 +187,10 @@ function createUVueAndroidPlugins(options) {
|
|
|
190
187
|
function resolveSourceMapDirByCacheDir() {
|
|
191
188
|
return path_1.default.resolve(process.env.UNI_APP_X_CACHE_DIR, 'sourcemap');
|
|
192
189
|
}
|
|
190
|
+
function shouldMoveSourceMapFromCache() {
|
|
191
|
+
return (process.env.UNI_APP_X === 'true' &&
|
|
192
|
+
process.env.UNI_APP_X_CACHE_DIR &&
|
|
193
|
+
process.env.NODE_ENV !== 'development' &&
|
|
194
|
+
((0, uni_cli_shared_1.isUniAppXIOS)() || (0, uni_cli_shared_1.isUniAppXAndroidJsEngine)()));
|
|
195
|
+
}
|
|
196
|
+
exports.shouldMoveSourceMapFromCache = shouldMoveSourceMapFromCache;
|
package/dist/plugins/copy.js
CHANGED
|
@@ -12,9 +12,8 @@ const debugCopy = (0, debug_1.default)('uni:copy');
|
|
|
12
12
|
function uniCopyPlugin({ outputDir, copyOptions, }) {
|
|
13
13
|
const staticDir = uni_cli_shared_1.PUBLIC_DIR + '/**/*';
|
|
14
14
|
const uniModulesStaticDir = 'uni_modules/*/' + uni_cli_shared_1.PUBLIC_DIR + '/**/*';
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const uniModulesCppDir = isDom2Harmony ? 'uni_modules/*/cppsdk/**/*' : '';
|
|
15
|
+
const isDom2 = process.env.UNI_APP_X_DOM2 === 'true';
|
|
16
|
+
const uniModulesCppDir = isDom2 ? 'uni_modules/*/cppsdk/**/*' : '';
|
|
18
17
|
const assets = [staticDir, uniModulesStaticDir];
|
|
19
18
|
const cppAssets = [];
|
|
20
19
|
if (uniModulesCppDir) {
|
|
@@ -32,10 +31,17 @@ function uniCopyPlugin({ outputDir, copyOptions, }) {
|
|
|
32
31
|
assets.push(asset);
|
|
33
32
|
});
|
|
34
33
|
const inputDir = (0, uni_cli_shared_1.normalizePath)(process.env.UNI_INPUT_DIR);
|
|
34
|
+
const normalizedInputDir = normalizePathForCompare(inputDir);
|
|
35
35
|
const platform = process.env.UNI_PLATFORM;
|
|
36
36
|
const utsPlatform = process.env.UNI_UTS_PLATFORM;
|
|
37
37
|
// 非当前平台 static 目录
|
|
38
38
|
const ignorePlatformStaticDirs = createIgnorePlatformDirs(uni_cli_shared_1.PUBLIC_DIR, platform, utsPlatform);
|
|
39
|
+
// app 资源包导出时,如果 uni_modules 的 utssdk 不支持当前原生平台,则连同 static 一起忽略
|
|
40
|
+
const ignoreUniModulesStaticDirs = createIgnoreUniModulesStaticDirs(inputDir, subpackages, utsPlatform);
|
|
41
|
+
const ignoreStaticDirs = [
|
|
42
|
+
...ignorePlatformStaticDirs,
|
|
43
|
+
...ignoreUniModulesStaticDirs,
|
|
44
|
+
];
|
|
39
45
|
// 非当前平台 cppsdk 目录
|
|
40
46
|
const ignorePlatformCppDirs = uniModulesCppDir
|
|
41
47
|
? createIgnorePlatformDirs('cppsdk', platform, utsPlatform)
|
|
@@ -48,15 +54,17 @@ function uniCopyPlugin({ outputDir, copyOptions, }) {
|
|
|
48
54
|
readyTimeout: getReadyTimeout(),
|
|
49
55
|
ignored(path) {
|
|
50
56
|
const normalizedPath = (0, uni_cli_shared_1.normalizePath)(path);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const comparablePath = normalizePathForCompare(normalizedPath);
|
|
58
|
+
if (ignoreUniModulesStaticDirs.find((dir) =>
|
|
59
|
+
// 忽略整个 static 目录及其子文件,避免无效资源进入资源包
|
|
60
|
+
(comparablePath + '/').includes(dir))) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (ignorePlatformStaticDirs.find((dir) => (comparablePath + '/').includes(dir))) {
|
|
54
64
|
return fs_1.default.statSync(normalizedPath).isDirectory();
|
|
55
65
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// 目前仅简单处理static
|
|
59
|
-
if (normalizedPath.includes('/static/')) {
|
|
66
|
+
if (!comparablePath.startsWith(normalizedInputDir)) {
|
|
67
|
+
if (comparablePath.includes('/static/')) {
|
|
60
68
|
return false;
|
|
61
69
|
}
|
|
62
70
|
return true;
|
|
@@ -67,10 +75,10 @@ function uniCopyPlugin({ outputDir, copyOptions, }) {
|
|
|
67
75
|
},
|
|
68
76
|
];
|
|
69
77
|
targets.push(...copyOptions.targets);
|
|
70
|
-
if (process.env.
|
|
78
|
+
if (process.env.UNI_APP_X_DOM2_CPP_DIR && cppAssets.length) {
|
|
71
79
|
targets.push({
|
|
72
80
|
src: cppAssets,
|
|
73
|
-
dest: process.env.
|
|
81
|
+
dest: process.env.UNI_APP_X_DOM2_CPP_DIR,
|
|
74
82
|
watchOptions: {
|
|
75
83
|
readyTimeout: getReadyTimeout(),
|
|
76
84
|
ignored(path) {
|
|
@@ -86,7 +94,7 @@ function uniCopyPlugin({ outputDir, copyOptions, }) {
|
|
|
86
94
|
});
|
|
87
95
|
}
|
|
88
96
|
debugCopy(targets);
|
|
89
|
-
checkIgnoreStatic(
|
|
97
|
+
checkIgnoreStatic(ignoreStaticDirs.map((dir) => dir.substring(1).split('/')));
|
|
90
98
|
return (0, uni_cli_shared_1.uniViteCopyPlugin)({
|
|
91
99
|
targets,
|
|
92
100
|
});
|
|
@@ -143,5 +151,38 @@ function createIgnorePlatformDirs(dir, platform, utsPlatform) {
|
|
|
143
151
|
return p !== platform;
|
|
144
152
|
})
|
|
145
153
|
// 在最后增加 / 是为了避免误判以 platform 开头的目录,比如 app-test
|
|
146
|
-
.map((p) => '/' + dir + '/' + p + '/'));
|
|
154
|
+
.map((p) => normalizePathForCompare('/' + dir + '/' + p + '/')));
|
|
155
|
+
}
|
|
156
|
+
function createIgnoreUniModulesStaticDirs(inputDir, subpackages, utsPlatform) {
|
|
157
|
+
if (utsPlatform !== 'app-android' && utsPlatform !== 'app-ios') {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
const ignoreDirs = [];
|
|
161
|
+
const roots = [
|
|
162
|
+
inputDir,
|
|
163
|
+
...subpackages.map((root) => path_1.default.resolve(inputDir, root)),
|
|
164
|
+
];
|
|
165
|
+
roots.forEach((rootDir) => {
|
|
166
|
+
const uniModulesDir = path_1.default.resolve(rootDir, 'uni_modules');
|
|
167
|
+
if (!fs_1.default.existsSync(uniModulesDir)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
fs_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
|
|
171
|
+
const uniModuleRootDir = path_1.default.resolve(uniModulesDir, uniModuleDir);
|
|
172
|
+
const utssdkDir = path_1.default.resolve(uniModuleRootDir, 'utssdk');
|
|
173
|
+
const staticDir = path_1.default.resolve(uniModuleRootDir, uni_cli_shared_1.PUBLIC_DIR);
|
|
174
|
+
if (!fs_1.default.existsSync(utssdkDir) || !fs_1.default.existsSync(staticDir)) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if ((0, uni_cli_shared_1.hasUTSModulePlatformFile)(uniModuleRootDir, utsPlatform)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
ignoreDirs.push(normalizePathForCompare('/' + (0, uni_cli_shared_1.normalizePath)(path_1.default.relative(inputDir, staticDir)) + '/'));
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
return ignoreDirs;
|
|
184
|
+
}
|
|
185
|
+
function normalizePathForCompare(id) {
|
|
186
|
+
const normalizedPath = (0, uni_cli_shared_1.normalizePath)(id);
|
|
187
|
+
return uni_cli_shared_1.isWindows ? normalizedPath.toLowerCase() : normalizedPath;
|
|
147
188
|
}
|
package/dist/vue/options.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.initPluginViteLegacyOptions = exports.initPluginVueJsxOptions = exports.initPluginVueOptions = exports.createPluginVueInstance = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
8
|
const shared_1 = require("@vue/shared");
|
|
10
9
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
@@ -53,10 +52,9 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
|
|
|
53
52
|
}
|
|
54
53
|
const templateOptions = vueOptions.template || (vueOptions.template = {});
|
|
55
54
|
const compilerOptions = templateOptions.compilerOptions || (templateOptions.compilerOptions = {});
|
|
56
|
-
const
|
|
57
|
-
process.env.UNI_PLATFORM === 'app-harmony';
|
|
55
|
+
const isDom2 = process.env.UNI_APP_X_DOM2 === 'true';
|
|
58
56
|
compilerOptions.isX = process.env.UNI_APP_X === 'true';
|
|
59
|
-
compilerOptions.dom2 =
|
|
57
|
+
compilerOptions.dom2 = isDom2;
|
|
60
58
|
// 默认就移除comments节点
|
|
61
59
|
compilerOptions.comments = false;
|
|
62
60
|
const { compiler, styleOptions: { postcssPlugins }, compilerOptions: { miniProgram, isNativeTag, isVoidTag, isCustomElement, nodeTransforms, directiveTransforms, whitespace, }, } = uniPluginOptions;
|
|
@@ -145,7 +143,7 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
|
|
|
145
143
|
};
|
|
146
144
|
}
|
|
147
145
|
if (options.platform !== 'h5' && options.platform !== 'web') {
|
|
148
|
-
compilerOptions.nodeTransforms.push(...(0, uni_cli_shared_1.getBaseNodeTransforms)(options.base,
|
|
146
|
+
compilerOptions.nodeTransforms.push(...(0, uni_cli_shared_1.getBaseNodeTransforms)(options.base, isDom2 ? (0, uni_cli_shared_1.createResolveStaticAsset)(options.inputDir) : undefined));
|
|
149
147
|
}
|
|
150
148
|
if (nodeTransforms) {
|
|
151
149
|
compilerOptions.nodeTransforms.push(...nodeTransforms);
|
|
@@ -216,7 +214,7 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
|
|
|
216
214
|
if (!vueOptions.script.babelParserPlugins.includes('decorators')) {
|
|
217
215
|
vueOptions.script.babelParserPlugins.push('decorators');
|
|
218
216
|
}
|
|
219
|
-
if (
|
|
217
|
+
if (isDom2) {
|
|
220
218
|
const appVue = (0, uni_cli_shared_1.resolveAppVue)(process.env.UNI_INPUT_DIR);
|
|
221
219
|
function isAppVue(id) {
|
|
222
220
|
return (0, uni_cli_shared_1.normalizePath)(id) === appVue;
|
|
@@ -231,6 +229,8 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
|
|
|
231
229
|
vueOptions.script.extraOptions = (descriptor) => {
|
|
232
230
|
return {
|
|
233
231
|
isWatch: process.env.NODE_ENV === 'development',
|
|
232
|
+
// TODO 目前使用全局开关,后续可能是页面级别的开关?
|
|
233
|
+
dynamicSharedData: process.env.UNI_APP_X_DOM2_DYNAMIC === 'true',
|
|
234
234
|
helper: (0, uni_cli_shared_1.requireUniHelpers)(),
|
|
235
235
|
componentType: (0, uni_cli_shared_1.isUniPageFile)(descriptor.filename)
|
|
236
236
|
? 'page'
|
|
@@ -239,31 +239,8 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
|
|
|
239
239
|
: 'component',
|
|
240
240
|
};
|
|
241
241
|
};
|
|
242
|
-
let disableStaticStyle = false;
|
|
243
|
-
if (isDevX && process.env.NODE_ENV === 'development') {
|
|
244
|
-
if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
|
|
245
|
-
// 开发版本、开发模式下,非鸿蒙release模式打包
|
|
246
|
-
disableStaticStyle =
|
|
247
|
-
process.env.UNI_APP_HARMONY_RUN_MODE !== 'release';
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
;
|
|
251
242
|
vueOptions.template.compilerOptions.extraOptions = (descriptor) => {
|
|
252
|
-
|
|
253
|
-
const relativeFilename = (0, uni_cli_shared_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename));
|
|
254
|
-
return {
|
|
255
|
-
root: (0, uni_cli_shared_1.normalizePath)(process.env.UNI_INPUT_DIR),
|
|
256
|
-
platform: process.env.UNI_UTS_PLATFORM,
|
|
257
|
-
componentType: (0, uni_cli_shared_1.isUniPageFile)(filename) ? 'page' : 'component',
|
|
258
|
-
relativeFilename,
|
|
259
|
-
helper: (0, uni_cli_shared_1.requireUniHelpers)(),
|
|
260
|
-
scriptCppBlocks: descriptor.scriptCppBlocks,
|
|
261
|
-
genVueId: !!process.env.UNI_AUTOMATOR_WS_ENDPOINT,
|
|
262
|
-
disableStaticStyle,
|
|
263
|
-
onVueTemplateCompileLog(type, error) {
|
|
264
|
-
return (0, uni_cli_shared_1.onVueTemplateCompileLog)(type, error, descriptor.source, relativeFilename);
|
|
265
|
-
},
|
|
266
|
-
};
|
|
243
|
+
return (0, uni_cli_shared_1.initVueTemplateCompilerExtraOptions)(descriptor);
|
|
267
244
|
};
|
|
268
245
|
}
|
|
269
246
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/vite-plugin-uni",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-5010420260703001",
|
|
4
4
|
"description": "uni-app vite plugin",
|
|
5
5
|
"bin": {
|
|
6
6
|
"uni": "bin/uni.js"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"picocolors": "1.1.0",
|
|
45
45
|
"terser": "^5.4.0",
|
|
46
46
|
"unplugin-auto-import": "19.1.0",
|
|
47
|
-
"@dcloudio/uni-
|
|
48
|
-
"@dcloudio/uni-shared": "3.0.0-
|
|
49
|
-
"@dcloudio/uni-
|
|
47
|
+
"@dcloudio/uni-nvue-styler": "3.0.0-5010420260703001",
|
|
48
|
+
"@dcloudio/uni-cli-shared": "3.0.0-5010420260703001",
|
|
49
|
+
"@dcloudio/uni-shared": "3.0.0-5010420260703001"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/debug": "4.1.12",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"vite": "5.2.8"
|
|
64
64
|
},
|
|
65
65
|
"uni-app": {
|
|
66
|
-
"compilerVersion": "5.
|
|
66
|
+
"compilerVersion": "5.14"
|
|
67
67
|
},
|
|
68
68
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
69
69
|
"scripts": {
|