Skip to content

Commit

Permalink
Merge pull request jd-opensource#279 from jardenliu/dev
Browse files Browse the repository at this point in the history
docs: update docs for loader "info" argument
  • Loading branch information
bailicangdu authored Feb 13, 2022
2 parents b76fcd2 + 462b5c3 commit 815b541
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/zh-cn/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ start (options?: {
// 可选,传递给loader的配置项
options?: unknown,
// 必填,js处理函数,必须返回code值
loader?: (code: string, url: string, options: unknown) => string
loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
}>

// 子应用插件
Expand All @@ -61,7 +61,7 @@ start (options?: {
// 可选,传递给loader的配置项
options?: unknown,
// 必填,js处理函数,必须返回code值
loader?: (code: string, url: string, options: unknown) => string
loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
}>
}
},
Expand Down
10 changes: 5 additions & 5 deletions docs/zh-cn/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ microApp.start({
// 可选,传递给loader的配置项
options?: any,
// 必填,js处理函数,必须返回code值
loader?: (code: string, url: string, options: any) => code
loader?: (code: string, url: string, options: any, info: sourceScriptInfo) => code
}>

// 子应用插件
Expand All @@ -34,7 +34,7 @@ microApp.start({
// 可选,传递给loader的配置项
options?: any,
// 必填,js处理函数,必须返回code值
loader?: (code: string, url: string, options: any) => code
loader?: (code: string, url: string, options: any, info: sourceScriptInfo) => code
}>
}
}
Expand All @@ -52,15 +52,15 @@ microApp.start({
scopeProperties: ['key', 'key', ...], // 可选
escapeProperties: ['key', 'key', ...], // 可选
options: 配置项, // 可选
loader(code, url, options) { // 必填
loader(code, url, options, info) { // 必填
console.log('全局插件')
return code
}
}
],
modules: {
'appName1': [{
loader(code, url, options) {
loader(code, url, options, info) {
if (url === 'xxx.js') {
code = code.replace('var abc =', 'window.abc =')
}
Expand All @@ -71,7 +71,7 @@ microApp.start({
scopeProperties: ['key', 'key', ...], // 可选
escapeProperties: ['key', 'key', ...], // 可选
options: 配置项, // 可选
loader(code, url, options) { // 必填
loader(code, url, options, info) { // 必填
console.log('只适用于appName2的插件')
return code
}
Expand Down

0 comments on commit 815b541

Please sign in to comment.