@dcloudio/uni-cli-shared 3.0.0-alpha-4070720250804001 → 3.0.0-alpha-4070620250731002
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/easycom.d.ts +0 -1
- package/dist/easycom.js +13 -17
- package/dist/hbx/alias.js +10 -43
- package/dist/hbx/index.js +0 -10
- package/dist/hbx/log.js +1 -23
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +1 -2
- package/dist/json/manifest.d.ts +0 -1
- package/dist/json/manifest.js +1 -11
- package/dist/json/mp/jsonFile.js +2 -4
- package/dist/json/mp/pages.js +0 -1
- package/dist/json/mp/types.d.ts +1 -4
- package/dist/json/uni-x/manifest.d.ts +0 -1
- package/dist/json/uni-x/manifest.js +1 -5
- package/dist/messages/zh_CN.js +0 -1
- package/dist/uni_modules.cloud.d.ts +4 -10
- package/dist/uni_modules.cloud.js +19 -58
- package/dist/uni_modules.d.ts +0 -2
- package/dist/uni_modules.js +2 -81
- package/dist/uts.js +0 -16
- package/dist/vite/autoImport.js +0 -2
- package/dist/vite/cloud.js +5 -51
- package/dist/vite/plugins/index.d.ts +0 -1
- package/dist/vite/plugins/index.js +1 -3
- package/dist/vite/plugins/inject.js +1 -3
- package/dist/vite/plugins/uts/uni_modules.d.ts +0 -1
- package/dist/vite/plugins/uts/uni_modules.js +14 -63
- package/dist/vite/plugins/uts/uvue.js +3 -17
- package/dist/vite/plugins/vitejs/plugins/css.js +5 -40
- package/dist/vue/transforms/transformUTSComponent.js +3 -8
- package/package.json +38 -38
- package/dist/vite/plugins/stats.d.ts +0 -2
- package/dist/vite/plugins/stats.js +0 -42
- package/dist/workers.d.ts +0 -14
- package/dist/workers.js +0 -187
- package/lib/vapor/@vitejs/plugin-vue/LICENSE +0 -21
- package/lib/vapor/@vitejs/plugin-vue/README.md +0 -278
- package/lib/vapor/@vitejs/plugin-vue/dist/index.cjs +0 -3105
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.cts +0 -113
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.mts +0 -111
- package/lib/vapor/@vitejs/plugin-vue/dist/index.d.ts +0 -113
- package/lib/vapor/@vitejs/plugin-vue/dist/index.mjs +0 -3090
- package/lib/vapor/@vitejs/plugin-vue/package.json +0 -50
- package/lib/vapor/@vue/compiler-core/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-core/README.md +0 -1
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +0 -6902
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +0 -6779
- package/lib/vapor/@vue/compiler-core/dist/compiler-core.esm-bundler.js +0 -5870
- package/lib/vapor/@vue/compiler-core/index.js +0 -7
- package/lib/vapor/@vue/compiler-core/package.json +0 -58
- package/lib/vapor/@vue/compiler-dom/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-dom/README.md +0 -1
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -936
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +0 -856
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +0 -6682
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +0 -14
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +0 -693
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.js +0 -6855
- package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.prod.js +0 -14
- package/lib/vapor/@vue/compiler-dom/index.js +0 -7
- package/lib/vapor/@vue/compiler-dom/package.json +0 -57
- package/lib/vapor/@vue/compiler-sfc/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-sfc/README.md +0 -80
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -21682
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +0 -66272
- package/lib/vapor/@vue/compiler-sfc/package.json +0 -68
- package/lib/vapor/@vue/compiler-ssr/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-ssr/README.md +0 -1
- package/lib/vapor/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +0 -1402
- package/lib/vapor/@vue/compiler-ssr/package.json +0 -34
- package/lib/vapor/@vue/compiler-vapor/LICENSE +0 -21
- package/lib/vapor/@vue/compiler-vapor/README.md +0 -1
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +0 -4540
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +0 -37020
- package/lib/vapor/@vue/compiler-vapor/package.json +0 -49
- package/lib/vapor/@vue/reactivity/LICENSE +0 -21
- package/lib/vapor/@vue/reactivity/README.md +0 -19
- package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.js +0 -2033
- package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.prod.js +0 -1841
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.js +0 -2023
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.prod.js +0 -5
- package/lib/vapor/@vue/reactivity/dist/reactivity.esm-bundler.js +0 -1992
- package/lib/vapor/@vue/reactivity/dist/reactivity.global.js +0 -2082
- package/lib/vapor/@vue/reactivity/dist/reactivity.global.prod.js +0 -5
- package/lib/vapor/@vue/reactivity/index.js +0 -7
- package/lib/vapor/@vue/reactivity/package.json +0 -55
- package/lib/vapor/@vue/runtime-core/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-core/README.md +0 -28
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.js +0 -8972
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.prod.js +0 -7088
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8913
- package/lib/vapor/@vue/runtime-core/index.js +0 -7
- package/lib/vapor/@vue/runtime-core/package.json +0 -54
- package/lib/vapor/@vue/runtime-dom/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-dom/README.md +0 -13
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.js +0 -1797
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +0 -1646
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +0 -12929
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +0 -6
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1838
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.js +0 -13086
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.prod.js +0 -6
- package/lib/vapor/@vue/runtime-dom/index.js +0 -7
- package/lib/vapor/@vue/runtime-dom/package.json +0 -60
- package/lib/vapor/@vue/runtime-vapor/LICENSE +0 -21
- package/lib/vapor/@vue/runtime-vapor/README.md +0 -8
- package/lib/vapor/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js +0 -3242
- package/lib/vapor/@vue/runtime-vapor/package.json +0 -47
- package/lib/vapor/@vue/server-renderer/LICENSE +0 -21
- package/lib/vapor/@vue/server-renderer/README.md +0 -178
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.js +0 -1144
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.prod.js +0 -871
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.js +0 -8756
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +0 -5
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-bundler.js +0 -1366
- package/lib/vapor/@vue/server-renderer/index.js +0 -7
- package/lib/vapor/@vue/server-renderer/package.json +0 -55
- package/lib/vapor/@vue/shared/LICENSE +0 -21
- package/lib/vapor/@vue/shared/README.md +0 -3
- package/lib/vapor/@vue/shared/dist/shared.cjs.js +0 -698
- package/lib/vapor/@vue/shared/dist/shared.cjs.prod.js +0 -690
- package/lib/vapor/@vue/shared/dist/shared.esm-bundler.js +0 -616
- package/lib/vapor/@vue/shared/index.js +0 -7
- package/lib/vapor/@vue/shared/package.json +0 -47
- package/lib/vapor/@vue/vue/LICENSE +0 -21
- package/lib/vapor/@vue/vue/README.md +0 -62
- package/lib/vapor/@vue/vue/compiler-sfc/index.browser.js +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.browser.mjs +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.d.mts +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.d.ts +0 -1
- package/lib/vapor/@vue/vue/compiler-sfc/index.js +0 -3
- package/lib/vapor/@vue/vue/compiler-sfc/index.mjs +0 -3
- package/lib/vapor/@vue/vue/compiler-sfc/package.json +0 -4
- package/lib/vapor/@vue/vue/compiler-sfc/register-ts.js +0 -3
- package/lib/vapor/@vue/vue/dist/vue.cjs.js +0 -80
- package/lib/vapor/@vue/vue/dist/vue.cjs.prod.js +0 -66
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.js +0 -18840
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.prod.js +0 -12
- package/lib/vapor/@vue/vue/dist/vue.esm-bundler.js +0 -72
- package/lib/vapor/@vue/vue/dist/vue.global.js +0 -18820
- package/lib/vapor/@vue/vue/dist/vue.global.prod.js +0 -12
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.js +0 -15648
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.prod.js +0 -9
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.js +0 -12953
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.prod.js +0 -6
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-bundler.js +0 -29
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.js +0 -13111
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.prod.js +0 -6
- package/lib/vapor/@vue/vue/index.js +0 -7
- package/lib/vapor/@vue/vue/index.mjs +0 -1
- package/lib/vapor/@vue/vue/jsx-runtime/index.d.ts +0 -25
- package/lib/vapor/@vue/vue/jsx-runtime/index.js +0 -15
- package/lib/vapor/@vue/vue/jsx-runtime/index.mjs +0 -12
- package/lib/vapor/@vue/vue/jsx-runtime/package.json +0 -5
- package/lib/vapor/@vue/vue/jsx.d.ts +0 -22
- package/lib/vapor/@vue/vue/package.json +0 -114
- package/lib/vapor/@vue/vue/server-renderer/index.d.mts +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.d.ts +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.js +0 -1
- package/lib/vapor/@vue/vue/server-renderer/index.mjs +0 -1
- package/lib/vapor/@vue/vue/server-renderer/package.json +0 -4
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-4070620250731002",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,73 +22,73 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ampproject/remapping": "^2.1.2",
|
|
25
|
-
"@babel/code-frame": "7.
|
|
26
|
-
"@babel/core": "7.
|
|
27
|
-
"@babel/parser": "7.
|
|
28
|
-
"@babel/types": "7.
|
|
25
|
+
"@babel/code-frame": "^7.23.5",
|
|
26
|
+
"@babel/core": "^7.23.3",
|
|
27
|
+
"@babel/parser": "^7.23.9",
|
|
28
|
+
"@babel/types": "^7.20.7",
|
|
29
29
|
"@intlify/core-base": "9.1.9",
|
|
30
30
|
"@intlify/shared": "9.1.9",
|
|
31
31
|
"@intlify/vue-devtools": "9.1.9",
|
|
32
|
-
"@rollup/pluginutils": "5.
|
|
32
|
+
"@rollup/pluginutils": "^5.0.5",
|
|
33
33
|
"@vue/compiler-core": "3.4.21",
|
|
34
34
|
"@vue/compiler-dom": "3.4.21",
|
|
35
35
|
"@vue/compiler-sfc": "3.4.21",
|
|
36
36
|
"@vue/compiler-ssr": "3.4.21",
|
|
37
37
|
"@vue/server-renderer": "3.4.21",
|
|
38
38
|
"@vue/shared": "3.4.21",
|
|
39
|
-
"adm-zip": "0.5.
|
|
40
|
-
"autoprefixer": "10.4.
|
|
39
|
+
"adm-zip": "^0.5.12",
|
|
40
|
+
"autoprefixer": "^10.4.19",
|
|
41
41
|
"base64url": "^3.0.1",
|
|
42
|
-
"chokidar": "3.
|
|
42
|
+
"chokidar": "^3.5.3",
|
|
43
43
|
"compare-versions": "^3.6.0",
|
|
44
|
-
"debug": "4.3.
|
|
44
|
+
"debug": "^4.3.3",
|
|
45
45
|
"entities": "^4.5.0",
|
|
46
|
-
"es-module-lexer": "1.
|
|
47
|
-
"esbuild": "0.20.
|
|
48
|
-
"estree-walker": "2.0.2",
|
|
49
|
-
"fast-glob": "3.
|
|
50
|
-
"fs-extra": "10.
|
|
51
|
-
"hash-sum": "2.0.0",
|
|
52
|
-
"isbinaryfile": "5.0.2",
|
|
53
|
-
"jsonc-parser": "3.
|
|
46
|
+
"es-module-lexer": "^1.2.1",
|
|
47
|
+
"esbuild": "^0.20.1",
|
|
48
|
+
"estree-walker": "^2.0.2",
|
|
49
|
+
"fast-glob": "^3.2.11",
|
|
50
|
+
"fs-extra": "^10.0.0",
|
|
51
|
+
"hash-sum": "^2.0.0",
|
|
52
|
+
"isbinaryfile": "^5.0.2",
|
|
53
|
+
"jsonc-parser": "^3.2.0",
|
|
54
54
|
"lines-and-columns": "^2.0.4",
|
|
55
|
-
"magic-string": "0.30.
|
|
56
|
-
"merge": "2.1.1",
|
|
57
|
-
"mime": "3.0.0",
|
|
58
|
-
"module-alias": "2.2.
|
|
55
|
+
"magic-string": "^0.30.7",
|
|
56
|
+
"merge": "^2.1.1",
|
|
57
|
+
"mime": "^3.0.0",
|
|
58
|
+
"module-alias": "^2.2.2",
|
|
59
59
|
"os-locale-s-fix": "^1.0.8-fix-1",
|
|
60
|
-
"picocolors": "1.
|
|
60
|
+
"picocolors": "^1.0.0",
|
|
61
61
|
"postcss-import": "^14.0.2",
|
|
62
62
|
"postcss-load-config": "^3.1.1",
|
|
63
63
|
"postcss-modules": "^4.3.0",
|
|
64
|
-
"postcss-selector-parser": "6.
|
|
65
|
-
"resolve": "1.22.
|
|
66
|
-
"source-map-js": "1.2
|
|
64
|
+
"postcss-selector-parser": "^6.0.6",
|
|
65
|
+
"resolve": "^1.22.1",
|
|
66
|
+
"source-map-js": "^1.0.2",
|
|
67
67
|
"tapable": "^2.2.0",
|
|
68
68
|
"unimport": "4.1.1",
|
|
69
69
|
"unplugin-auto-import": "19.1.0",
|
|
70
70
|
"xregexp": "3.1.0",
|
|
71
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
72
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
71
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-4070620250731002",
|
|
72
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-4070620250731002"
|
|
73
73
|
},
|
|
74
74
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@types/adm-zip": "0.5.5",
|
|
76
|
+
"@types/adm-zip": "^0.5.5",
|
|
77
77
|
"@types/babel__code-frame": "^7.0.6",
|
|
78
78
|
"@types/babel__core": "^7.1.19",
|
|
79
|
-
"@types/debug": "4.1.
|
|
80
|
-
"@types/estree": "1.0.5",
|
|
81
|
-
"@types/fs-extra": "9.0.13",
|
|
79
|
+
"@types/debug": "^4.1.7",
|
|
80
|
+
"@types/estree": "^1.0.5",
|
|
81
|
+
"@types/fs-extra": "^9.0.13",
|
|
82
82
|
"@types/hash-sum": "^1.0.0",
|
|
83
83
|
"@types/less": "^3.0.3",
|
|
84
|
-
"@types/mime": "2.0.3",
|
|
85
|
-
"@types/module-alias": "2.0.4",
|
|
86
|
-
"@types/resolve": "1.20.
|
|
87
|
-
"@types/sass": "1.43.1",
|
|
84
|
+
"@types/mime": "^2.0.3",
|
|
85
|
+
"@types/module-alias": "^2.0.4",
|
|
86
|
+
"@types/resolve": "^1.20.2",
|
|
87
|
+
"@types/sass": "^1.43.1",
|
|
88
88
|
"@types/stylus": "^0.48.36",
|
|
89
89
|
"code-frame": "link:@types/@babel/code-frame",
|
|
90
|
-
"postcss": "8.4.
|
|
90
|
+
"postcss": "^8.4.21",
|
|
91
91
|
"vue": "3.4.21",
|
|
92
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
92
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4070620250731002"
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uniStatsPlugin = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const emittedHashMap = new WeakMap();
|
|
6
|
-
function uniStatsPlugin() {
|
|
7
|
-
let resolvedConfig;
|
|
8
|
-
return {
|
|
9
|
-
name: 'uni:app-stats',
|
|
10
|
-
enforce: 'post',
|
|
11
|
-
configResolved(config) {
|
|
12
|
-
resolvedConfig = config;
|
|
13
|
-
emittedHashMap.set(resolvedConfig, new Map());
|
|
14
|
-
},
|
|
15
|
-
writeBundle(_, bundle) {
|
|
16
|
-
if (resolvedConfig.isProduction) {
|
|
17
|
-
// 仅dev生效
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const emittedHash = emittedHashMap.get(resolvedConfig);
|
|
21
|
-
const changedFiles = [];
|
|
22
|
-
Object.keys(bundle).forEach((filename) => {
|
|
23
|
-
const outputFile = bundle[filename];
|
|
24
|
-
let outputFileHash = '';
|
|
25
|
-
if (outputFile.type === 'asset') {
|
|
26
|
-
outputFileHash = (0, utils_1.hash)(outputFile.source);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
outputFileHash = (0, utils_1.hash)(outputFile.code);
|
|
30
|
-
}
|
|
31
|
-
if (emittedHash.get(filename) !== outputFileHash) {
|
|
32
|
-
emittedHash.set(filename, outputFileHash);
|
|
33
|
-
changedFiles.push(filename);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
process.env.UNI_APP_CHANGED_FILES = changedFiles.length
|
|
37
|
-
? JSON.stringify(changedFiles)
|
|
38
|
-
: '';
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.uniStatsPlugin = uniStatsPlugin;
|
package/dist/workers.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
import type { UniXCompiler } from '@dcloudio/uni-uts-v1';
|
|
3
|
-
export declare function getWorkers(): Record<string, string>;
|
|
4
|
-
export declare function getWorkersRootDir(): string | null;
|
|
5
|
-
/**
|
|
6
|
-
* 遍历目录下的所有uts文件,读取文件内容,正则匹配出定义的worker,返回文件名和类名的映射关系
|
|
7
|
-
* export class MyWorkerTask extends WorkerTaskImpl {}
|
|
8
|
-
* @param dir
|
|
9
|
-
*/
|
|
10
|
-
export declare function initWorkers(workersDir: string, rootDir: string): Record<string, string>;
|
|
11
|
-
export declare function uniWorkersPlugin(): Plugin;
|
|
12
|
-
export declare function resolveWorkersDir(inputDir: string): any;
|
|
13
|
-
export declare function uniJavaScriptWorkersPlugin(): Plugin;
|
|
14
|
-
export declare function initUniXCompilerRootWorkers(rootDir: string, compiler: UniXCompiler): Promise<void>;
|
package/dist/workers.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initUniXCompilerRootWorkers = exports.uniJavaScriptWorkersPlugin = exports.resolveWorkersDir = exports.uniWorkersPlugin = exports.initWorkers = exports.getWorkersRootDir = exports.getWorkers = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
const fast_glob_1 = require("fast-glob");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const json_1 = require("./json");
|
|
12
|
-
const uts_1 = require("./uts");
|
|
13
|
-
const uni_modules_1 = require("./vite/plugins/uts/uni_modules");
|
|
14
|
-
const resolve_1 = require("./resolve");
|
|
15
|
-
let workersRootDir = null;
|
|
16
|
-
let workers = {};
|
|
17
|
-
function getWorkers() {
|
|
18
|
-
return workers;
|
|
19
|
-
}
|
|
20
|
-
exports.getWorkers = getWorkers;
|
|
21
|
-
function getWorkersRootDir() {
|
|
22
|
-
return workersRootDir;
|
|
23
|
-
}
|
|
24
|
-
exports.getWorkersRootDir = getWorkersRootDir;
|
|
25
|
-
/**
|
|
26
|
-
* 遍历目录下的所有uts文件,读取文件内容,正则匹配出定义的worker,返回文件名和类名的映射关系
|
|
27
|
-
* export class MyWorkerTask extends WorkerTaskImpl {}
|
|
28
|
-
* @param dir
|
|
29
|
-
*/
|
|
30
|
-
function initWorkers(workersDir, rootDir) {
|
|
31
|
-
const dir = path_1.default.join(rootDir, workersDir);
|
|
32
|
-
if (!fs_extra_1.default.existsSync(dir)) {
|
|
33
|
-
return workers;
|
|
34
|
-
}
|
|
35
|
-
workers = {};
|
|
36
|
-
(0, fast_glob_1.sync)('**/*.uts', { cwd: dir }).forEach((file) => {
|
|
37
|
-
const content = fs_extra_1.default.readFileSync(path_1.default.join(dir, file), 'utf-8');
|
|
38
|
-
const match = content.match(/export\s+class\s+(.*)\s+extends\s+WorkerTaskImpl\s*{/);
|
|
39
|
-
if (match && match[1]) {
|
|
40
|
-
workers[(0, utils_1.normalizePath)(path_1.default.join(workersDir, file))] = match[1];
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return workers;
|
|
44
|
-
}
|
|
45
|
-
exports.initWorkers = initWorkers;
|
|
46
|
-
function uniWorkersPlugin() {
|
|
47
|
-
const inputDir = process.env.UNI_INPUT_DIR;
|
|
48
|
-
const platform = process.env.UNI_UTS_PLATFORM;
|
|
49
|
-
const resolveWorkers = () => getWorkers();
|
|
50
|
-
function refreshWorkers() {
|
|
51
|
-
const workersDir = resolveWorkersDir(inputDir);
|
|
52
|
-
if (workersDir) {
|
|
53
|
-
workersRootDir = workersDir;
|
|
54
|
-
initWorkers(workersDir, inputDir);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
refreshWorkers();
|
|
60
|
-
const preprocessor = platform === 'app-android'
|
|
61
|
-
? (0, uni_modules_1.createAppAndroidUniModulesSyncFilePreprocessorOnce)(false)
|
|
62
|
-
: platform === 'app-ios'
|
|
63
|
-
? (0, uni_modules_1.createAppIosUniModulesSyncFilePreprocessorOnce)(false)
|
|
64
|
-
: platform === 'app-harmony'
|
|
65
|
-
? (0, uni_modules_1.createAppHarmonyUniModulesSyncFilePreprocessorOnce)(false)
|
|
66
|
-
: null;
|
|
67
|
-
const cache = {};
|
|
68
|
-
const uniXKotlinCompiler = platform === 'app-android'
|
|
69
|
-
? (0, uts_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce({
|
|
70
|
-
resolveWorkers,
|
|
71
|
-
})
|
|
72
|
-
: null;
|
|
73
|
-
const uniXSwiftCompiler = platform === 'app-ios'
|
|
74
|
-
? (0, uts_1.resolveUTSCompiler)().createUniXSwiftCompilerOnce({
|
|
75
|
-
resolveWorkers,
|
|
76
|
-
})
|
|
77
|
-
: null;
|
|
78
|
-
const uniXArkTSCompiler = platform === 'app-harmony'
|
|
79
|
-
? (0, uts_1.resolveUTSCompiler)().createUniXArkTSCompilerOnce({
|
|
80
|
-
resolveWorkers,
|
|
81
|
-
})
|
|
82
|
-
: null;
|
|
83
|
-
return {
|
|
84
|
-
name: 'uni-workers',
|
|
85
|
-
enforce: 'pre',
|
|
86
|
-
async buildStart() {
|
|
87
|
-
if (refreshWorkers()) {
|
|
88
|
-
if (preprocessor) {
|
|
89
|
-
await syncWorkersFiles(platform, inputDir, preprocessor, cache);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// 需要等待 workers 文件同步完之后,添加到 rootFiles 中,触发 tsc 的编译
|
|
93
|
-
if (uniXKotlinCompiler) {
|
|
94
|
-
await initUniXCompilerRootWorkers((0, uts_1.tscOutDir)('app-android'), uniXKotlinCompiler);
|
|
95
|
-
}
|
|
96
|
-
if (uniXSwiftCompiler) {
|
|
97
|
-
await initUniXCompilerRootWorkers((0, uts_1.tscOutDir)('app-ios'), uniXSwiftCompiler);
|
|
98
|
-
}
|
|
99
|
-
if (uniXArkTSCompiler) {
|
|
100
|
-
await initUniXCompilerRootWorkers((0, uts_1.tscOutDir)('app-harmony'), uniXArkTSCompiler);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
exports.uniWorkersPlugin = uniWorkersPlugin;
|
|
106
|
-
async function syncWorkersFiles(platform, inputDir, preprocessor, cache) {
|
|
107
|
-
if (platform !== 'app-harmony' &&
|
|
108
|
-
platform !== 'app-android' &&
|
|
109
|
-
platform !== 'app-ios') {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const workersDir = resolveWorkersDir(inputDir);
|
|
113
|
-
if (workersDir) {
|
|
114
|
-
const { syncUTSFiles } = (0, uts_1.resolveUTSCompiler)();
|
|
115
|
-
await syncUTSFiles((0, utils_1.normalizePath)(path_1.default.join(workersDir, '**/*.uts')), inputDir, (0, uts_1.tscOutDir)(platform), true, preprocessor, cache);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function resolveWorkersDir(inputDir) {
|
|
119
|
-
const manifestJson = (0, json_1.parseManifestJsonOnce)(inputDir);
|
|
120
|
-
if (manifestJson.workers) {
|
|
121
|
-
let workersDir = typeof manifestJson.workers === 'string'
|
|
122
|
-
? manifestJson.workers
|
|
123
|
-
: manifestJson.workers.path;
|
|
124
|
-
if (workersDir) {
|
|
125
|
-
workersDir = (0, utils_1.normalizePath)(workersDir);
|
|
126
|
-
const dir = path_1.default.join(inputDir, workersDir);
|
|
127
|
-
if (fs_extra_1.default.existsSync(dir)) {
|
|
128
|
-
return workersDir;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.resolveWorkersDir = resolveWorkersDir;
|
|
134
|
-
function uniJavaScriptWorkersPlugin() {
|
|
135
|
-
// 仅小程序平台外置uni-worker.mp.js
|
|
136
|
-
const external = (process.env.UNI_UTS_PLATFORM || '').startsWith('mp-');
|
|
137
|
-
let workerPolyfillCode = '';
|
|
138
|
-
let isWrite = false;
|
|
139
|
-
const UniAppWorkerJSName = external ? 'uni-worker.mp.js' : 'uni-worker.web.js';
|
|
140
|
-
return {
|
|
141
|
-
name: 'uni:javascript-workers',
|
|
142
|
-
generateBundle(_, bundle) {
|
|
143
|
-
const workers = getWorkers();
|
|
144
|
-
const workerPaths = Object.keys(workers).map((key) => {
|
|
145
|
-
return key.replace('.uts', '.js');
|
|
146
|
-
});
|
|
147
|
-
if (workerPaths.length) {
|
|
148
|
-
if (!workerPolyfillCode) {
|
|
149
|
-
workerPolyfillCode = fs_extra_1.default.readFileSync((0, resolve_1.resolveBuiltIn)(`@dcloudio/uni-app/dist-x/${UniAppWorkerJSName}`), 'utf-8');
|
|
150
|
-
}
|
|
151
|
-
Object.keys(bundle).forEach((file) => {
|
|
152
|
-
if (workerPaths.includes(file)) {
|
|
153
|
-
const chunk = bundle[file];
|
|
154
|
-
if (chunk.type === 'chunk') {
|
|
155
|
-
const workerCode = external
|
|
156
|
-
? `require('${(0, utils_1.normalizePath)(path_1.default.relative(path_1.default.dirname(file), path_1.default.join(getWorkersRootDir(), 'uni-worker.js')))}')`
|
|
157
|
-
: workerPolyfillCode;
|
|
158
|
-
chunk.code = `${workerCode}\n${chunk.code}\nnew ${workers[file.replace('.js', '.uts')]}()`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
writeBundle() {
|
|
165
|
-
if (external && Object.keys(getWorkers()).length && !isWrite) {
|
|
166
|
-
isWrite = true;
|
|
167
|
-
// 写入uni-worker.js
|
|
168
|
-
fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, getWorkersRootDir(), 'uni-worker.js'), workerPolyfillCode);
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
exports.uniJavaScriptWorkersPlugin = uniJavaScriptWorkersPlugin;
|
|
174
|
-
async function initUniXCompilerRootWorkers(rootDir, compiler) {
|
|
175
|
-
const workers = getWorkers();
|
|
176
|
-
if (Object.keys(workers).length) {
|
|
177
|
-
for (const key in workers) {
|
|
178
|
-
const file = path_1.default.join(rootDir, key + '.ts');
|
|
179
|
-
if (fs_extra_1.default.existsSync(file)) {
|
|
180
|
-
if (!compiler.hasRootFile(file)) {
|
|
181
|
-
await compiler.addRootFile(file);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
exports.initUniXCompilerRootWorkers = initUniXCompilerRootWorkers;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
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.
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
# @vitejs/plugin-vue [](https://npmjs.com/package/@vitejs/plugin-vue)
|
|
2
|
-
|
|
3
|
-
> Note: as of `vue` 3.2.13+ and `@vitejs/plugin-vue` 1.9.0+, `@vue/compiler-sfc` is no longer required as a peer dependency.
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
// vite.config.js
|
|
7
|
-
import vue from '@vitejs/plugin-vue'
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
plugins: [vue()],
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
For JSX / TSX support, [`@vitejs/plugin-vue-jsx`](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) is also needed.
|
|
15
|
-
|
|
16
|
-
## Options
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
export interface Options {
|
|
20
|
-
include?: string | RegExp | (string | RegExp)[]
|
|
21
|
-
exclude?: string | RegExp | (string | RegExp)[]
|
|
22
|
-
|
|
23
|
-
isProduction?: boolean
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Requires @vitejs/plugin-vue@^5.1.0
|
|
27
|
-
*/
|
|
28
|
-
features?: {
|
|
29
|
-
/**
|
|
30
|
-
* Enable reactive destructure for `defineProps`.
|
|
31
|
-
* - Available in Vue 3.4 and later.
|
|
32
|
-
* - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+
|
|
33
|
-
*/
|
|
34
|
-
propsDestructure?: boolean
|
|
35
|
-
/**
|
|
36
|
-
* Transform Vue SFCs into custom elements.
|
|
37
|
-
* - `true`: all `*.vue` imports are converted into custom elements
|
|
38
|
-
* - `string | RegExp`: matched files are converted into custom elements
|
|
39
|
-
* - **default:** /\.ce\.vue$/
|
|
40
|
-
*/
|
|
41
|
-
customElement?: boolean | string | RegExp | (string | RegExp)[]
|
|
42
|
-
/**
|
|
43
|
-
* Set to `false` to disable Options API support and allow related code in
|
|
44
|
-
* Vue core to be dropped via dead-code elimination in production builds,
|
|
45
|
-
* resulting in smaller bundles.
|
|
46
|
-
* - **default:** `true`
|
|
47
|
-
*/
|
|
48
|
-
optionsAPI?: boolean
|
|
49
|
-
/**
|
|
50
|
-
* Set to `true` to enable devtools support in production builds.
|
|
51
|
-
* Results in slightly larger bundles.
|
|
52
|
-
* - **default:** `false`
|
|
53
|
-
*/
|
|
54
|
-
prodDevtools?: boolean
|
|
55
|
-
/**
|
|
56
|
-
* Set to `true` to enable detailed information for hydration mismatch
|
|
57
|
-
* errors in production builds. Results in slightly larger bundles.
|
|
58
|
-
* - **default:** `false`
|
|
59
|
-
*/
|
|
60
|
-
prodHydrationMismatchDetails?: boolean
|
|
61
|
-
/**
|
|
62
|
-
* Customize the component ID generation strategy.
|
|
63
|
-
* - `'filepath'`: hash the file path (relative to the project root)
|
|
64
|
-
* - `'filepath-source'`: hash the file path and the source code
|
|
65
|
-
* - `function`: custom function that takes the file path, source code,
|
|
66
|
-
* whether in production mode, and the default hash function as arguments
|
|
67
|
-
* - **default:** `'filepath'` in development, `'filepath-source'` in production
|
|
68
|
-
*/
|
|
69
|
-
componentIdGenerator?:
|
|
70
|
-
| 'filepath'
|
|
71
|
-
| 'filepath-source'
|
|
72
|
-
| ((
|
|
73
|
-
filepath: string,
|
|
74
|
-
source: string,
|
|
75
|
-
isProduction: boolean | undefined,
|
|
76
|
-
getHash: (text: string) => string,
|
|
77
|
-
) => string)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// `script`, `template` and `style` are lower-level compiler options
|
|
81
|
-
// to pass on to respective APIs of `vue/compiler-sfc`
|
|
82
|
-
|
|
83
|
-
script?: Partial<
|
|
84
|
-
Omit<
|
|
85
|
-
SFCScriptCompileOptions,
|
|
86
|
-
| 'id'
|
|
87
|
-
| 'isProd'
|
|
88
|
-
| 'inlineTemplate'
|
|
89
|
-
| 'templateOptions'
|
|
90
|
-
| 'sourceMap'
|
|
91
|
-
| 'genDefaultAs'
|
|
92
|
-
| 'customElement'
|
|
93
|
-
>
|
|
94
|
-
>
|
|
95
|
-
|
|
96
|
-
template?: Partial<
|
|
97
|
-
Omit<
|
|
98
|
-
SFCTemplateCompileOptions,
|
|
99
|
-
| 'id'
|
|
100
|
-
| 'source'
|
|
101
|
-
| 'ast'
|
|
102
|
-
| 'filename'
|
|
103
|
-
| 'scoped'
|
|
104
|
-
| 'slotted'
|
|
105
|
-
| 'isProd'
|
|
106
|
-
| 'inMap'
|
|
107
|
-
| 'ssr'
|
|
108
|
-
| 'ssrCssVars'
|
|
109
|
-
| 'preprocessLang'
|
|
110
|
-
>
|
|
111
|
-
>
|
|
112
|
-
|
|
113
|
-
style?: Partial<
|
|
114
|
-
Omit<
|
|
115
|
-
SFCStyleCompileOptions,
|
|
116
|
-
| 'filename'
|
|
117
|
-
| 'id'
|
|
118
|
-
| 'isProd'
|
|
119
|
-
| 'source'
|
|
120
|
-
| 'scoped'
|
|
121
|
-
| 'cssDevSourcemap'
|
|
122
|
-
| 'postcssOptions'
|
|
123
|
-
| 'map'
|
|
124
|
-
| 'postcssPlugins'
|
|
125
|
-
| 'preprocessCustomRequire'
|
|
126
|
-
| 'preprocessLang'
|
|
127
|
-
| 'preprocessOptions'
|
|
128
|
-
>
|
|
129
|
-
>
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Use custom compiler-sfc instance. Can be used to force a specific version.
|
|
133
|
-
*/
|
|
134
|
-
compiler?: typeof _compiler
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @deprecated moved to `features.customElement`.
|
|
138
|
-
*/
|
|
139
|
-
customElements?: boolean | string | RegExp | (string | RegExp)[]
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Asset URL handling
|
|
144
|
-
|
|
145
|
-
When `@vitejs/plugin-vue` compiles the `<template>` blocks in SFCs, it also converts any encountered asset URLs into ESM imports.
|
|
146
|
-
|
|
147
|
-
For example, the following template snippet:
|
|
148
|
-
|
|
149
|
-
```vue
|
|
150
|
-
<img src="../image.png" />
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Is the same as:
|
|
154
|
-
|
|
155
|
-
```vue
|
|
156
|
-
<script setup>
|
|
157
|
-
import _imports_0 from '../image.png'
|
|
158
|
-
</script>
|
|
159
|
-
|
|
160
|
-
<img :src="_imports_0" />
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
By default the following tag/attribute combinations are transformed, and can be configured using the `template.transformAssetUrls` option.
|
|
164
|
-
|
|
165
|
-
```js
|
|
166
|
-
{
|
|
167
|
-
video: ['src', 'poster'],
|
|
168
|
-
source: ['src'],
|
|
169
|
-
img: ['src'],
|
|
170
|
-
image: ['xlink:href', 'href'],
|
|
171
|
-
use: ['xlink:href', 'href']
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Note that only attribute values that are static strings are transformed. Otherwise, you'd need to import the asset manually, e.g. `import imgUrl from '../image.png'`.
|
|
176
|
-
|
|
177
|
-
## Example for passing options to `vue/compiler-sfc`:
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
import vue from '@vitejs/plugin-vue'
|
|
181
|
-
|
|
182
|
-
export default {
|
|
183
|
-
plugins: [
|
|
184
|
-
vue({
|
|
185
|
-
template: {
|
|
186
|
-
compilerOptions: {
|
|
187
|
-
// ...
|
|
188
|
-
},
|
|
189
|
-
transformAssetUrls: {
|
|
190
|
-
// ...
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
}),
|
|
194
|
-
],
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Example for transforming custom blocks
|
|
199
|
-
|
|
200
|
-
```ts
|
|
201
|
-
import vue from '@vitejs/plugin-vue'
|
|
202
|
-
import yaml from 'js-yaml'
|
|
203
|
-
|
|
204
|
-
const vueI18nPlugin = {
|
|
205
|
-
name: 'vue-i18n',
|
|
206
|
-
transform(code, id) {
|
|
207
|
-
// if .vue file don't have <i18n> block, just return
|
|
208
|
-
if (!/vue&type=i18n/.test(id)) {
|
|
209
|
-
return
|
|
210
|
-
}
|
|
211
|
-
// parse yaml
|
|
212
|
-
if (/\.ya?ml$/.test(id)) {
|
|
213
|
-
code = JSON.stringify(yaml.load(code.trim()))
|
|
214
|
-
}
|
|
215
|
-
// mount the value on the i18n property of the component instance
|
|
216
|
-
return `export default Comp => {
|
|
217
|
-
Comp.i18n = ${code}
|
|
218
|
-
}`
|
|
219
|
-
},
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export default {
|
|
223
|
-
plugins: [vue(), vueI18nPlugin],
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Create a file named `Demo.vue`, add `lang="yaml"` to the `<i18n>` blocks, then you can use the syntax of `YAML`:
|
|
228
|
-
|
|
229
|
-
```vue
|
|
230
|
-
<template>Hello</template>
|
|
231
|
-
|
|
232
|
-
<i18n lang="yaml">
|
|
233
|
-
message: 'world'
|
|
234
|
-
fullWord: 'hello world'
|
|
235
|
-
</i18n>
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
`message` is mounted on the i18n property of the component instance, you can use like this:
|
|
239
|
-
|
|
240
|
-
```vue
|
|
241
|
-
<script setup lang="ts">
|
|
242
|
-
import Demo from 'components/Demo.vue'
|
|
243
|
-
</script>
|
|
244
|
-
|
|
245
|
-
<template>
|
|
246
|
-
<Demo /> {{ Demo.i18n.message }}
|
|
247
|
-
<div>{{ Demo.i18n.fullWord }}</div>
|
|
248
|
-
</template>
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
## Using Vue SFCs as Custom Elements
|
|
252
|
-
|
|
253
|
-
> Requires `vue@^3.2.0` & `@vitejs/plugin-vue@^1.4.0`
|
|
254
|
-
|
|
255
|
-
Vue 3.2 introduces the `defineCustomElement` method, which works with SFCs. By default, `<style>` tags inside SFCs are extracted and merged into CSS files during build. However when shipping a library of custom elements, it may be desirable to inline the styles as JavaScript strings and inject them into the custom elements' shadow root instead.
|
|
256
|
-
|
|
257
|
-
Starting in 1.4.0, files ending with `*.ce.vue` will be compiled in "custom elements" mode: its `<style>` tags are compiled into inlined CSS strings and attached to the component as its `styles` property:
|
|
258
|
-
|
|
259
|
-
```js
|
|
260
|
-
import { defineCustomElement } from 'vue'
|
|
261
|
-
import Example from './Example.ce.vue'
|
|
262
|
-
|
|
263
|
-
console.log(Example.styles) // ['/* css content */']
|
|
264
|
-
|
|
265
|
-
// register
|
|
266
|
-
customElements.define('my-example', defineCustomElement(Example))
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
Note in custom elements mode there is no need to use `<style scoped>` since the CSS is already scoped inside the shadow DOM.
|
|
270
|
-
|
|
271
|
-
The `customElement` plugin option can be used to configure the behavior:
|
|
272
|
-
|
|
273
|
-
- `{ customElement: true }` will import all `*.vue` files in custom element mode.
|
|
274
|
-
- Use a string or regex pattern to change how files should be loaded as Custom Elements (this check is applied after `include` and `exclude` matches).
|
|
275
|
-
|
|
276
|
-
## License
|
|
277
|
-
|
|
278
|
-
MIT
|