-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support unplugin context (again) #1741
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const assert = require("assert"); | ||
|
||
const { parseBuildResult, trim, moduleReg } = require("../../../scripts/test-utils"); | ||
const { files } = parseBuildResult(__dirname); | ||
|
||
const content = files["index.js"]; | ||
assert.strictEqual(files['test.txt'], 'test'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": [ | ||
"./plugin" | ||
], | ||
"minify": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
module.exports = { | ||
async load(path) { | ||
path.endsWith('.hoo'); | ||
} | ||
Comment on lines
+3
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 未使用 在 if (path.endsWith('.hoo')) {
// 实现相应的加载逻辑
} |
||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||||||||||||
module.exports = [ | ||||||||||||||||||||
{ | ||||||||||||||||||||
async loadInclude(path) { | ||||||||||||||||||||
// this.warn('loadInclude: ' + path); | ||||||||||||||||||||
path.endsWith('.hoo'); | ||||||||||||||||||||
return true; | ||||||||||||||||||||
}, | ||||||||||||||||||||
Comment on lines
+3
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 修复 loadInclude 方法中的逻辑错误
建议修改为: async loadInclude(path) {
// this.warn('loadInclude: ' + path);
- path.endsWith('.hoo');
- return true;
+ return path.endsWith('.hoo');
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
async load(path) { | ||||||||||||||||||||
if (path.endsWith('.hoo')) { | ||||||||||||||||||||
this.warn('load: ' + path); | ||||||||||||||||||||
this.warn({ | ||||||||||||||||||||
message: 'test warn with object', | ||||||||||||||||||||
}); | ||||||||||||||||||||
this.error('error: ' + path); | ||||||||||||||||||||
this.emitFile({ | ||||||||||||||||||||
type: 'asset', | ||||||||||||||||||||
fileName: 'test.txt', | ||||||||||||||||||||
source: 'test', | ||||||||||||||||||||
}); | ||||||||||||||||||||
return { | ||||||||||||||||||||
content: `export default () => <Foooo>.hoo</Foooo>;`, | ||||||||||||||||||||
type: 'jsx', | ||||||||||||||||||||
}; | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
}, | ||||||||||||||||||||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// should be handled with load hook |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(require('./foo.hoo')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
改进错误和警告的处理机制
当前的
warn
和error
方法实现过于简单,建议: