Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
dbc1bc9d
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dbc1bc9d
编写于
1月 22, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build(deps): bump preprocess from 3.1.0 to 3.2.0
上级
7ab8af11
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
336 addition
and
412 deletion
+336
-412
packages/uni-cli-shared/lib/preprocess/lib/preprocess.js
packages/uni-cli-shared/lib/preprocess/lib/preprocess.js
+235
-307
packages/uni-cli-shared/lib/preprocess/lib/regexrules.js
packages/uni-cli-shared/lib/preprocess/lib/regexrules.js
+97
-101
packages/uni-cli-shared/lib/preprocess/package.json
packages/uni-cli-shared/lib/preprocess/package.json
+1
-1
packages/vite-plugin-uni/src/load/main.ts
packages/vite-plugin-uni/src/load/main.ts
+3
-3
未找到文件。
packages/uni-cli-shared/lib/preprocess/lib/preprocess.js
浏览文件 @
dbc1bc9d
...
...
@@ -7,58 +7,54 @@
* Licensed under the Apache 2.0 license.
*/
'
use strict
'
'
use strict
'
;
exports
.
preprocess
=
preprocess
exports
.
preprocessFile
=
preprocessFile
exports
.
preprocessFileSync
=
preprocessFileSync
exports
.
preprocess
=
preprocess
;
exports
.
preprocessFile
=
preprocessFile
;
exports
.
preprocessFileSync
=
preprocessFileSync
;
var
path
=
require
(
'
path
'
)
var
fs
=
require
(
'
fs
'
)
var
os
=
require
(
'
os
'
)
var
delim
=
require
(
'
./regexrules
'
)
var
XRegExp
=
require
(
'
xregexp
'
)
var
path
=
require
(
'
path
'
),
fs
=
require
(
'
fs
'
),
os
=
require
(
'
os
'
),
delim
=
require
(
'
./regexrules
'
),
XRegExp
=
require
(
'
xregexp
'
);
function
preprocessFile
(
srcFile
,
destFile
,
context
,
callback
,
options
)
{
options
=
getOptionsForFile
(
srcFile
,
options
)
context
.
src
=
srcFile
fs
.
readFile
(
srcFile
,
function
(
err
,
data
)
{
if
(
err
)
return
callback
(
err
,
data
)
var
parsed
=
preprocess
(
data
,
context
,
options
)
fs
.
writeFile
(
destFile
,
parsed
,
callback
)
})
options
=
getOptionsForFile
(
srcFile
,
options
)
;
context
.
src
=
srcFile
;
fs
.
readFile
(
srcFile
,
function
(
err
,
data
)
{
if
(
err
)
return
callback
(
err
,
data
)
;
var
parsed
=
preprocess
(
data
,
context
,
options
)
;
fs
.
writeFile
(
destFile
,
parsed
,
callback
)
;
})
;
}
function
preprocessFileSync
(
srcFile
,
destFile
,
context
,
options
)
{
options
=
getOptionsForFile
(
srcFile
,
options
)
context
.
src
=
srcFile
options
=
getOptionsForFile
(
srcFile
,
options
)
;
context
.
src
=
srcFile
;
var
data
=
fs
.
readFileSync
(
srcFile
)
var
parsed
=
preprocess
(
data
,
context
,
options
)
return
fs
.
writeFileSync
(
destFile
,
parsed
)
var
data
=
fs
.
readFileSync
(
srcFile
)
;
var
parsed
=
preprocess
(
data
,
context
,
options
)
;
return
fs
.
writeFileSync
(
destFile
,
parsed
)
;
}
function
getOptionsForFile
(
srcFile
,
options
)
{
options
=
options
||
{}
options
.
srcDir
=
options
.
srcDir
||
path
.
dirname
(
srcFile
)
options
.
type
=
options
.
type
||
getExtension
(
srcFile
)
options
=
options
||
{}
;
options
.
srcDir
=
options
.
srcDir
||
path
.
dirname
(
srcFile
)
;
options
.
type
=
options
.
type
||
getExtension
(
srcFile
)
;
return
options
return
options
;
}
function
getExtension
(
filename
)
{
var
ext
=
path
.
extname
(
filename
||
''
).
split
(
'
.
'
)
return
ext
[
ext
.
length
-
1
]
var
ext
=
path
.
extname
(
filename
||
''
).
split
(
'
.
'
);
return
ext
[
ext
.
length
-
1
]
;
}
function
preprocess
(
src
,
context
,
typeOrOptions
)
{
src
=
src
.
toString
()
context
=
context
||
process
.
env
src
=
src
.
toString
()
;
context
=
context
||
process
.
env
;
// default values
var
options
=
{
...
...
@@ -66,440 +62,372 @@ function preprocess(src, context, typeOrOptions) {
srcDir
:
process
.
cwd
(),
srcEol
:
getEolType
(
src
),
type
:
delim
[
'
html
'
]
}
}
;
// needed for backward compatibility with 2.x.x series
if
(
typeof
typeOrOptions
===
'
string
'
)
{
typeOrOptions
=
{
type
:
typeOrOptions
}
}
;
}
// needed for backward compatibility with 2.x.x series
if
(
typeof
context
.
srcDir
===
'
string
'
)
{
typeOrOptions
=
typeOrOptions
||
{}
typeOrOptions
.
srcDir
=
context
.
srcDir
if
(
typeof
context
.
srcDir
===
"
string
"
)
{
typeOrOptions
=
typeOrOptions
||
{}
;
typeOrOptions
.
srcDir
=
context
.
srcDir
;
}
if
(
typeOrOptions
&&
typeof
typeOrOptions
===
'
object
'
)
{
options
.
srcDir
=
typeOrOptions
.
srcDir
||
options
.
srcDir
options
.
fileNotFoundSilentFail
=
typeOrOptions
.
fileNotFoundSilentFail
||
options
.
fileNotFoundSilentFail
options
.
srcEol
=
typeOrOptions
.
srcEol
||
options
.
srcEol
options
.
type
=
delim
[
typeOrOptions
.
type
]
||
options
.
type
options
.
srcDir
=
typeOrOptions
.
srcDir
||
options
.
srcDir
;
options
.
fileNotFoundSilentFail
=
typeOrOptions
.
fileNotFoundSilentFail
||
options
.
fileNotFoundSilentFail
;
options
.
srcEol
=
typeOrOptions
.
srcEol
||
options
.
srcEol
;
options
.
type
=
delim
[
typeOrOptions
.
type
]
||
options
.
type
;
}
context
=
copy
(
context
)
context
=
copy
(
context
)
;
return
preprocessor
(
src
,
context
,
options
)
return
preprocessor
(
src
,
context
,
options
)
;
}
function
preprocessor
(
src
,
context
,
opts
,
noRestoreEol
)
{
src
=
normalizeEol
(
src
)
src
=
normalizeEol
(
src
)
;
var
rv
=
src
var
rv
=
src
;
rv
=
replace
(
rv
,
opts
.
type
.
include
,
processIncludeDirective
.
bind
(
null
,
false
,
context
,
opts
)
)
rv
=
replace
(
rv
,
opts
.
type
.
include
,
processIncludeDirective
.
bind
(
null
,
false
,
context
,
opts
));
if
(
opts
.
type
.
extend
)
{
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
extend
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
var
file
=
(
startMatches
[
1
]
||
''
).
trim
()
var
extendedContext
=
copy
(
context
)
var
extendedOpts
=
copy
(
opts
)
extendedContext
.
src
=
path
.
join
(
opts
.
srcDir
,
file
)
extendedOpts
.
srcDir
=
path
.
dirname
(
extendedContext
.
src
)
var
fileContents
=
getFileContents
(
extendedContext
.
src
,
opts
.
fileNotFoundSilentFail
,
context
.
src
)
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
extend
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
var
file
=
(
startMatches
[
1
]
||
''
).
trim
();
var
extendedContext
=
copy
(
context
);
var
extendedOpts
=
copy
(
opts
);
extendedContext
.
src
=
path
.
join
(
opts
.
srcDir
,
file
);
extendedOpts
.
srcDir
=
path
.
dirname
(
extendedContext
.
src
);
var
fileContents
=
getFileContents
(
extendedContext
.
src
,
opts
.
fileNotFoundSilentFail
,
context
.
src
);
if
(
fileContents
.
error
)
{
return
fileContents
.
contents
return
fileContents
.
contents
;
}
var
extendedSource
=
preprocessor
(
fileContents
.
contents
,
extendedContext
,
extendedOpts
,
true
).
trim
()
var
extendedSource
=
preprocessor
(
fileContents
.
contents
,
extendedContext
,
extendedOpts
,
true
).
trim
();
if
(
extendedSource
)
{
include
=
include
.
replace
(
/^
\n?
|
\n?
$/g
,
''
)
return
replace
(
extendedSource
,
opts
.
type
.
extendable
,
recurse
(
include
))
include
=
include
.
replace
(
/^
\n?
|
\n?
$/g
,
''
)
;
return
replace
(
extendedSource
,
opts
.
type
.
extendable
,
recurse
(
include
))
;
}
else
{
return
''
return
''
;
}
})
})
;
}
if
(
opts
.
type
.
foreach
)
{
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
foreach
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
var
variable
=
(
startMatches
[
1
]
||
''
).
trim
()
var
forParams
=
variable
.
split
(
'
'
)
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
foreach
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
var
variable
=
(
startMatches
[
1
]
||
''
).
trim
();
var
forParams
=
variable
.
split
(
'
'
);
if
(
forParams
.
length
===
3
)
{
var
contextVar
=
forParams
[
2
]
var
arrString
=
getDeepPropFromObj
(
context
,
contextVar
)
var
eachArr
var
contextVar
=
forParams
[
2
]
;
var
arrString
=
getDeepPropFromObj
(
context
,
contextVar
)
;
var
eachArr
;
if
(
arrString
.
match
(
/
\{(
.*
)\}
/
))
{
eachArr
=
JSON
.
parse
(
arrString
)
eachArr
=
JSON
.
parse
(
arrString
)
;
}
else
if
(
arrString
.
match
(
/
\[(
.*
)\]
/
))
{
eachArr
=
arrString
.
slice
(
1
,
-
1
)
eachArr
=
eachArr
.
split
(
'
,
'
)
eachArr
=
eachArr
.
map
(
function
(
arrEntry
)
{
return
arrEntry
.
replace
(
/
\s
*
([
'"
])(
.*
)\1\s
*/
,
'
$2
'
)
})
eachArr
=
arrString
.
slice
(
1
,
-
1
)
;
eachArr
=
eachArr
.
split
(
'
,
'
)
;
eachArr
=
eachArr
.
map
(
function
(
arrEntry
){
return
arrEntry
.
replace
(
/
\s
*
([
'"
])(
.*
)\1\s
*/
,
'
$2
'
)
;
})
;
}
else
{
eachArr
=
arrString
.
split
(
'
,
'
)
eachArr
=
arrString
.
split
(
'
,
'
)
;
}
var
replaceToken
=
new
RegExp
(
XRegExp
.
escape
(
forParams
[
0
]),
'
g
'
)
var
recursedInclude
=
recurse
(
include
)
var
replaceToken
=
new
RegExp
(
XRegExp
.
escape
(
forParams
[
0
]),
'
g
'
)
;
var
recursedInclude
=
recurse
(
include
)
;
return
Object
.
keys
(
eachArr
).
reduce
(
function
(
stringBuilder
,
arrKey
)
{
var
arrEntry
=
eachArr
[
arrKey
]
return
stringBuilder
+
recursedInclude
.
replace
(
replaceToken
,
arrEntry
)
},
''
)
return
Object
.
keys
(
eachArr
).
reduce
(
function
(
stringBuilder
,
arrKey
){
var
arrEntry
=
eachArr
[
arrKey
]
;
return
stringBuilder
+
recursedInclude
.
replace
(
replaceToken
,
arrEntry
)
;
},
''
)
;
}
else
{
return
''
return
''
;
}
})
})
;
}
if
(
opts
.
type
.
exclude
)
{
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
exclude
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
var
test
=
(
startMatches
[
1
]
||
''
).
trim
()
return
testPasses
(
test
,
context
)
?
''
:
recurse
(
include
)
})
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
exclude
,
function
(
startMatches
,
endMatches
,
include
,
recurse
){
var
test
=
(
startMatches
[
1
]
||
''
).
trim
();
return
testPasses
(
test
,
context
)
?
''
:
recurse
(
include
);
});
}
if
(
opts
.
type
.
if
)
{
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
if
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
var
variant
=
startMatches
[
1
]
var
test
=
(
startMatches
[
2
]
||
''
).
trim
()
switch
(
variant
)
{
rv
=
replaceRecursive
(
rv
,
opts
.
type
.
if
,
function
(
startMatches
,
endMatches
,
include
,
recurse
)
{
// I need to recurse first, so I don't catch "inner" else-directives
var
recursed
=
recurse
(
include
);
// look for the first else-directive
var
matches
=
opts
.
type
.
else
&&
recursed
.
match
(
new
RegExp
(
opts
.
type
.
else
));
var
match
=
(
matches
||
[
""
])[
0
];
var
index
=
match
?
recursed
.
indexOf
(
match
)
:
recursed
.
length
;
var
ifBlock
=
recursed
.
substring
(
0
,
index
);
var
elseBlock
=
recursed
.
substring
(
index
+
match
.
length
);
// empty string if no else-directive
var
variant
=
startMatches
[
1
];
var
test
=
(
startMatches
[
2
]
||
''
).
trim
();
// fixed by xxxxxx
var
startLine
=
padContent
(
startMatches
.
input
)
var
endLine
=
padContent
(
endMatches
.
input
)
switch
(
variant
)
{
case
'
if
'
:
case
'
ifdef
'
:
return
testPasses
(
test
,
context
)
?
padContent
(
startMatches
.
input
)
+
recurse
(
include
)
+
padContent
(
endMatches
.
input
)
:
padContent
(
startMatches
.
input
+
include
+
endMatches
.
input
)
case
'
ifdef
'
:
// fixed by xxxxxx
return
testPasses
(
test
,
context
)
?
(
startLine
+
ifBlock
+
endLine
)
:
(
startLine
+
padContent
(
ifBlock
)
+
padContent
(
match
||
''
)
+
elseBlock
+
endLine
);
case
'
ifndef
'
:
return
!
testPasses
(
test
,
context
)
?
padContent
(
startMatches
.
input
)
+
recurse
(
include
)
+
padContent
(
endMatches
.
input
)
:
padContent
(
startMatches
.
input
+
include
+
endMatches
.
input
)
// case 'ifdef':
// return typeof getDeepPropFromObj(context, test) !== 'undefined' ? (padContent(startMatches.input) + recurse(include) + padContent(endMatches.input)) : padContent(startMatches.input + include + endMatches.input) // fixed by xxxxxx
// case 'ifndef':
// return typeof getDeepPropFromObj(context, test) === 'undefined' ? (padContent(startMatches.input) + recurse(include) + padContent(endMatches.input)) : padContent(startMatches.input + include + endMatches.input) // fixed by xxxxxx
return
!
testPasses
(
test
,
context
)
?
(
startLine
+
ifBlock
+
endLine
)
:
(
startLine
+
padContent
(
ifBlock
)
+
padContent
(
match
||
''
)
+
elseBlock
+
endLine
);
// case 'ifdef':
// return typeof getDeepPropFromObj(context, test) !== 'undefined' ? ifBlock : elseBlock;
// case 'ifndef':
// return typeof getDeepPropFromObj(context, test) === 'undefined' ? ifBlock : elseBlock;
default
:
throw
new
Error
(
'
Unknown if variant
'
+
variant
+
'
.
'
)
throw
new
Error
(
'
Unknown if variant
'
+
variant
+
'
.
'
)
;
}
})
})
;
}
rv
=
replace
(
rv
,
opts
.
type
.
echo
,
function
(
match
,
variable
)
{
variable
=
(
variable
||
''
).
trim
()
rv
=
replace
(
rv
,
opts
.
type
.
echo
,
function
(
match
,
variable
)
{
variable
=
(
variable
||
''
).
trim
()
;
// if we are surrounded by quotes, echo as a string
var
stringMatch
=
variable
.
match
(
/^
([
'"
])(
.*
)\1
$/
)
if
(
stringMatch
)
return
stringMatch
[
2
]
return
getDeepPropFromObj
(
context
,
(
variable
||
''
).
trim
())
})
rv
=
replace
(
rv
,
opts
.
type
.
exec
,
function
(
match
,
name
,
value
)
{
name
=
(
name
||
''
).
trim
()
value
=
value
||
''
var
params
=
value
.
split
(
'
,
'
)
var
stringRegex
=
/^
[
'"
](
.*
)[
'"
]
$/
params
=
params
.
map
(
function
(
param
)
{
param
=
param
.
trim
()
if
(
stringRegex
.
test
(
param
))
{
// handle string parameter
return
param
.
replace
(
stringRegex
,
'
$1
'
)
}
else
{
// handle variable parameter
return
getDeepPropFromObj
(
context
,
param
)
var
stringMatch
=
variable
.
match
(
/^
([
'"
])(
.*
)\1
$/
);
if
(
stringMatch
)
return
stringMatch
[
2
];
var
arrString
=
getDeepPropFromObj
(
context
,
variable
);
return
typeof
arrString
!==
'
undefined
'
?
arrString
:
''
;
});
rv
=
replace
(
rv
,
opts
.
type
.
exec
,
function
(
match
,
name
,
value
)
{
name
=
(
name
||
''
).
trim
();
value
=
value
||
''
;
var
params
=
value
.
split
(
'
,
'
);
var
stringRegex
=
/^
[
'"
](
.*
)[
'"
]
$/
;
params
=
params
.
map
(
function
(
param
){
param
=
param
.
trim
();
if
(
stringRegex
.
test
(
param
))
{
// handle string parameter
return
param
.
replace
(
stringRegex
,
'
$1
'
);
}
else
{
// handle variable parameter
return
getDeepPropFromObj
(
context
,
param
);
}
})
})
;
var
fn
=
getDeepPropFromObj
(
context
,
name
)
if
(
!
fn
||
typeof
fn
!==
'
function
'
)
return
''
var
fn
=
getDeepPropFromObj
(
context
,
name
)
;
if
(
!
fn
||
typeof
fn
!==
'
function
'
)
return
''
;
return
fn
.
apply
(
context
,
params
)
})
return
fn
.
apply
(
context
,
params
)
;
})
;
rv
=
replace
(
rv
,
opts
.
type
[
'
include-static
'
],
processIncludeDirective
.
bind
(
null
,
true
,
context
,
opts
)
)
rv
=
replace
(
rv
,
opts
.
type
[
'
include-static
'
],
processIncludeDirective
.
bind
(
null
,
true
,
context
,
opts
));
if
(
!
noRestoreEol
)
{
rv
=
restoreEol
(
rv
,
opts
.
srcEol
)
rv
=
restoreEol
(
rv
,
opts
.
srcEol
)
;
}
return
rv
}
var
splitRE
=
/
\r?\n
/g
function
padContent
(
content
)
{
return
Array
(
content
.
split
(
splitRE
).
length
).
join
(
'
\n
'
)
return
rv
;
}
function
getEolType
(
source
)
{
var
eol
var
foundEolTypeCnt
=
0
var
eol
;
var
foundEolTypeCnt
=
0
;
if
(
source
.
indexOf
(
'
\r\n
'
)
>=
0
)
{
eol
=
'
\r\n
'
foundEolTypeCnt
++
eol
=
'
\r\n
'
;
foundEolTypeCnt
++
;
}
if
(
/
\r[^\n]
/
.
test
(
source
))
{
eol
=
'
\r
'
foundEolTypeCnt
++
eol
=
'
\r
'
;
foundEolTypeCnt
++
;
}
if
(
/
[^\r]\n
/
.
test
(
source
))
{
eol
=
'
\n
'
foundEolTypeCnt
++
eol
=
'
\n
'
;
foundEolTypeCnt
++
;
}
if
(
eol
==
null
||
foundEolTypeCnt
>
1
)
{
eol
=
os
.
EOL
eol
=
os
.
EOL
;
}
return
eol
return
eol
;
}
function
normalizeEol
(
source
,
indent
)
{
// only process any kind of EOL if indentation has to be added, otherwise replace only non \n EOLs
if
(
indent
)
{
source
=
source
.
replace
(
/
(?:\r?\n)
|
\r
/g
,
'
\n
'
+
indent
)
source
=
source
.
replace
(
/
(?:\r?\n)
|
\r
/g
,
'
\n
'
+
indent
)
;
}
else
{
source
=
source
.
replace
(
/
(?:\r\n)
|
\r
/g
,
'
\n
'
)
source
=
source
.
replace
(
/
(?:\r\n)
|
\r
/g
,
'
\n
'
)
;
}
return
source
return
source
;
}
function
restoreEol
(
normalizedSource
,
originalEol
)
{
if
(
originalEol
!==
'
\n
'
)
{
normalizedSource
=
normalizedSource
.
replace
(
/
\n
/g
,
originalEol
)
normalizedSource
=
normalizedSource
.
replace
(
/
\n
/g
,
originalEol
)
;
}
return
normalizedSource
return
normalizedSource
;
}
function
replace
(
rv
,
rule
,
processor
)
{
var
isRegex
=
typeof
rule
===
'
string
'
||
rule
instanceof
RegExp
var
isArray
=
Array
.
isArray
(
rule
)
var
isRegex
=
typeof
rule
===
'
string
'
||
rule
instanceof
RegExp
;
var
isArray
=
Array
.
isArray
(
rule
)
;
if
(
isRegex
)
{
rule
=
[
new
RegExp
(
rule
,
'
gmi
'
)]
rule
=
[
new
RegExp
(
rule
,
'
gmi
'
)];
}
else
if
(
isArray
)
{
rule
=
rule
.
map
(
function
(
subRule
)
{
return
new
RegExp
(
subRule
,
'
gmi
'
)
})
rule
=
rule
.
map
(
function
(
subRule
){
return
new
RegExp
(
subRule
,
'
gmi
'
);
})
;
}
else
{
throw
new
Error
(
'
Rule must be a String, a RegExp, or an Array.
'
)
throw
new
Error
(
'
Rule must be a String, a RegExp, or an Array.
'
)
;
}
return
rule
.
reduce
(
function
(
rv
,
rule
)
{
return
rv
.
replace
(
rule
,
processor
)
},
rv
)
return
rule
.
reduce
(
function
(
rv
,
rule
){
return
rv
.
replace
(
rule
,
processor
)
;
},
rv
)
;
}
function
replaceRecursive
(
rv
,
rule
,
processor
)
{
if
(
!
rule
.
start
||
!
rule
.
end
)
{
throw
new
Error
(
'
Recursive rule must have start and end.
'
)
if
(
!
rule
.
start
||
!
rule
.
end
)
{
throw
new
Error
(
'
Recursive rule must have start and end.
'
)
;
}
var
startRegex
=
new
RegExp
(
rule
.
start
,
'
mi
'
)
var
endRegex
=
new
RegExp
(
rule
.
end
,
'
mi
'
)
var
startRegex
=
new
RegExp
(
rule
.
start
,
'
mi
'
)
;
var
endRegex
=
new
RegExp
(
rule
.
end
,
'
mi
'
)
;
function
matchReplacePass
(
content
)
{
var
matches
=
XRegExp
.
matchRecursive
(
content
,
rule
.
start
,
rule
.
end
,
'
gmi
'
,
{
valueNames
:
[
'
between
'
,
'
left
'
,
'
match
'
,
'
right
'
]
})
})
;
var
matchGroup
=
{
left
:
null
,
match
:
null
,
right
:
null
}
}
;
return
matches
.
reduce
(
function
(
builder
,
match
)
{
switch
(
match
.
name
)
{
return
matches
.
reduce
(
function
(
builder
,
match
)
{
switch
(
match
.
name
)
{
case
'
between
'
:
builder
+=
match
.
value
break
builder
+=
match
.
value
;
break
;
case
'
left
'
:
matchGroup
.
left
=
startRegex
.
exec
(
match
.
value
)
break
matchGroup
.
left
=
startRegex
.
exec
(
match
.
value
)
;
break
;
case
'
match
'
:
matchGroup
.
match
=
match
.
value
break
matchGroup
.
match
=
match
.
value
;
break
;
case
'
right
'
:
matchGroup
.
right
=
endRegex
.
exec
(
match
.
value
)
builder
+=
processor
(
matchGroup
.
left
,
matchGroup
.
right
,
matchGroup
.
match
,
matchReplacePass
)
break
matchGroup
.
right
=
endRegex
.
exec
(
match
.
value
);
builder
+=
processor
(
matchGroup
.
left
,
matchGroup
.
right
,
matchGroup
.
match
,
matchReplacePass
);
break
;
}
return
builder
},
''
)
return
builder
;
},
''
)
;
}
return
matchReplacePass
(
rv
)
return
matchReplacePass
(
rv
)
;
}
function
processIncludeDirective
(
isStatic
,
context
,
opts
,
match
,
linePrefix
,
file
)
{
file
=
(
file
||
''
).
trim
()
var
indent
=
linePrefix
.
replace
(
/
\S
/g
,
'
'
)
var
includedContext
=
copy
(
context
)
var
includedOpts
=
copy
(
opts
)
includedContext
.
src
=
path
.
join
(
opts
.
srcDir
,
file
)
includedOpts
.
srcDir
=
path
.
dirname
(
includedContext
.
src
)
var
fileContents
=
getFileContents
(
includedContext
.
src
,
opts
.
fileNotFoundSilentFail
,
context
.
src
)
function
processIncludeDirective
(
isStatic
,
context
,
opts
,
match
,
linePrefix
,
file
)
{
file
=
(
file
||
''
).
trim
();
var
indent
=
linePrefix
.
replace
(
/
\S
/g
,
'
'
);
var
includedContext
=
copy
(
context
);
var
includedOpts
=
copy
(
opts
);
includedContext
.
src
=
path
.
join
(
opts
.
srcDir
,
file
);
includedOpts
.
srcDir
=
path
.
dirname
(
includedContext
.
src
);
var
fileContents
=
getFileContents
(
includedContext
.
src
,
opts
.
fileNotFoundSilentFail
,
context
.
src
);
if
(
fileContents
.
error
)
{
return
linePrefix
+
fileContents
.
contents
return
linePrefix
+
fileContents
.
contents
;
}
var
includedSource
=
fileContents
.
contents
var
includedSource
=
fileContents
.
contents
;
if
(
isStatic
)
{
includedSource
=
fileContents
.
contents
includedSource
=
fileContents
.
contents
;
}
else
{
includedSource
=
preprocessor
(
fileContents
.
contents
,
includedContext
,
includedOpts
,
true
)
includedSource
=
preprocessor
(
fileContents
.
contents
,
includedContext
,
includedOpts
,
true
);
}
includedSource
=
normalizeEol
(
includedSource
,
indent
)
includedSource
=
normalizeEol
(
includedSource
,
indent
)
;
if
(
includedSource
)
{
return
linePrefix
+
includedSource
return
linePrefix
+
includedSource
;
}
else
{
return
linePrefix
return
linePrefix
;
}
}
function
getTestTemplate
(
test
)
{
/*
jshint evil:true
*/
test
=
test
||
'
true
'
test
=
test
.
trim
()
/*
jshint evil:true
*/
test
=
test
||
'
true
'
;
test
=
test
.
trim
()
;
// force single equals replacement
test
=
test
.
replace
(
/
([^
=!
])
=
([^
=
])
/g
,
'
$1==$2
'
)
//fixed by xxxxxx
test
=
test
.
replace
(
/
([^
=!
])
=
([^
=
])
/g
,
'
$1==$2
'
)
;
//
fixed by xxxxxx
test
=
test
.
replace
(
/-/g
,
'
_
'
)
/* eslint-disable no-new-func */
return
new
Function
(
'
context
'
,
'
with (context||{}){ return (
'
+
test
+
'
); }
'
)
return
new
Function
(
"
context
"
,
"
with (context||{}){ return (
"
+
test
+
"
); }
"
);
}
function
testPasses
(
test
,
context
)
{
var
testFn
=
getTestTemplate
(
test
)
try
{
return
testFn
(
context
,
getDeepPropFromObj
)
}
catch
(
e
)
{}
return
false
function
testPasses
(
test
,
context
)
{
var
testFn
=
getTestTemplate
(
test
);
return
testFn
(
context
,
getDeepPropFromObj
);
}
function
getFileContents
(
path
,
failSilent
,
requesterPath
)
{
try
{
fs
.
statSync
(
path
)
fs
.
statSync
(
path
)
;
}
catch
(
e
)
{
if
(
failSilent
)
{
return
{
error
:
true
,
contents
:
path
+
'
not found!
'
}
return
{
error
:
true
,
contents
:
path
+
'
not found!
'
};
}
else
{
var
errMsg
=
path
errMsg
=
requesterPath
?
errMsg
+
'
requested from
'
+
requesterPath
:
errMsg
errMsg
+=
'
not found!
'
throw
new
Error
(
errMsg
)
var
errMsg
=
path
;
errMsg
=
requesterPath
?
errMsg
+
'
requested from
'
+
requesterPath
:
errMsg
;
errMsg
+=
'
not found!
'
;
throw
new
Error
(
errMsg
);
}
}
return
{
error
:
false
,
contents
:
fs
.
readFileSync
(
path
).
toString
()
}
return
{
error
:
false
,
contents
:
fs
.
readFileSync
(
path
).
toString
()};
}
function
copy
(
obj
)
{
return
Object
.
keys
(
obj
).
reduce
(
function
(
copyObj
,
objKey
)
{
copyObj
[
objKey
]
=
obj
[
objKey
]
return
copyObj
},
{})
return
Object
.
keys
(
obj
).
reduce
(
function
(
copyObj
,
objKey
)
{
copyObj
[
objKey
]
=
obj
[
objKey
]
;
return
copyObj
;
},
{})
;
}
function
getDeepPropFromObj
(
obj
,
propPath
)
{
propPath
.
replace
(
/
\[([^\]
+?
])\]
/g
,
'
.$1
'
)
propPath
=
propPath
.
split
(
'
.
'
)
propPath
.
replace
(
/
\[([^\]
+?
])\]
/g
,
'
.$1
'
)
;
propPath
=
propPath
.
split
(
'
.
'
)
;
// fast path, no need to loop if structurePath contains only a single segment
if
(
propPath
.
length
===
1
)
{
return
obj
[
propPath
[
0
]]
return
obj
[
propPath
[
0
]]
;
}
// loop only as long as possible (no exceptions for null/undefined property access)
propPath
.
some
(
function
(
pathSegment
)
{
obj
=
obj
[
pathSegment
]
return
obj
==
null
})
propPath
.
some
(
function
(
pathSegment
)
{
obj
=
obj
[
pathSegment
]
;
return
(
obj
==
null
);
})
;
return
obj
return
obj
;
}
// fixed by xxxxxx
const
splitRE
=
/
\r?\n
/g
function
padContent
(
content
)
{
return
Array
(
content
.
split
(
splitRE
).
length
).
join
(
'
\n
'
)
}
\ No newline at end of file
packages/uni-cli-shared/lib/preprocess/lib/regexrules.js
浏览文件 @
dbc1bc9d
module
.
exports
=
{
simple
:
{
echo
:
'
^#echo[
\t
]+(.*?)[
\t
]*$
'
,
exec
:
'
^#exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*$
'
,
include
:
'
^(.*)#include(?!-)[
\t
]+(.*?)[
\t
]*$
'
,
// allow prefix characters to specify the indent level of included file
'
include-static
'
:
'
^(.*)#include-static[
\t
]+(.*?)[
\t
]*$
'
simple
:
{
echo
:
"
^#echo[
\t
]+(.*?)[
\t
]*$
"
,
exec
:
"
^#exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*$
"
,
include
:
"
^(.*)#include(?!-)[
\t
]+(.*?)[
\t
]*$
"
,
// allow prefix characters to specify the indent level of included file
'
include-static
'
:
"
^(.*)#include-static[
\t
]+(.*?)[
\t
]*$
"
},
html
:
{
echo
:
'
<!--[
\t
]*#echo[
\t
]+(.*?)[
\t
]*(?:-->|!>)
'
,
exec
:
'
<!--[
\t
]*#exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*(?:-->|!>)
'
,
include
:
'
(.*)<!--[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*(?:-->|!>)
'
,
'
include-static
'
:
'
(.*)<!--[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*(?:-->|!>)
'
,
exclude
:
{
start
:
'
[
\t
]*<!--[
\t
]*#exclude(?:[
\t
]+(.*?))?[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*<!--[
\t
]*#endexclude[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
'
html
:
{
echo
:
"
<!--[
\t
]*#echo[
\t
]+(.*?)[
\t
]*(?:-->|!>)
"
,
exec
:
"
<!--[
\t
]*#exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*(?:-->|!>)
"
,
include
:
"
(.*)<!--[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*(?:-->|!>)
"
,
'
include-static
'
:
"
(.*)<!--[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*(?:-->|!>)
"
,
exclude
:
{
start
:
"
[
\t
]*<!--[
\t
]*#exclude(?:[
\t
]+(.*?))?[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*<!--[
\t
]*#endexclude[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
"
},
extend
:
{
start
:
'
[
\t
]*<!--[
\t
]*#extend(?!able)[
\t
]+(.*?)[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*<!--[
\t
]*#endextend[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
'
extend
:
{
start
:
"
[
\t
]*<!--[
\t
]*#extend(?!able)[
\t
]+(.*?)[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*<!--[
\t
]*#endextend[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
"
},
extendable
:
'
<!--[
\t
]*#extendable[
\t
]*(?:-->|!>)
'
,
if
:
{
start
:
'
[
\t
]*<!--[
\t
]*#(ifndef|ifdef|if)[
\t
]+(.*?)[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*<!(?:--)?[
\t
]*#endif[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
'
extendable
:
"
<!--[
\t
]*#extendable[
\t
]*(?:-->|!>)
"
,
if
:
{
start
:
"
[
\t
]*<!--[
\t
]*#(ifndef|ifdef|if)[
\t
]+(.*?)[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*<!(?:--)?[
\t
]*#endif[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
"
},
foreach
:
{
start
:
'
[
\t
]*<!--[
\t
]*#foreach[
\t
]+(.*?)[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*<!(?:--)?[
\t
]*#endfor[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
'
else
:
"
[
\t
]*<!(?:--)?[
\t
]*#else[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
"
,
foreach
:
{
start
:
"
[
\t
]*<!--[
\t
]*#foreach[
\t
]+(.*?)[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*<!(?:--)?[
\t
]*#endfor[
\t
]*(?:-->|!>)(?:[
\t
]*
\n
)?
"
}
},
js
:
{
echo
:
[
'
/
\\
*[
\t
]*#echo[
\t
]+(.*?)[
\t
]*
\\
*(?:
\\
*|/)
'
,
'
//[
\t
]*#echo[
\t
]+(.*?)[
\t
]*$
'
js
:
{
echo
:
[
"
/
\\
*[
\t
]*#echo[
\t
]+(.*?)[
\t
]*
\\
*(?:
\\
*|/)
"
,
"
//[
\t
]*#echo[
\t
]+(.*?)[
\t
]*$
"
],
exec
:
'
(?://|/
\\
*)[
\t
]*#exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*(?:
\\
*(?:
\\
*|/))?
'
,
include
:
[
'
^(.*)/
\\
*[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*
\\
*(?:
\\
*|/)
'
,
'
^(.*)//[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*$
'
exec
:
"
(?://|/
\\
*)[
\t
]*#exec[
\t
]+(
\\
S+?)[
\t
]*
\\
((.*)
\\
)[
\t
]*(?:
\\
*(?:
\\
*|/))?
"
,
include
:
[
"
^(.*)/
\\
*[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*
\\
*(?:
\\
*|/)
"
,
"
^(.*)//[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*$
"
],
'
include-static
'
:
[
'
^(.*)/
\\
*[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*
\\
*(?:
\\
*|/)
'
,
'
^(.*)//[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*$
'
"
^(.*)/
\\
*[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*
\\
*(?:
\\
*|/)
"
,
"
^(.*)//[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*$
"
],
exclude
:
{
start
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#exclude(?:[
\t
]+([^
\n
*]*))?[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#endexclude[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
'
exclude
:
{
start
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#exclude(?:[
\t
]+([^
\n
*]*))?[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#endexclude[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
"
},
extend
:
{
start
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#extend(?!able)[
\t
]+([^
\n
*]*)(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#endextend[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
'
extend
:
{
start
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#extend(?!able)[
\t
]+([^
\n
*]*)(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#endextend[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
"
},
extendable
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#extendable[
\t
]*(?:
\\
*/)?
'
,
if
:
{
start
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#(ifndef|ifdef|if)[
\t
]+([^
\n
*]*)(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#endif[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
'
extendable
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#extendable[
\t
]*(?:
\\
*/)?
"
,
if
:
{
start
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#(ifndef|ifdef|if)[
\t
]+([^
\n
*]*)(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#endif[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
"
},
foreach
:
{
start
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#foreach[
\t
]+([^
\n
*]*)(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
'
,
end
:
'
[
\t
]*(?://|/
\\
*)[
\t
]*#endfor[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
'
else
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#else[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
"
,
foreach
:
{
start
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#foreach[
\t
]+([^
\n
*]*)(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
+)?
"
,
end
:
"
[
\t
]*(?://|/
\\
*)[
\t
]*#endfor[
\t
]*(?:
\\
*(?:
\\
*|/))?(?:[
\t
]*
\n
)?
"
}
},
coffee
:
{
echo
:
'
#+[
\t
]*@echo[
\t
]+(.*?)[
\t
]*$
'
,
exec
:
'
#+[
\t
]*@exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*$
'
,
include
:
'
^(.*?)#+[
\t
]*@include(?!-)[
\t
]+(.*?)[
\t
]*$
'
,
'
include-static
'
:
'
^(.*?)#+[
\t
]*@include-static[
\t
]+(.*?)[
\t
]*$
'
,
exclude
:
{
start
:
'
^[
\t
]*#+[
\t
]*@exclude(?:[
\t
]+(.*?))?[
\t
]*
\n
+
'
,
end
:
'
^[
\t
]*#+[
\t
]*@endexclude[
\t
]*
\n
?
'
coffee
:
{
echo
:
[
"
###+[
\t
]*#echo[
\t
]+(.*?)[
\t
]###
"
,
"
#+[
\t
]*#echo[
\t
]+(.*?)[
\t
]*$
"
],
exec
:
"
#+[
\t
]*#exec[
\t
]+(
\\
S+)[
\t
]*
\\
((.*)
\\
)[
\t
]*$
"
,
include
:
"
^(.*?)#+[
\t
]*#include(?!-)[
\t
]+(.*?)[
\t
]*$
"
,
'
include-static
'
:
"
^(.*?)#+[
\t
]*#include-static[
\t
]+(.*?)[
\t
]*$
"
,
exclude
:
{
start
:
"
^[
\t
]*#+[
\t
]*#exclude(?:[
\t
]+(.*?))?[
\t
]*
\n
+
"
,
end
:
"
^[
\t
]*#+[
\t
]*#endexclude[
\t
]*
\n
?
"
},
extend
:
{
start
:
'
^[
\t
]*#+[
\t
]*@extend(?!able)[
\t
]+(.*?)
\n
+
'
,
end
:
'
^[
\t
]*#+[
\t
]*@endextend[
\t
]*
\n
?
'
extend
:
{
start
:
"
^[
\t
]*#+[
\t
]*#extend(?!able)[
\t
]+(.*?)
\n
+
"
,
end
:
"
^[
\t
]*#+[
\t
]*#endextend[
\t
]*
\n
?
"
},
extendable
:
'
^[
\t
]*#+[
\t
]*@extendable[
\t
]*$
'
,
if
:
{
start
:
'
^[
\t
]*#+[
\t
]*@(ifndef|ifdef|if)[
\t
]+(.*?)[
\t
]*
\n
+
'
,
end
:
'
^[
\t
]*#+[
\t
]*@endif[
\t
]*
\n
?
'
extendable
:
"
^[
\t
]*#+[
\t
]*#extendable[
\t
]*$
"
,
if
:
{
start
:
"
^[
\t
]*#+[
\t
]*#(ifndef|ifdef|if)[
\t
]+(.*?)[
\t
]*
\n
+
"
,
end
:
"
^[
\t
]*#+[
\t
]*#endif[
\t
]*
\n
?
"
},
foreach
:
{
start
:
'
^[
\t
]*#+[
\t
]*@foreach[
\t
]+(.*?)[
\t
]*
\n
+
'
,
end
:
'
^[
\t
]*#+[
\t
]*@endfor[
\t
]*
\n
?
'
else
:
"
^[
\t
]*#+[
\t
]*#else[
\t
]*
\n
?
"
,
foreach
:
{
start
:
"
^[
\t
]*#+[
\t
]*#foreach[
\t
]+(.*?)[
\t
]*
\n
+
"
,
end
:
"
^[
\t
]*#+[
\t
]*#endfor[
\t
]*
\n
?
"
}
}
}
}
;
module
.
exports
.
xml
=
module
.
exports
.
html
module
.
exports
.
xml
=
module
.
exports
.
html
;
module
.
exports
.
javascript
=
module
.
exports
.
js
module
.
exports
.
jsx
=
module
.
exports
.
js
module
.
exports
.
c
=
module
.
exports
.
js
module
.
exports
.
cc
=
module
.
exports
.
js
module
.
exports
.
cpp
=
module
.
exports
.
js
module
.
exports
.
cs
=
module
.
exports
.
js
module
.
exports
.
csharp
=
module
.
exports
.
js
module
.
exports
.
java
=
module
.
exports
.
js
module
.
exports
.
less
=
module
.
exports
.
js
module
.
exports
.
sass
=
module
.
exports
.
js
module
.
exports
.
scss
=
module
.
exports
.
js
module
.
exports
.
css
=
module
.
exports
.
js
module
.
exports
.
php
=
module
.
exports
.
js
module
.
exports
.
ts
=
module
.
exports
.
js
module
.
exports
.
tsx
=
module
.
exports
.
js
module
.
exports
.
peg
=
module
.
exports
.
js
module
.
exports
.
pegjs
=
module
.
exports
.
js
module
.
exports
.
jade
=
module
.
exports
.
js
module
.
exports
.
styl
=
module
.
exports
.
js
module
.
exports
.
go
=
module
.
exports
.
js
module
.
exports
.
javascript
=
module
.
exports
.
js
;
module
.
exports
.
jsx
=
module
.
exports
.
js
;
module
.
exports
.
json
=
module
.
exports
.
js
;
module
.
exports
.
c
=
module
.
exports
.
js
;
module
.
exports
.
cc
=
module
.
exports
.
js
;
module
.
exports
.
cpp
=
module
.
exports
.
js
;
module
.
exports
.
cs
=
module
.
exports
.
js
;
module
.
exports
.
csharp
=
module
.
exports
.
js
;
module
.
exports
.
java
=
module
.
exports
.
js
;
module
.
exports
.
less
=
module
.
exports
.
js
;
module
.
exports
.
sass
=
module
.
exports
.
js
;
module
.
exports
.
scss
=
module
.
exports
.
js
;
module
.
exports
.
css
=
module
.
exports
.
js
;
module
.
exports
.
php
=
module
.
exports
.
js
;
module
.
exports
.
ts
=
module
.
exports
.
js
;
module
.
exports
.
tsx
=
module
.
exports
.
js
;
module
.
exports
.
peg
=
module
.
exports
.
js
;
module
.
exports
.
pegjs
=
module
.
exports
.
js
;
module
.
exports
.
jade
=
module
.
exports
.
js
;
module
.
exports
.
styl
=
module
.
exports
.
js
;
module
.
exports
.
go
=
module
.
exports
.
js
;
module
.
exports
.
bash
=
module
.
exports
.
coffee
module
.
exports
.
shell
=
module
.
exports
.
coffee
module
.
exports
.
sh
=
module
.
exports
.
coffee
module
.
exports
.
bash
=
module
.
exports
.
coffee
;
module
.
exports
.
shell
=
module
.
exports
.
coffee
;
module
.
exports
.
sh
=
module
.
exports
.
coffee
;
packages/uni-cli-shared/lib/preprocess/package.json
浏览文件 @
dbc1bc9d
{
"name"
:
"preprocess"
,
"description"
:
"Preprocess directives in HTML, JavaScript, etc directives based off variable context"
,
"version"
:
"3.
1
.0"
,
"version"
:
"3.
2
.0"
,
"homepage"
:
"https://github.com/jsoverson/preprocess"
,
"author"
:
{
"name"
:
"Jarrod Overson"
,
...
...
packages/vite-plugin-uni/src/load/main.ts
浏览文件 @
dbc1bc9d
...
...
@@ -19,8 +19,8 @@ export const main = {
if
(
!
pagesJsPath
)
{
pagesJsPath
=
slash
(
path
.
resolve
(
options
.
inputDir
,
'
pages.json.js
'
))
}
return
`import '
${
pagesJsPath
}
';
${
fs
.
readFileSync
(
filename
,
'
utf-8
'
).
toString
()}
`
return
`import '
${
pagesJsPath
}
';
${
fs
.
readFileSync
(
filename
,
'
utf-8
'
)
.
toString
()}
`
},
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录