@dcloudio/vue-cli-plugin-uni 2.0.2-alpha-3090920231206001 → 2.0.2-alpha-3090920231207002
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/lib/configure-webpack.js +11 -72
- package/lib/util.js +76 -0
- package/package.json +3 -3
package/lib/configure-webpack.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
1
|
const path = require('path')
|
|
3
2
|
const webpack = require('webpack')
|
|
4
3
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
@@ -14,10 +13,6 @@ function resolve (dir) {
|
|
|
14
13
|
return path.resolve(__dirname, '..', dir)
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
function resolveModule (dir) {
|
|
18
|
-
return path.resolve(process.env.UNI_CLI_CONTEXT, './node_modules', dir)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
module.exports = function configureWebpack (platformOptions, manifestPlatformOptions, vueOptions, api) {
|
|
22
17
|
const {
|
|
23
18
|
runByHBuilderX, // 使用 HBuilderX 运行
|
|
@@ -97,71 +92,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
97
92
|
matchUse.push(loader)
|
|
98
93
|
}
|
|
99
94
|
|
|
100
|
-
const
|
|
101
|
-
const defaultTsConfigJson = path.resolve(process.env.UNI_CLI_CONTEXT, 'tsconfig.json')
|
|
102
|
-
|
|
103
|
-
const tsConfigJsonFile = fs.existsSync(userTsConfigJson) ? userTsConfigJson : defaultTsConfigJson
|
|
104
|
-
|
|
105
|
-
const context = isInHBuilderX ? process.env.UNI_INPUT_DIR : process.env.UNI_CLI_CONTEXT
|
|
106
|
-
|
|
107
|
-
const tsLoaderOptions = {
|
|
108
|
-
context,
|
|
109
|
-
configFile: tsConfigJsonFile,
|
|
110
|
-
compilerOptions: {
|
|
111
|
-
baseUrl: context,
|
|
112
|
-
typeRoots: [
|
|
113
|
-
resolveModule('@dcloudio/types'),
|
|
114
|
-
resolveModule('@types'),
|
|
115
|
-
path.resolve(process.env.UNI_CLI_CONTEXT, 'types')
|
|
116
|
-
],
|
|
117
|
-
types: [
|
|
118
|
-
'uni-app',
|
|
119
|
-
'uni-app-vue2',
|
|
120
|
-
'webpack-env'
|
|
121
|
-
],
|
|
122
|
-
paths: {
|
|
123
|
-
'@/*': [
|
|
124
|
-
path.join(process.env.UNI_INPUT_DIR, '*')
|
|
125
|
-
],
|
|
126
|
-
vue: [
|
|
127
|
-
resolveModule('vue')
|
|
128
|
-
],
|
|
129
|
-
vuex: [
|
|
130
|
-
resolveModule('vuex')
|
|
131
|
-
],
|
|
132
|
-
'vue-class-component': [
|
|
133
|
-
resolveModule('vue-class-component')
|
|
134
|
-
],
|
|
135
|
-
'vue-property-decorator': [
|
|
136
|
-
resolveModule('vue-property-decorator')
|
|
137
|
-
],
|
|
138
|
-
tslib: [
|
|
139
|
-
resolveModule('tslib')
|
|
140
|
-
],
|
|
141
|
-
'mpvue-page-factory': [
|
|
142
|
-
resolveModule('@dcloudio/vue-cli-plugin-uni/packages/mpvue-page-factory')
|
|
143
|
-
],
|
|
144
|
-
'@vue/composition-api': [
|
|
145
|
-
resolveModule('@dcloudio/vue-cli-plugin-uni/packages/@vue/composition-api')
|
|
146
|
-
],
|
|
147
|
-
'@dcloudio/uni-app': [
|
|
148
|
-
resolveModule('@dcloudio/uni-app')
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
errorFormatter (error, colors) {
|
|
153
|
-
const messageColor = error.severity === 'warning' ? colors.bold.yellow : colors.bold.red
|
|
154
|
-
const filePath = path.relative(process.env.UNI_INPUT_DIR, error.file).replace('.vue.ts', '.vue')
|
|
155
|
-
if (error.code === 2307 && error.content.includes('.vue')) {
|
|
156
|
-
error.content = error.content.replace('Cannot find module ', '') +
|
|
157
|
-
' script 节点必须使用 lang="ts",文档参考地址:https://uniapp.dcloud.io/frame?id=vue-ts'
|
|
158
|
-
}
|
|
159
|
-
return messageColor(
|
|
160
|
-
`[tsl] ERROR at ${filePath}:${error.line}
|
|
161
|
-
TS${error.code}:${error.content}`
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
95
|
+
const tsLoaderOptions = require('./util').getTsLoadOptions()
|
|
165
96
|
|
|
166
97
|
function updateTsLoader (rawRules, fakeFile, loader) {
|
|
167
98
|
const matchRule = rawRules.find(createMatcher(fakeFile))
|
|
@@ -261,7 +192,15 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
261
192
|
.parseUniExtApis(false, process.env.UNI_UTS_PLATFORM, 'javascript')
|
|
262
193
|
const keys = Object.keys(uniExtApis)
|
|
263
194
|
if (keys.length) {
|
|
264
|
-
|
|
195
|
+
const provides = {}
|
|
196
|
+
keys.forEach(name => {
|
|
197
|
+
const provide = uniExtApis[name]
|
|
198
|
+
if (Array.isArray(provide) && provide.length === 3) {
|
|
199
|
+
provide.pop()
|
|
200
|
+
}
|
|
201
|
+
provides[name] = provide
|
|
202
|
+
})
|
|
203
|
+
plugins.push(new webpack.ProvidePlugin(provides))
|
|
265
204
|
}
|
|
266
205
|
}
|
|
267
206
|
if (!process.env.UNI_SUBPACKGE || !process.env.UNI_MP_PLUGIN) {
|
|
@@ -449,4 +388,4 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
449
388
|
watchOptions: require('./util').getWatchOptions()
|
|
450
389
|
}, platformWebpackConfig)
|
|
451
390
|
}
|
|
452
|
-
}
|
|
391
|
+
}
|
package/lib/util.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
1
2
|
const path = require('path')
|
|
3
|
+
|
|
2
4
|
const {
|
|
3
5
|
pathToGlob
|
|
4
6
|
} = require('@dcloudio/uni-cli-shared/lib/util')
|
|
@@ -37,5 +39,79 @@ module.exports = {
|
|
|
37
39
|
path.resolve(process.env.UNI_INPUT_DIR, 'cloudfunctions-tcb')
|
|
38
40
|
]
|
|
39
41
|
}
|
|
42
|
+
},
|
|
43
|
+
getTsLoadOptions () {
|
|
44
|
+
const {
|
|
45
|
+
isInHBuilderX // 在 HBuilderX 的插件中
|
|
46
|
+
} = require('@dcloudio/uni-cli-shared')
|
|
47
|
+
const userTsConfigJson = path.resolve(process.env.UNI_INPUT_DIR, 'tsconfig.json')
|
|
48
|
+
const defaultTsConfigJson = path.resolve(process.env.UNI_CLI_CONTEXT, 'tsconfig.json')
|
|
49
|
+
|
|
50
|
+
const tsConfigJsonFile = fs.existsSync(userTsConfigJson) ? userTsConfigJson : defaultTsConfigJson
|
|
51
|
+
|
|
52
|
+
const context = isInHBuilderX ? process.env.UNI_INPUT_DIR : process.env.UNI_CLI_CONTEXT
|
|
53
|
+
|
|
54
|
+
function resolveModule (dir) {
|
|
55
|
+
return path.resolve(process.env.UNI_CLI_CONTEXT, './node_modules', dir)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
context,
|
|
60
|
+
configFile: tsConfigJsonFile,
|
|
61
|
+
compilerOptions: {
|
|
62
|
+
baseUrl: context,
|
|
63
|
+
typeRoots: [
|
|
64
|
+
resolveModule('@dcloudio/types'),
|
|
65
|
+
resolveModule('@types'),
|
|
66
|
+
path.resolve(process.env.UNI_CLI_CONTEXT, 'types')
|
|
67
|
+
],
|
|
68
|
+
types: [
|
|
69
|
+
'uni-app',
|
|
70
|
+
'uni-app-vue2',
|
|
71
|
+
'webpack-env'
|
|
72
|
+
],
|
|
73
|
+
paths: {
|
|
74
|
+
'@/*': [
|
|
75
|
+
path.join(process.env.UNI_INPUT_DIR, '*')
|
|
76
|
+
],
|
|
77
|
+
vue: [
|
|
78
|
+
resolveModule('vue')
|
|
79
|
+
],
|
|
80
|
+
vuex: [
|
|
81
|
+
resolveModule('vuex')
|
|
82
|
+
],
|
|
83
|
+
'vue-class-component': [
|
|
84
|
+
resolveModule('vue-class-component')
|
|
85
|
+
],
|
|
86
|
+
'vue-property-decorator': [
|
|
87
|
+
resolveModule('vue-property-decorator')
|
|
88
|
+
],
|
|
89
|
+
tslib: [
|
|
90
|
+
resolveModule('tslib')
|
|
91
|
+
],
|
|
92
|
+
'mpvue-page-factory': [
|
|
93
|
+
resolveModule('@dcloudio/vue-cli-plugin-uni/packages/mpvue-page-factory')
|
|
94
|
+
],
|
|
95
|
+
'@vue/composition-api': [
|
|
96
|
+
resolveModule('@dcloudio/vue-cli-plugin-uni/packages/@vue/composition-api')
|
|
97
|
+
],
|
|
98
|
+
'@dcloudio/uni-app': [
|
|
99
|
+
resolveModule('@dcloudio/uni-app')
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
errorFormatter (error, colors) {
|
|
104
|
+
const messageColor = error.severity === 'warning' ? colors.bold.yellow : colors.bold.red
|
|
105
|
+
const filePath = path.relative(process.env.UNI_INPUT_DIR, error.file).replace('.vue.ts', '.vue')
|
|
106
|
+
if (error.code === 2307 && error.content.includes('.vue')) {
|
|
107
|
+
error.content = error.content.replace('Cannot find module ', '') +
|
|
108
|
+
' script 节点必须使用 lang="ts",文档参考地址:https://uniapp.dcloud.io/frame?id=vue-ts'
|
|
109
|
+
}
|
|
110
|
+
return messageColor(
|
|
111
|
+
`[tsl] ERROR at ${filePath}:${error.line}
|
|
112
|
+
TS${error.code}:${error.content}`
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
40
116
|
}
|
|
41
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/vue-cli-plugin-uni",
|
|
3
|
-
"version": "2.0.2-alpha-
|
|
3
|
+
"version": "2.0.2-alpha-3090920231207002",
|
|
4
4
|
"description": "uni-app plugin for vue-cli 3",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "fxy060608",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dcloudio/uni-stat": "^2.0.2-alpha-
|
|
20
|
+
"@dcloudio/uni-stat": "^2.0.2-alpha-3090920231207002",
|
|
21
21
|
"buffer-json": "^2.0.0",
|
|
22
22
|
"clone-deep": "^4.0.1",
|
|
23
23
|
"cross-env": "^5.2.0",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"copy-webpack-plugin": ">=5",
|
|
42
42
|
"postcss": ">=7"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "8710134ae8cd4ed7807b81bf1178de54529ccea6"
|
|
45
45
|
}
|