@dcloudio/uni-cli-shared 2.0.1-alpha-35420220810001 → 2.0.1-alpha-35520220824001
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/preprocess.js +2 -1
- package/lib/source-map.js +2 -8
- package/lib/util.js +32 -0
- package/package.json +4 -2
package/lib/preprocess.js
CHANGED
package/lib/source-map.js
CHANGED
|
@@ -4,16 +4,10 @@ const webpack = require('webpack')
|
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
normalizePath,
|
|
7
|
+
pathToRegexp,
|
|
7
8
|
isInHBuilderX
|
|
8
9
|
} = require('@dcloudio/uni-cli-shared/lib/util')
|
|
9
10
|
|
|
10
|
-
const isWin = /^win/.test(process.platform)
|
|
11
|
-
|
|
12
|
-
function genTranspileDepRegex (depPath) {
|
|
13
|
-
return new RegExp(isWin
|
|
14
|
-
? depPath.replace(/\\/g, '\\\\') // double escape for windows style path
|
|
15
|
-
: depPath)
|
|
16
|
-
}
|
|
17
11
|
let sourceRoot = false
|
|
18
12
|
|
|
19
13
|
function getSourceRoot () {
|
|
@@ -60,7 +54,7 @@ module.exports = {
|
|
|
60
54
|
},
|
|
61
55
|
createEvalSourceMapDevToolPlugin () {
|
|
62
56
|
return new webpack.EvalSourceMapDevToolPlugin({
|
|
63
|
-
test:
|
|
57
|
+
test: pathToRegexp(process.env.UNI_INPUT_DIR, { start: true }),
|
|
64
58
|
exclude,
|
|
65
59
|
moduleFilenameTemplate
|
|
66
60
|
})
|
package/lib/util.js
CHANGED
|
@@ -2,6 +2,8 @@ const path = require('path')
|
|
|
2
2
|
const fs = require('fs')
|
|
3
3
|
const hash = require('hash-sum')
|
|
4
4
|
const crypto = require('crypto')
|
|
5
|
+
const escapeStringRegexp = require('escape-string-regexp')
|
|
6
|
+
const escapeGlob = require('glob-escape')
|
|
5
7
|
|
|
6
8
|
const isWin = /^win/.test(process.platform)
|
|
7
9
|
|
|
@@ -121,6 +123,34 @@ function normalizeNodeModules (str) {
|
|
|
121
123
|
|
|
122
124
|
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
123
125
|
|
|
126
|
+
/**
|
|
127
|
+
* pathToRegexp
|
|
128
|
+
* @param {string} pathString
|
|
129
|
+
* @param {{start:?boolean,end:?boolean,global:?boolean}?} options
|
|
130
|
+
* @returns {RegExp}
|
|
131
|
+
*/
|
|
132
|
+
function pathToRegexp (pathString, options = {}) {
|
|
133
|
+
return new RegExp((options.start ? '^' : '') + escapeStringRegexp(pathString) + (options.end ? '$' : ''), 'i' + (options.global ? 'g' : ''))
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* pathToGlob
|
|
138
|
+
* @param {string} pathString
|
|
139
|
+
* @param {string} glob
|
|
140
|
+
* @param {{windows:?boolean,escape:?boolean}?} options
|
|
141
|
+
* @returns {string}
|
|
142
|
+
*/
|
|
143
|
+
function pathToGlob (pathString, glob, options = {}) {
|
|
144
|
+
const isWindows = 'windows' in options ? options.windows : /^win/.test(process.platform)
|
|
145
|
+
const useEscape = options.escape
|
|
146
|
+
const str = isWindows ? pathString.replace(/\\/g, '/') : pathString
|
|
147
|
+
let safeStr = escapeGlob(str)
|
|
148
|
+
if (isWindows || !useEscape) {
|
|
149
|
+
safeStr = safeStr.replace(/\\(.)/g, '[$1]')
|
|
150
|
+
}
|
|
151
|
+
return path.posix.join(safeStr, glob)
|
|
152
|
+
}
|
|
153
|
+
|
|
124
154
|
module.exports = {
|
|
125
155
|
isInHBuilderX,
|
|
126
156
|
isInHBuilderXAlpha,
|
|
@@ -149,6 +179,8 @@ module.exports = {
|
|
|
149
179
|
hyphenate,
|
|
150
180
|
normalizePath,
|
|
151
181
|
convertStaticStyle,
|
|
182
|
+
pathToRegexp,
|
|
183
|
+
pathToGlob,
|
|
152
184
|
getComponentName: cached((str) => {
|
|
153
185
|
if (str.indexOf('wx-') === 0) {
|
|
154
186
|
return str.replace('wx-', 'weixin-')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-35520220824001",
|
|
4
4
|
"description": "uni-cli-shared",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
"author": "fxy060608",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"escape-string-regexp": "^4.0.0",
|
|
23
|
+
"glob-escape": "^0.0.2",
|
|
22
24
|
"hash-sum": "^1.0.2",
|
|
23
25
|
"postcss-urlrewrite": "^0.2.2",
|
|
24
26
|
"strip-json-comments": "^2.0.1"
|
|
25
27
|
},
|
|
26
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "1073084863774ca9497f28782d47abf8c44b3661"
|
|
27
29
|
}
|