Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
05275209
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05275209
编写于
8月 01, 2022
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(vue-cli-plugin-uni): update plugin-webpack5.js
上级
71d2bbd4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
4 deletion
+34
-4
packages/vue-cli-plugin-uni/packages/vue-loader/lib/plugin-webpack5.js
...cli-plugin-uni/packages/vue-loader/lib/plugin-webpack5.js
+34
-4
未找到文件。
packages/vue-cli-plugin-uni/packages/vue-loader/lib/plugin-webpack5.js
浏览文件 @
05275209
...
@@ -6,28 +6,48 @@ const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin
...
@@ -6,28 +6,48 @@ const BasicMatcherRulePlugin = require('webpack/lib/rules/BasicMatcherRulePlugin
const
RuleSetCompiler
=
require
(
'
webpack/lib/rules/RuleSetCompiler
'
)
const
RuleSetCompiler
=
require
(
'
webpack/lib/rules/RuleSetCompiler
'
)
const
UseEffectRulePlugin
=
require
(
'
webpack/lib/rules/UseEffectRulePlugin
'
)
const
UseEffectRulePlugin
=
require
(
'
webpack/lib/rules/UseEffectRulePlugin
'
)
const
objectMatcherRulePlugins
=
[]
try
{
const
ObjectMatcherRulePlugin
=
require
(
'
webpack/lib/rules/ObjectMatcherRulePlugin
'
)
objectMatcherRulePlugins
.
push
(
new
ObjectMatcherRulePlugin
(
'
assert
'
,
'
assertions
'
),
new
ObjectMatcherRulePlugin
(
'
descriptionData
'
)
)
}
catch
(
e
)
{
const
DescriptionDataMatcherRulePlugin
=
require
(
'
webpack/lib/rules/DescriptionDataMatcherRulePlugin
'
)
objectMatcherRulePlugins
.
push
(
new
DescriptionDataMatcherRulePlugin
())
}
const
ruleSetCompiler
=
new
RuleSetCompiler
([
const
ruleSetCompiler
=
new
RuleSetCompiler
([
new
BasicMatcherRulePlugin
(
'
test
'
,
'
resource
'
),
new
BasicMatcherRulePlugin
(
'
test
'
,
'
resource
'
),
new
BasicMatcherRulePlugin
(
'
mimetype
'
),
new
BasicMatcherRulePlugin
(
'
dependency
'
),
new
BasicMatcherRulePlugin
(
'
include
'
,
'
resource
'
),
new
BasicMatcherRulePlugin
(
'
include
'
,
'
resource
'
),
new
BasicMatcherRulePlugin
(
'
exclude
'
,
'
resource
'
,
true
),
new
BasicMatcherRulePlugin
(
'
exclude
'
,
'
resource
'
,
true
),
new
BasicMatcherRulePlugin
(
'
resource
'
),
new
BasicMatcherRulePlugin
(
'
conditions
'
),
new
BasicMatcherRulePlugin
(
'
conditions
'
),
new
BasicMatcherRulePlugin
(
'
resource
'
),
new
BasicMatcherRulePlugin
(
'
resourceQuery
'
),
new
BasicMatcherRulePlugin
(
'
resourceQuery
'
),
new
BasicMatcherRulePlugin
(
'
resourceFragment
'
),
new
BasicMatcherRulePlugin
(
'
realResource
'
),
new
BasicMatcherRulePlugin
(
'
realResource
'
),
new
BasicMatcherRulePlugin
(
'
issuer
'
),
new
BasicMatcherRulePlugin
(
'
issuer
'
),
new
BasicMatcherRulePlugin
(
'
compiler
'
),
new
BasicMatcherRulePlugin
(
'
compiler
'
),
...
objectMatcherRulePlugins
,
new
BasicEffectRulePlugin
(
'
type
'
),
new
BasicEffectRulePlugin
(
'
type
'
),
new
BasicEffectRulePlugin
(
'
sideEffects
'
),
new
BasicEffectRulePlugin
(
'
sideEffects
'
),
new
BasicEffectRulePlugin
(
'
parser
'
),
new
BasicEffectRulePlugin
(
'
parser
'
),
new
BasicEffectRulePlugin
(
'
resolve
'
),
new
BasicEffectRulePlugin
(
'
resolve
'
),
new
BasicEffectRulePlugin
(
'
generator
'
),
new
UseEffectRulePlugin
()
new
UseEffectRulePlugin
()
])
])
class
VueLoaderPlugin
{
class
VueLoaderPlugin
{
apply
(
compiler
)
{
apply
(
compiler
)
{
const
normalModule
=
compiler
.
webpack
?
compiler
.
webpack
.
NormalModule
:
require
(
'
webpack/lib/NormalModule
'
)
// add NS marker so that the loader can detect and report missing plugin
// add NS marker so that the loader can detect and report missing plugin
compiler
.
hooks
.
compilation
.
tap
(
id
,
compilation
=>
{
compiler
.
hooks
.
compilation
.
tap
(
id
,
compilation
=>
{
const
normalModuleLoader
=
require
(
'
webpack/lib/NormalModule
'
)
.
getCompilationHooks
(
compilation
).
loader
const
normalModuleLoader
=
normalModule
.
getCompilationHooks
(
compilation
).
loader
normalModuleLoader
.
tap
(
id
,
loaderContext
=>
{
normalModuleLoader
.
tap
(
id
,
loaderContext
=>
{
loaderContext
[
NS
]
=
true
loaderContext
[
NS
]
=
true
})
})
...
@@ -38,6 +58,10 @@ class VueLoaderPlugin {
...
@@ -38,6 +58,10 @@ class VueLoaderPlugin {
let
vueRules
=
[]
let
vueRules
=
[]
for
(
const
rawRule
of
rules
)
{
for
(
const
rawRule
of
rules
)
{
// skip rules with 'enforce'. eg. rule for eslint-loader
if
(
rawRule
.
enforce
)
{
continue
}
// skip the `include` check when locating the vue rule
// skip the `include` check when locating the vue rule
const
clonedRawRule
=
Object
.
assign
({},
rawRule
)
const
clonedRawRule
=
Object
.
assign
({},
rawRule
)
delete
clonedRawRule
.
include
delete
clonedRawRule
.
include
...
@@ -71,7 +95,7 @@ class VueLoaderPlugin {
...
@@ -71,7 +95,7 @@ class VueLoaderPlugin {
)
)
}
}
// get the normlized "use" for vue files
// get the norm
a
lized "use" for vue files
const
vueUse
=
vueRules
.
filter
(
rule
=>
rule
.
type
===
'
use
'
).
map
(
rule
=>
rule
.
value
)
const
vueUse
=
vueRules
.
filter
(
rule
=>
rule
.
type
===
'
use
'
).
map
(
rule
=>
rule
.
value
)
// get vue-loader options
// get vue-loader options
...
@@ -110,6 +134,7 @@ class VueLoaderPlugin {
...
@@ -110,6 +134,7 @@ class VueLoaderPlugin {
const
pitcher
=
{
const
pitcher
=
{
loader
:
require
.
resolve
(
'
./loaders/pitcher
'
),
loader
:
require
.
resolve
(
'
./loaders/pitcher
'
),
resourceQuery
:
query
=>
{
resourceQuery
:
query
=>
{
if
(
!
query
)
{
return
false
}
const
parsed
=
qs
.
parse
(
query
.
slice
(
1
))
const
parsed
=
qs
.
parse
(
query
.
slice
(
1
))
return
parsed
.
vue
!=
null
return
parsed
.
vue
!=
null
},
},
...
@@ -128,8 +153,9 @@ class VueLoaderPlugin {
...
@@ -128,8 +153,9 @@ class VueLoaderPlugin {
}
}
}
}
let
uid
=
0
function
cloneRule
(
rawRule
,
refs
)
{
function
cloneRule
(
rawRule
,
refs
)
{
const
rules
=
ruleSetCompiler
.
compileRules
(
'
ruleSet
'
,
[{
const
rules
=
ruleSetCompiler
.
compileRules
(
`clonedRuleSet-
${
++
uid
}
`
,
[{
rules
:
[
rawRule
]
rules
:
[
rawRule
]
}],
refs
)
}],
refs
)
let
currentResource
let
currentResource
...
@@ -182,6 +208,10 @@ function cloneRule (rawRule, refs) {
...
@@ -182,6 +208,10 @@ function cloneRule (rawRule, refs) {
delete
res
.
test
delete
res
.
test
if
(
rawRule
.
rules
)
{
res
.
rules
=
rawRule
.
rules
.
map
(
rule
=>
cloneRule
(
rule
,
refs
))
}
if
(
rawRule
.
oneOf
)
{
if
(
rawRule
.
oneOf
)
{
res
.
oneOf
=
rawRule
.
oneOf
.
map
(
rule
=>
cloneRule
(
rule
,
refs
))
res
.
oneOf
=
rawRule
.
oneOf
.
map
(
rule
=>
cloneRule
(
rule
,
refs
))
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录