@dcloudio/uni-cli-shared 3.0.0-alpha-4070420250630002 → 3.0.0-alpha-4070520250704002

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.
@@ -0,0 +1,61 @@
1
+ function resolveNativeBinding () {
2
+ const { platform, arch } = process
3
+ let nativeBinding = ''
4
+ switch (platform) {
5
+ case 'win32':
6
+ switch (arch) {
7
+ case 'x64':
8
+ nativeBinding = 'preprocessor-windows-x86_64'
9
+ break
10
+ default:
11
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
12
+ }
13
+ break
14
+ case 'darwin':
15
+ switch (arch) {
16
+ case 'x64':
17
+ nativeBinding = 'preprocessor-macos-x86_64'
18
+ break
19
+ case 'arm64':
20
+ nativeBinding = 'preprocessor-macos-arm64'
21
+ break
22
+ default:
23
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
24
+ }
25
+ break
26
+ default:
27
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
28
+ }
29
+ return require('./' + nativeBinding)
30
+ }
31
+
32
+ async function runProcess (vue3 = false) {
33
+ try {
34
+ /* eslint-disable no-undef */
35
+ globalThis.preprocessor_require = require
36
+ await resolveNativeBinding().process(vue3)
37
+ } catch (error) {
38
+ }
39
+ }
40
+
41
+ class PreprocessorWebpackPlugin {
42
+ apply (compiler) {
43
+ compiler.hooks.afterEmit.tapPromise('d', (params) => {
44
+ return runProcess(false)
45
+ })
46
+ }
47
+ }
48
+
49
+ function PreprocessorVitePlugin () {
50
+ return {
51
+ name: 'preprocessor',
52
+ async writeBundle (_) {
53
+ await runProcess(true)
54
+ }
55
+ }
56
+ }
57
+
58
+ module.exports = {
59
+ PreprocessorWebpackPlugin,
60
+ PreprocessorVitePlugin
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4070420250630002",
3
+ "version": "3.0.0-alpha-4070520250704002",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -68,8 +68,8 @@
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-4070420250630002",
72
- "@dcloudio/uni-shared": "3.0.0-alpha-4070420250630002"
71
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4070520250704002",
72
+ "@dcloudio/uni-shared": "3.0.0-alpha-4070520250704002"
73
73
  },
74
74
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
75
75
  "devDependencies": {
@@ -89,6 +89,6 @@
89
89
  "code-frame": "link:@types/@babel/code-frame",
90
90
  "postcss": "^8.4.21",
91
91
  "vue": "3.4.21",
92
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4070420250630002"
92
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4070520250704002"
93
93
  }
94
94
  }