-
Notifications
You must be signed in to change notification settings - Fork 108
feat: add resolve_id plugin hook #1625
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
Conversation
Walkthrough此拉取请求引入了对多个结构体的修改,主要涉及 Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (11)
e2e/fixtures/plugins/expect.js (1)
11-13: 新断言看起来不错!新添加的断言正确地验证了
resolve_id钩子的功能。这与 PR 的目标一致。建议添加一个简短的注释来解释这个新断言的目的。例如:
// resolve_id hook +// 验证 resolve_id 钩子是否正确实现 assert(content.includes(`resolve_id mocked`), `resolve_id hook works`);这将有助于其他开发人员更好地理解测试的意图。
e2e/fixtures/plugins/plugins.config.js (1)
24-30: 新的resolveId方法实现看起来不错,但有一个小建议。这个新方法很好地实现了
resolve_id插件钩子的功能。它正确地处理了特定的模块解析,并为其他情况返回 null。不过,有一个小建议:
考虑在生产环境中移除或条件化
console.log语句。您可以使用环境变量来控制日志输出,例如:async resolveId(source, importer) { if (source === 'resolve_id') { - console.log('resolveId', source, importer); + if (process.env.NODE_ENV !== 'production') { + console.log('resolveId', source, importer); + } return { id: require('path').join(__dirname, 'resolve_id_mock.js') }; } return null; }这样可以在开发时保留有用的日志,同时避免在生产环境中输出不必要的信息。
crates/mako/src/lib.rs (1)
Line range hint
1-56: 文件总结此更改将
resolve模块的可见性从私有改为公共,这是实现新的resolve_id插件钩子的必要步骤。这个修改与 PR 的目标一致,并且可能会影响其他模块对resolve模块的访问。请确保这个更改不会破坏现有的模块封装或导致意外的副作用。建议在实现新功能时,仔细考虑模块的可见性,以确保正确的封装和最小特权原则。
packages/mako/binding.d.ts (2)
54-54: 新增的 resolveId 方法符合预期,建议添加注释新增的
resolveId方法符合 PR 的目标,即添加resolve_id插件钩子。方法签名看起来合适,返回类型与新添加的ResolveIdResult接口匹配。为了提高代码的可读性和可维护性,建议为该方法添加简短的 JSDoc 注释,解释其用途和参数含义。例如:
/** * 解析给定源和导入者的标识符 * @param source 要解析的源 * @param importer 导入者的上下文 * @returns 包含解析后标识符的 Promise */ resolveId?: (source: string, importer: string) => Promise<{ id: string }>;
64-66: 新增的 ResolveIdResult 接口结构合理,建议添加注释新增的
ResolveIdResult接口结构简单明了,与JsHooks中resolveId方法的返回类型相匹配。这种设计有助于提高代码的类型安全性和可读性。为了进一步提高代码的可读性和可维护性,建议为该接口添加简短的 JSDoc 注释,解释其用途。例如:
/** * 表示解析标识符的结果 */ export interface ResolveIdResult { /** * 解析后的标识符 */ id: string; }crates/mako/src/resolve/resolution.rs (2)
16-16: 修改重复的文档注释以准确描述方法功能
path方法和into_path_buf方法的文档注释都是“返回不包含查询和片段的路径”,但两者的行为不同。建议修改注释,以清晰区分两者的功能。修改建议:
/// 返回不包含查询和片段的路径 pub fn path(&self) -> &Path { &self.path } - /// 返回不包含查询和片段的路径 + /// 消耗自身,返回路径的所有权,不包含查询和片段 pub fn into_path_buf(self) -> PathBuf { self.path }Also applies to: 21-21
54-63: 在Debug实现中提供更多有用信息当前
Debug实现中,只显示了package_json的路径信息。为了调试的完整性,可能需要包含PackageJson的其他关键信息,或明确指出当package_json为None时的情况。crates/binding/src/js_plugin.rs (1)
52-73: 建议为resolve_id方法添加文档注释为了提高代码的可维护性和可读性,建议为
resolve_id方法添加相应的文档注释,解释其功能、参数和返回值。应用以下差异以添加文档注释:
+ /// 解析模块标识符。 fn resolve_id( &self, source: &str, importer: &str, _context: &Arc<Context>, ) -> Result<Option<ResolverResource>> {crates/mako/src/plugin.rs (3)
56-63: 建议为新增方法添加文档注释为了提高代码的可读性和维护性,建议为
resolve_id方法添加文档注释,说明其作用和使用方式。
255-268: 建议为新增方法添加文档注释为了提高代码的可读性和维护性,建议为
resolve_id方法添加文档注释,说明其功能和预期行为。
56-63: 建议为新增的resolve_id方法编写单元测试为了确保新添加的
resolve_id方法在各种情况下都能正常工作,建议为其编写相应的单元测试,覆盖不同的输入场景和边界条件。Also applies to: 255-268
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (12)
- crates/binding/src/js_hook.rs (3 hunks)
- crates/binding/src/js_plugin.rs (3 hunks)
- crates/mako/src/lib.rs (1 hunks)
- crates/mako/src/plugin.rs (2 hunks)
- crates/mako/src/resolve.rs (3 hunks)
- crates/mako/src/resolve/resolution.rs (1 hunks)
- crates/mako/src/resolve/resource.rs (1 hunks)
- e2e/fixtures/plugins/expect.js (1 hunks)
- e2e/fixtures/plugins/plugins.config.js (1 hunks)
- e2e/fixtures/plugins/resolve_id_mock.js (1 hunks)
- e2e/fixtures/plugins/src/index.tsx (1 hunks)
- packages/mako/binding.d.ts (2 hunks)
✅ Files skipped from review due to trivial changes (2)
- e2e/fixtures/plugins/resolve_id_mock.js
- e2e/fixtures/plugins/src/index.tsx
🧰 Additional context used
🔇 Additional comments (12)
crates/mako/src/lib.rs (1)
18-18: 将resolve模块设为公共可见这个更改使
resolve模块对外部模块可见。这与 PR 目标中提到的新增resolve_id插件钩子相符。请运行以下脚本以验证
resolve模块的使用:✅ Verification successful
已验证
resolve模块的可见性更改该更改成功将
resolve模块设为公共可见,并且没有发现任何外部使用情况。🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:验证 `resolve` 模块的使用情况 # 测试:搜索 `resolve` 模块的使用。预期:找到新的外部使用情况。 rg --type rust "use (crate|super)::resolve"Length of output: 1432
crates/mako/src/resolve/resource.rs (1)
3-3: 导入更改看起来没有问题,但需要进一步验证这个更改将
Resolution类型的导入从外部 crate 改为本地模块,这看起来是个合理的改动。然而,我们需要确保:
- 新的本地
Resolution类型与之前的实现完全兼容。- 代码库中其他使用
oxc_resolver::Resolution的地方都已更新。- 如果
Resolution类型的实现有任何变化,相关文档已经更新。请运行以下脚本来验证更改的影响:
packages/mako/binding.d.ts (1)
Line range hint
54-66: 总体评价:变更符合预期且集成良好这些修改很好地实现了 PR 的目标,即添加
resolve_id插件钩子。新增的resolveId方法和ResolveIdResult接口为插件系统提供了一种清晰的机制来参与标识符解析过程。这些变更与现有代码库的结构和类型定义保持一致,不会破坏现有功能。总的来说,这些更改增强了插件系统的灵活性,允许更精细的控制over标识符解析过程。建议在合并这些更改之前,确保更新相关文档,以反映这个新的插件钩子。
crates/mako/src/resolve/resolution.rs (1)
41-51: 验证full_path方法在不同平台下的正确性在
full_path方法中,通过将query和fragment直接使用path.push附加到路径上。请确认这种方式在所有平台(尤其是Windows和Unix系统)下都能正确拼接路径,避免出现路径格式错误。您可以考虑在不同平台上运行测试,或使用路径处理库来确保跨平台兼容性。
crates/binding/src/js_plugin.rs (1)
52-73: 新增的resolve_id方法实现正确该方法正确地调用了
resolve_id钩子函数,并正确处理了返回值,逻辑清晰,符合预期。crates/binding/src/js_hook.rs (4)
61-62: 在 JsHooks 结构体中添加 resolve_id 字段新增的
resolve_id字段,以及对应的 TypeScript 类型声明,符合预期,实现合理。
69-69: 在 TsFnHooks 结构体中添加 resolve_id 字段新增的
resolve_id字段,类型为Option<ThreadsafeFunction<(String, String), Option<ResolveIdResult>>>,与 JsHooks 中的定义保持一致,实现合理。
85-87: 在 TsFnHooks::new 方法中正确初始化 resolve_id 字段对
resolve_id字段的初始化方式与其他钩子函数一致,实现合理。
109-112: 新增 ResolveIdResult 结构体定义了新的结构体
ResolveIdResult,包含一个id: String字段,标记为可为空对象,符合预期。crates/mako/src/resolve.rs (3)
13-13: 确认新模块的引入和导出在第13行引入了新的模块
mod resolution;,并在第15行通过pub use resolution::Resolution;公开了Resolution。这确保了其他模块可以访问和使用Resolution结构体。Also applies to: 15-15
257-262: 确保Resolution结构体的字段正确赋值在第257-262行,将
resolution转换为新的Resolution结构体。请确保以下字段正确赋值:
package_json: 使用cloned()方法克隆可能的package_json,以确保所有权正确。path: 调用into_path_buf()将路径转换为PathBuf类型。query和fragment: 使用map方法并调用to_string(),以处理可能存在的查询和片段部分。
55-60: 检查resolve_id方法的错误处理在第55-60行,添加了对插件驱动的
resolve_id方法的调用,并使用?操作符处理可能的错误。如果resolve_id返回错误,整个resolve函数将提前返回错误。请确认这种错误传播方式符合预期,或者是否需要在此处进行错误捕获和处理以增强鲁棒性。为验证
resolve_id方法的错误处理方式,请运行以下脚本查看其定义:✅ Verification successful
继续检查
resolve_id方法的错误处理为了进一步确认
resolve_id方法的错误传播方式,请运行以下脚本以获取其实现细节:
确认
resolve_id方法的错误处理符合预期所有
resolve_id方法均通过?操作符传播错误,符合预期的错误处理方式。🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:查找 `resolve_id` 方法的定义以确认错误处理方式 # 测试:搜索插件驱动中 `resolve_id` 方法的定义。期望:找到方法定义的位置。 rg --type rust 'fn resolve_id\(' -A 5Length of output: 1025
Script:
# #!/bin/bash # 描述:提取 `resolve_id` 方法的实现以检查错误处理逻辑 rg --type rust 'fn resolve_id\(' -A 20Length of output: 3535
| #[derive(Clone)] | ||
| pub struct Resolution { | ||
| pub path: PathBuf, | ||
| pub query: Option<String>, | ||
| pub fragment: Option<String>, | ||
| pub package_json: Option<Arc<PackageJson>>, | ||
| } |
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
建议将结构体字段设为私有以增强封装性
当前,Resolution结构体的所有字段都声明为pub,这可能会暴露内部实现细节。建议将这些字段设为私有,并提供公有的访问方法(getter),以保持封装性和灵活性。
| /// Returns serialized package_json | ||
| pub fn package_json(&self) -> Option<&Arc<PackageJson>> { | ||
| self.package_json.as_ref() | ||
| } |
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.
更新方法注释以反映实际返回值
package_json方法的注释为“返回序列化的package_json”,但实际上返回的是PackageJson的引用。为了避免误导,建议修改注释以准确描述方法的返回值。
修改建议:
- /// 返回序列化的package_json
+ /// 返回与路径关联的`PackageJson`引用(如果存在)
pub fn package_json(&self) -> Option<&Arc<PackageJson>> {
self.package_json.as_ref()
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Returns serialized package_json | |
| pub fn package_json(&self) -> Option<&Arc<PackageJson>> { | |
| self.package_json.as_ref() | |
| } | |
| /// 返回与路径关联的`PackageJson`引用(如果存在) | |
| pub fn package_json(&self) -> Option<&Arc<PackageJson>> { | |
| self.package_json.as_ref() | |
| } |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1625 +/- ##
==========================================
- Coverage 61.98% 61.97% -0.02%
==========================================
Files 154 155 +1
Lines 15414 15467 +53
==========================================
+ Hits 9554 9585 +31
- Misses 5860 5882 +22 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
docs/config.md (3)
547-547: 新增的 resolveId 钩子函数看起来不错resolveId 钩子函数的添加与 PR 的目标一致,为插件系统提供了解析模块标识符的能力。这是一个有用的补充。
建议:
- 考虑为 resolveId 函数添加更详细的说明,解释其用途和使用场景。
- 可以提供一个简单的示例,展示如何在插件中使用这个新的钩子函数。
Line range hint
1037-1062: 关于别名配置的新增说明非常有帮助这些新增的说明很好地解释了如何正确使用别名功能,有助于防止用户犯常见错误。
建议:
- 考虑将这两个注意事项合并成一个列表,以提高可读性。
- 可以添加一个正确配置的完整示例,展示如何同时避免这两个问题。
Line range hint
1-1236: 配置文档整体结构清晰,内容全面这份配置文档提供了 Mako 的全面配置指南,结构清晰,解释详细,对用户非常有帮助。新增的内容与现有文档风格一致,很好地融入了整体结构。
建议:
- 考虑在文档开头添加一个目录或快速导航,方便用户快速找到所需的配置项。
- 可以考虑为一些较复杂的配置项添加更多实际应用场景的示例。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- docs/config.md (1 hunks)
- docs/config.zh-CN.md (1 hunks)
👮 Files not reviewed due to content moderation or server errors (1)
- docs/config.zh-CN.md
🧰 Additional context used
| path: PathBuf::from(x.id), | ||
| query: None, | ||
| fragment: None, | ||
| package_json: None, |
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.
需要支持下 package json 的内容的传递,以保证需要使用报名的场景 or package.json 中 side effects
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (7)
e2e/fixtures/plugins/plugins.config.js (1)
22-34: 新的 resolveId 方法实现看起来不错,但请考虑在生产环境中移除日志记录。resolveId 方法的实现符合预期,正确处理了 'resolve_id' 和 'resolve_id_external' 两种情况。使用
require('path').join构建文件路径是个好做法。然而,在第 25 行的 console.log 可能会在生产环境中造成不必要的日志输出。建议在生产环境中移除或禁用 console.log 语句。您可以考虑使用条件语句来控制日志输出,例如:
if (process.env.NODE_ENV !== 'production') { console.log('resolveId', source, importer); }这样可以确保在开发过程中保留有用的调试信息,同时避免在生产环境中产生不必要的日志。
crates/binding/src/js_hook.rs (3)
61-62: 新增的 resolve_id 钩子函数符合预期这个新增的
resolve_id字段很好地实现了 PR 的目标。它的类型定义和其他钩子保持一致,使用Option<JsFunction>允许该钩子是可选的。TypeScript 类型注解也正确地描述了预期的函数签名。建议为这个新字段添加一个简短的文档注释,解释其用途和预期行为。例如:
/// 解析给定源和导入者的标识符。 #[napi(ts_type = "(source: string, importer: string) => Promise<{ id: string }>;")] pub resolve_id: Option<JsFunction>,
69-69: TsFnHooks 中的 resolve_id 字段实现正确新增的
resolve_id字段在TsFnHooks结构体中的实现是正确的。它使用了ThreadsafeFunction,与结构体中的其他字段保持一致,确保了并发访问的安全性。输入和输出类型的定义也符合预期的功能。建议为这个新字段添加一个简短的文档注释,解释其用途和与
JsHooks中对应字段的关系。例如:/// 对应于 JsHooks 中的 resolve_id 字段的线程安全版本。 pub resolve_id: Option<ThreadsafeFunction<(String, String), Option<ResolveIdResult>>>,
109-113: ResolveIdResult 结构体定义合理新增的
ResolveIdResult结构体很好地封装了resolve_id操作的结果。id字段为必需项,而external字段为可选项,这种设计提供了足够的灵活性。使用#[napi(object, use_nullable = true)]注解也确保了与 JavaScript 表示的兼容性。建议添加一些文档注释来解释这个结构体的用途和字段的含义。例如:
/// 表示 resolve_id 操作的结果。 #[napi(object, use_nullable = true)] pub struct ResolveIdResult { /// 解析后的标识符。 pub id: String, /// 可选字段,指示解析的标识符是否为外部资源。 pub external: Option<bool>, }此外,考虑使用
#[must_use]属性来提醒调用者不要忽略这个结构体的实例。docs/config.md (3)
547-547: 新增的 resolveId 钩子函数看起来不错新增的
resolveId钩子函数很好地补充了插件系统的功能,允许开发者自定义模块标识符的解析过程。这与 PR 的目标相符,即引入新的resolve_id插件钩子。建议为
resolveId钩子函数添加一个简短的示例,以帮助用户更好地理解其用法。例如:resolveId: async (id: string, importer: string) => { if (id === 'virtual-module') { return { id: '/absolute/path/to/module.js', external: false }; } return null; // 返回 null 表示使用默认解析 }
Line range hint
1022-1046: 解析配置说明的补充很有帮助新增的两条注意事项为用户提供了重要的配置指导,有助于防止常见的别名配置错误。这些补充说明非常有价值。
为了提高可读性,建议将这两条注意事项格式化为一个列表。例如:
注意: 1. 如果要为目录设置别名,请不要添加 `/*` 后缀,我们目前不支持这种方式。 2. 如果要为本地路径设置别名,请确保添加 `./` 前缀。否则,它将被视为依赖模块。 例如: ```diff { resolve: { alias: [ - ["@/src/*", "./src/*"], + [ "@/src", "./src"], - ["@/src", "src"], + ["@/src", "./src"], ], }, }这样的格式更容易阅读和理解。 --- Line range hint `1-1137`: **文档的整体更新非常全面和有价值** 这次更新大大提高了 Mako 配置文档的质量和完整性。新增的内容和现有结构保持一致,同时提供了更多的细节和澄清。这对用户理解和正确配置 Mako 非常有帮助。 为了保持文档风格的一致性,建议检查所有配置项的描述格式。例如,确保每个配置项都有类型、默认值和简短描述。可以考虑使用表格或统一的列表格式来呈现这些信息,这样可以让文档更易于浏览和查找特定信息。 此外,可以考虑在文档开头添加一个目录,列出所有主要配置项,并提供快速跳转链接。这将帮助用户更快地找到他们需要的特定配置信息。 </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** <details> <summary>📥 Commits</summary> Files that changed from the base of the PR and between b133fa32f8314b9df3365c37a319c0706c73532c and fd5afd137ee28c4a3142666e5423dea3d5b488c3. </details> <details> <summary>📒 Files selected for processing (8)</summary> * crates/binding/src/js_hook.rs (3 hunks) * crates/binding/src/js_plugin.rs (3 hunks) * docs/config.md (1 hunks) * docs/config.zh-CN.md (1 hunks) * e2e/fixtures/plugins/expect.js (1 hunks) * e2e/fixtures/plugins/plugins.config.js (1 hunks) * e2e/fixtures/plugins/src/index.tsx (1 hunks) * packages/mako/binding.d.ts (2 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (4)</summary> * crates/binding/src/js_plugin.rs * e2e/fixtures/plugins/expect.js * e2e/fixtures/plugins/src/index.tsx * packages/mako/binding.d.ts </details> <details> <summary>🧰 Additional context used</summary> </details> <details> <summary>🔇 Additional comments (7)</summary><blockquote> <details> <summary>docs/config.zh-CN.md (7)</summary><blockquote> `547-550`: **新增配置项:emitDecoratorMetadata** 这是一个有用的新增配置项,允许用户控制是否输出装饰器元数据。 建议添加一个简短的说明,解释这个选项的用途,例如: "此选项用于启用TypeScript装饰器元数据的输出,对于使用反射或依赖注入框架的项目特别有用。" --- Line range hint `552-555`: **新增配置项:emotion** 这是一个很好的新增配置项,为使用Emotion的项目提供了支持。 建议添加一个简短的说明,解释Emotion是什么,例如: "Emotion是一个流行的CSS-in-JS库,启用此选项可以在项目中使用Emotion的样式方案。" --- Line range hint `557-576`: **新增实验性配置项:experimental.detectLoop** 这是一个非常有用的新增实验性功能,可以帮助开发者检测项目中的依赖循环。 建议: 1. 在配置项描述的开头更明显地标注这是一个实验性功能,例如: "【实验性功能】用于检测依赖循环的配置。" 2. 添加一个简短的说明,解释依赖循环检测的重要性,例如: "依赖循环可能导致意外的行为和性能问题,及时发现和解决它们对于维护健康的代码库很重要。" 3. 考虑添加一个使用示例,说明如何解释生成的graphviz文件。 --- Line range hint `578-590`: **新增实验性配置项:experimental.requireContext** 这个新增的实验性配置项提供了对`require.context`功能的控制,这是一个很好的灵活性增强。 建议: 1. 在配置项描述的开头更明显地标注这是一个实验性功能。 2. 提供更多关于`require.context`功能的背景信息,例如: "require.context是一个用于模块动态导入的webpack特性,它允许您创建一个上下文,从而实现按需导入文件。" 3. 解释为什么默认启用这个功能,以及禁用它可能带来的影响。 4. 考虑添加一个使用示例,展示如何在项目中利用这个功能。 --- Line range hint `592-605`: **新增实验性配置项:experimental.webpackSyntaxValidate** 这个新增的实验性配置项为使用webpack语法的包提供了一个白名单机制,这是一个有趣的功能。 建议: 1. 在配置项描述的开头更明显地标注这是一个实验性功能。 2. 提供更多关于webpack语法的背景信息,例如: "webpack语法包括特定的导入语句、魔法注释等,这些在非webpack环境中可能不被支持。" 3. 解释使用这个选项的潜在影响和风险,例如: "允许使用webpack语法可能会影响项目的可移植性和与其他构建工具的兼容性。" 4. 考虑添加一个使用示例,展示如何正确配置这个选项。 --- `547-547`: **更新的配置项:plugins.resolveId** 在plugins配置中新增的`resolveId`钩子函数是一个强大的扩展点,可以让插件参与模块解析过程。 建议: 1. 提供更多关于`resolveId`钩子的使用场景和目的,例如: "此钩子允许插件自定义模块解析逻辑,对于处理别名、虚拟模块或特殊的导入路径特别有用。" 2. 解释返回值中`external`属性的作用,例如: "当`external`为true时,表示该模块应被视为外部依赖,不应被打包。" 3. 考虑添加一个简单的使用示例,展示如何在插件中实现这个钩子函数。 --- Line range hint `1009-1013`: **更新的配置项:publicPath** 关于运行时设置`publicPath`的说明是一个很好的补充,提高了配置的灵活性。 建议: 1. 提供一个简短的代码示例,展示如何在运行时使用`__mako_public_path__`,例如: ```javascript // 在应用的入口文件中 __mako_public_path__ = process.env.PUBLIC_PATH;
- 解释为什么同时支持
__mako_public_path__和__webpack_public_path__,例如:
"为了保持与webpack项目的兼容性,我们同时支持这两种设置方式。"- 提醒用户在使用运行时设置时可能需要注意的事项,如确保在加载任何资源之前设置
publicPath。
* fix: env_replacer should not replace user defined variable in scope (#1577) * fix: env_replacer should not replace user defined variable in scope * test: add test cases for env_replacer * chore: code style * release: @umijs/mako@0.8.11 * chore: bundler-mako@0.8.11 * docs: add changelog for v0.8.11 * fix(tree-shaking): detect export var side effects (#1579) * test: ✅ add a failure test * fix: 🐛 add is pure detection in export var decl * fix: bad output when chunk_loading_global containing quotation mark (#1582) * chore: ➕ add a subdot cli tool script (#1585) * fix(win): copy don't work under windows (#1587) * fix(win): module id should be win_pathed (#1588) * feat(tree-shaking): optimize import namespace used all exports to partial used of source modules (#1584) * test: ✅ add failure test case * feat: ✨ add collect prop explicit field * feat: ✨ collect explicit member prop access to optizmize used export in dep module replace USE ALL export to partial used exports * fix: dedestructuring before collect ExplicitProps * test: ✅ add back trace env var * test: ✅ update test case * fix: 🐛 add globals and helpers --------- Co-authored-by: Jinbao1001 <nodewebli@gmail.com> * fix: merge mako config (#1578) * fix: merge mako config * fix: merge mako config * fix:clear deps should not panic when module not found (#1581) * fix:clear deps should not panic when module not found * chore: use tracing warn * fix: delete log * Revert "fix: merge mako config (#1578)" (#1589) This reverts commit c08821d. * fix: watch too many file error (#1550) * fix: watch too many file error * chore: delete print * chore: delete log * release: @umijs/mako@0.8.8-rc.1 * fix: conflict * feat: support numeric module Id (#1561) * feat: moduleIdStrategy support numberous * fix: typos * fix: typos * fix: change name * fix: typos * release: @umijs/mako@0.8.12 * chore: fix typo and doc (#1591) * fix: chunk_loading_global (#1590) * fix: bad entry output when chunk_loading_global containing singe quote * test: add test cases for chunk_loading_global * docs: update * chore: update lock * chore: remove useless dependencies (#1595) * refactor: 🔥 rm ci warn logs (#1596) * fix: devServer put static serve proxy after umi proxy middleware (#1558) * fix: fix umi load html file failed, * test: add umi devServer test case * fix: typo * fix: hmr on hyper-static-file error * fix: import expect.mjs error on github workflow. * fix: import expect.mjs error on github workflow. * fix: 🐛 expect for error case * fix: 🐛 dev.hmr dont stop * fix: 🐛 add OKAM env * fix: 🐛 wait for mako server * fix: 🐛 kill by children process * test: ✅ add umi.css * refactor: 🎨 unify expect file * feat: export killMakoDevServer from test-hmr.mjs, make it public for all test case * test: ✅ unify expect file * chore: ➕ use express-http-proxy for static proxy * feat: ✨ better mako static proxy * test: ✅ support umi dev test with local mako * chore: ⬆️ update pnpm-lock * chore: 🎨 * fix: 🐛 ignore children process killed error --------- Co-authored-by: huanyu.why <huanyu.why@antgroup.com> Co-authored-by: pshu <pishu.spf@antfin.com> * fix(tree-shaking): object spread transform should go before deconstructing (#1598) * fix: 🐛 deconstructing needs object spread transform first * test: ✅ add guardian syntax * release: @umijs/mako@0.8.13-canary.20240918.1 * chore: bundler-mako@0.8.13-canary.20240918.1 * chore: 🎨 thread name after mako (#1601) * refactor: 🎨 rayon is not friendly to js users * chore: ✏️ rename tokio worker with mako * revert: import namespace optimize (#1606) * Revert "fix(tree-shaking): object spread transform should go before deconstructing (#1598)" This reverts commit 9434d99. * Revert "feat(tree-shaking): optimize import namespace used all exports to partial used of source modules (#1584)" This reverts commit 81a52f8. * chore: 🔧 update mako clean script * release: @umijs/mako@0.8.13 * chore: bundler-mako@0.8.13 * docs: change log 0923 (#1607) * docs: 📝 change log * docs: 📝 change log 0923 * chore: ✏️ * fix: 🐛 turn off express-http-proxy's keep alive (#1612) * fix: 🐛 turn off express-http-proxy's keep alive * refactor: 🔥 remove timeout config * release: @umijs/mako@0.8.14 * chore: bundler-mako@0.8.14 * refactor: napi threadsafe function (#1608) * refactor: napi threadsafe function * chore: update binding typings * refactor: code pieces * fix: catch napi tsfn promise rejection * chore: update binding typings * docs: 📝 change log 20240925 (#1613) * feat: disable webp to base64 (#1602) * feat: init * fix: context * fix: no use * fix: typos * fix: typos * fix: typos * fix: typos * fix(bundler-mako): experimental config should be merged deeply (#1617) * refactor: config codes organization (#1618) * refactor: config codes organization * fix: typos * refactor: config parse error * fix: clickToComponent don't work (#1620) * fix: duplicate_package_checker panic when no package.json is supplied (#1621) * fix: file_stem index out of bound (#1623) * feat: add resolve_id plugin hook (#1625) * feat: add resolve_id plugin hook * chore: update docs * feat: add external * release: @umijs/mako@0.8.15 * chore: bundler-mako@0.8.15 * docs: changelog for 0.8.15 * chore: update the release instruction (#1627) * refactor: code-splitting config (#1629) * feat: add loadInclude plugin hook (#1630) * feat: add { isEntry } for resolve_id plugin hook (#1631) * feat/upgrade swc (#1444) * 🚧 * 🚧 a basic working version * chore: 🚨 lint happy * refactor: 🎨 adjust to new swc * refactor: 🎨 remove deprecated methods * chore: 🚨 lint happy * feat: ✨ update swc emotion * chore: 🔧 remove useless profile in sub crate * chore: 🔧 add back emotion plugin * refactor: 🎨 add back merge source map * test: ✅ hot update js file served by hyper static, it use text/javascript * chore: 🔧 lock update * chore: 🔧 clean up swc core feature * refactor: 🎨 fix breaking change of ctxt of span * fix: 🐛 ctxt apply mark * refactor: 🎨 use DUMMY CTXT instead of SyntaxContext::empty() * chore: ⬆️ temperal use mdxjs from kdy branch * feat: ✨ re-enable mdxjs * feat: ✨ swc_core 0.100.1 * chore: 🙈 ignore fmt in fixtures * chore: 🚨 lint happy * chore: ⬆️ swc_common * chore: ✏️ typo * release: @umijs/mako@0.8.1-canary.20240812.1 * chore: bundler-mako@0.8.1-canary.20240812.1 * chore: ⬆️ swc_core 0.100.6 * release: @umijs/mako@0.8.1-canary.20240814.2 * chore: bundler-mako@0.8.1-canary.20240814.2 * chore: 🚨 lint happy * chore: 🔧 CI build bindings * chore: 🔧 fix build docker * refactor: 🔥 remove aarch64-unknown-linux-gnu * chore: 🔧 create tar * chore: 🙈 * release: @umijs/mako@0.8.3-canary.20240820.1 * chore: bundler-mako@0.8.3-canary.20240820.1 * chore: 🔧 wrong donwload param * chore: 🔧 upload download actions should be same version * chore: 🔧 try codecov in ci * refactor: 🔥 remove unnecessary target * refactor: 🎨 use swc comments * fix: 🐛 after upgrade to swc_core it should remove paren before minifiy * refactor: 🎨 move dummy ctxt defintion to ast mod * chore: 🚨 lint happy * release: @umijs/mako@0.8.8-canary.20240902.1 * chore: bundler-mako@0.8.8-canary.20240902.1 * release: @umijs/mako@0.8.8-canary.20240903.3 * chore: bundler-mako@0.8.8-canary.20240903.3 * refactor: 🎨 use VisitMut + Fold code style * chore: ⬆️ update pnpm-lock * chore: 🙈 * revert: ⏪ delete musl bindin * release: @umijs/mako@0.8.9-canary.20240909.1 * chore: bundler-mako@0.8.9-canary.20240909.1 * release: @umijs/mako@0.8.11-canary.20240910.1 * chore: bundler-mako@0.8.11-canary.20240910.1 * fix: 🐛 use chars() instead of bytes() * fix: 🐛 unescape html entity by html escape crate * release: @umijs/mako@0.8.14-canary.20240924.1 * chore: bundler-mako@0.8.14-canary.20240924.1 * release: @umijs/mako@0.8.15-canary.20240927.1 * chore: bundler-mako@0.8.15-canary.20240927.1 * fix: hash not stable (&revert import * as optimize) (#1610) * Revert "revert: import namespace optimize (#1606)" This reverts commit a485358. * fix: hash not stable * fix: deps sort not stable * fix: deps sort not stable * fix: deps sort not stable * fix: delete binding * fix: var name * chore: iter to into * fix: format * release: @umijs/mako@0.9.0 * chore: bundler-mako@0.9.0 * docs: 📝 changelog 0.9.0 * fix: duplicate_package_checker panic when package.json has no version field (#1634) * feat: magic comment chunk name (#1628) * refactor: code-splitting config * feat: support magic comment chunk name basically * fix: magic comment chunk name for webworker * refactor: use ImportOptions to represent option from magic comments * fix: dep replacer when magic comments chunk name existed * test: update test cases for magic comments chunk name * fix: dep replacer when dynamic import depencies is missing * chore: remove useless codes * refactor: code styles * docs: add todo for ChunkId * test: fix visitors::dynamic_import::tests::test_dynamic_import * test: fix test::hmr * fix: dep replacer when dynamic import css modules or moduleIdStrategy is hashed * chore: remove meaning less changes * test: enable magic comment chunk name in fixtures/umi * docs: add docs for magic comment chunk name * feat: support webpackIgnore and makoIgnore magic comment (#1636) * feat: support webpackIgnore and makoIgnore magic comment * chore: fmt * chore: rename magic_comment_chunk_name to magic_comment * chore: fix typo * feat: add transform plugin hook (#1637) * feat: add transform plugin hook * docs: add docs * chore: fmt * chore: perf * feat: add transformInclude plugin hook (#1639) * feat: add transformInclude plugin hook * chore: fmt * Fix: import namespace optimize panic with nested for of stmt (#1640) * test: ✅ add import namespace optimize panic test case * fix: 🐛 fix nested for of stmt panic * release: @umijs/mako@0.9.2-canary.20241016.1 * chore: bundler-mako@0.9.2-canary.20241016.1 * release: @umijs/mako@0.9.2 * chore: bundler-mako@0.9.2 * docs: 📝 changelog 0.9.2 * feat: add buildEnd plugin hook (#1644) * feat: add enforce plugin hook (#1646) * feat: add enforce plugin hook * chore: code style * chore: code style * chore: fix lint * chore: 🎨 add missing binding type * release: @umijs/mako@0.9.3-canary.20241016.1 * chore: bundler-mako@0.9.3-canary.20241016.1 * feat: add writeBundle plugin hook (#1650) * feat: add watch_changes plugin hook (#1651) * feat: add watch_changes plugin hook * chore: fix lint * chore: fix ts define * fix: mako on windows don't work (#1652) * fix: devtool sourcemap explosion in windows (#1653) * chore: remove dead code * fix: should not re-group when span changed (#1654) * fix: umd should be import as cjs (#1642) * fix: umd should be import as cjs * refactor: 🎨 just short circuit typeof define to prevent define takes effect * revert: ⏪ binding.d.ts --------- Co-authored-by: pshu <pishu.spf@antfin.com> * fix: 🐛 add process.env.SOCKET_SERVER define to prevent process polyfilll (#1655) * release: @umijs/mako@0.9.3-canary.20241023.1 * chore: bundler-mako@0.9.3-canary.20241023.1 * release: @umijs/mako@0.9.3 * chore: bundler-mako@0.9.3 * docs: changelog for 0.9.3 * fix: hmr with magic comment chunk name (#1663) * feat: enable magicComment features by default (#1667) * feat(bundler-mako): add moduleIdStrategy to supportMakoConfigKeys (#1664) * fix: async module in circular dependence (#1659) * test: ✅ add test async module in circular dependencies * refactor: 🎨 handle async polution by traversal * refactor: 🎨 use default over expect * feat: compatible codeSplitting config with umi (#1669) * feat: compatible codeSplitting config with umi * test: fix e2e code-splitting.granular * fix: umi codeSplitting: depPerChunk * Feat/benchmark workflows (#1671) * feat: benchmark-workflows * fix: 修改Github Secrets * release: @umijs/mako@0.9.4 * chore: bundler-mako@0.9.4 * docs: 📝 changelog 0.9.4 * chore: Optional parameters (#1679) * chore: Optional parameters * Update index.ts * fix: skip module should skip async module (#1662) * release: @umijs/mako@0.9.5 * chore: bundler-mako@0.9.5 * docs: update changelog * docs: update changelog * feat(ssu): handle dependence changing while watching (#1690) * refactor: 🎨 add after update aspect for rebuild cached modules * refactor: 🎨 add next_build aspect in build_my_modify * feat: ✨ 区分 ssu firstbuild 和 updating 两者状态 * fix: pnpm workspace watch too many files (#1684) * fix: ✅ ts annotated declare variable treat as top level variable (#1682) * test: ✅ add ts declare annotated variable as top level * refactor: 🎨 mv clean syntax context to visitors folder * fix: 🐛 strip ts/tsx first, then do normal transform * feat: move ensure runtime to entry (#1660) * feat: ✨ add ensure2 replace in dynamic replace * feat: ✨ ensure 2 runtime * feat: ✨ add experimental centralEnsure config * refactor: 🎨 add struct ReslvedReplaceInfo * feat: ✨ add central ensure plugin * refactor: 🎨 extract module ensure map * refactor: 🎨 add back chunk id in replace info * refactor: 🎨 fix case one source with different import type * refactor: 🎨 extract hmr runtime update code aspect * release: @umijs/mako@0.9.6-canary.20241107.1 * chore: bundler-mako@0.9.6-canary.20241107.1 * feat: keep unresolved nodejs require (#1689) * fix: regexpr for nodejs intenal modules igonre * feat: not replace unresolved nodejs require to __mako_require__ * fix: define util require should be __mako_require__ * feat: add expreriental.keep_unresolved_node_require * feat: add expreriental.ignore_non_literal_require * chore: 🔥 remove unused fn * release: @umijs/mako@0.9.6 * chore: bundler-mako@0.9.6 * docs: changelog for 0.9.6 * fix(SSU): 🐛 in case external not avaible to all entries (#1698) * fix(SSU): 🐛 in case external not avaible to all entries * refactor: 🎨 explict ignore the error * fix: devserver response header add cacheControl no-cache (#1692) * fix: add no-cache * feat: add cross origin * fix: resonse header add cors and no_cache for all branch (#1699) * fix: judge devServer instead of writeToDisk * fix: add branch header * refactor: 🎨 static file with 0 ages --------- Co-authored-by: pshu <pishu.spf@antfin.com> * release: @umijs/mako@0.9.7 * chore: bundler-mako@0.9.7 * docs: 📝 update changelog for 0.9.7 * chore: ✏️ remove some if (#1706) * fix: optimization.concatenateModules dts lost (#1708) * refactor: 🔥 enter ensure 使用 chunk sync dep 减少首屏 chunk 数量 (#1707) * fix: 🐛 typing of stats (#1712) * fix: 🐛 detect circular deps output file content (#1715) * chore: update @umijs/mako typings * feat: ensure esm imports exists when mode is production (#1709) * feat: ensure esm imports exists when mode is production * release: @umijs/mako@0.9.8 * chore: bundler-mako@0.9.8 * docs: update docs * fix: node ignores (#1716) * feat: supports publicPath: auto (#1717) * feat: auto resolve entry file extension (#1718) * feat: auto resolve entry file extension * fix: remove useless clone * Fix/context module source with first empty quasis (#1719) * test: ✅ add first empty quasis template string module source case * fix: 🐛 first emtpy quasis case * fix: inline css config deserialize (#1720) * fix: node ignore should support node: prefixed only built-in modules (#1721) * release: @umijs/mako@0.9.9 * docs: suggest using volta to manage node and pnpm's version * chore: bundler-mako@0.9.9 * docs: update CHANGELOG.md * feat: supports umd export (#1723) * feat: supports umd export * fix: umd config binding typing * fix: typos * fix: umd export * chore: update typings * fix: replace the "typeof __webpack_require__" content (#1688) * fix: replace the "typeof __webpack_require__" content * fix: add some other webpack string name * fix: 增加对typeof 表达式的处理 * fix: delete log * fix: rename --------- Co-authored-by: shikuan.sk <shikuan.sk@antgroup.com> * fix: umd config deserialization (#1726) * feat: support case sensitive (#1714) * feat: add CaseSensitivePlugin * FIX: update path check * fix: clippy error * fix: 调整判断 * fix: 修复目录读取 * fix: 修改参数名称 * fix: 调整测试方式添加e2e断言,并增加配置项只有mac系统下才需要开启相关配置 * fix: 删除过滤条件 * fix: 删除多余测试文件,增加更新内容 * fix: 删除多余log * fix: 测试执行 * fix: 添加测试系统 * fix: 调整顺序 * fix: 添加测试系统 * fix: 非mac环境断言 * fix: 引用遗漏 * fix: 断言 * fix: 删除默认 * fix: 默认配置 * fix: 测试覆盖 * Revert "fix: 测试覆盖" This reverts commit b0a2e66. --------- Co-authored-by: shikuan.sk <shikuan.sk@antgroup.com> * refactor: 🔥 remove unecessary transform (#1727) * feat: output filename (#1725) * refactor: 🎨 add file name template and chunk name in ChunkFile struct * feat: ✨ add config to output#filename * feat: ✨ render filename when output#filename configed * feat: ✨ calc hash in ast impl for entry * test: ✅ add test case * test: ✅ add ut * chore: 🔧 disable codecov error * refactor: 🎨 remove clone * fix: 🐛 hash when necessary * chore: 🔧 add codecov.yml * release: @umijs/mako@0.9.10-canary.20241218.1 * chore: ⬆️ update pnpm-lock * feat: native plugin init (#1691) * feat: init rust plugin * chore: delete print * Rename cargo.toml to Cargo.toml * chore: update * fix: type * fix: plugin options string * fix: cfg test * release: @umijs/mako@0.10.0 * chore: bundler-mako@0.10.0 * docs: 📝 changelog 2024.12.20 * chore: 🔧 for quick setup dep to debug (#1733) * fix: support optional chaining in environment variable (#1730) * fix: support optional chaining in environment variable * test(): add edge cases for optional chaining in env_replacer * refactor: 🎨 no need to resolve empty url in css (#1732) * refactor: 🎨 no need to resolve empty url in css * refactor: 🎨 add test case * feat: support unplugin context (#1728) * feat: support plugin context * fix: napi context * chore: revert changes * chore: improve * feat: add error * feat: warn and error support object * feat: support emit_file * ci: fix test * chore: improve * chore: update test * chore: format * chore: don't support add watch file * feat: load and transform adapter, and add unplugin-replace example * chore: test unplugin-icons * chore: update pnpm-lock.yaml * docs: improve --------- Co-authored-by: xusd320 <xusd320@gmail.com> * fix: legacy octal escape is not permitted in strict mode (#1736) * fix: legacy octal escape is not permitted in strict mode * fix: e2e inline css * release: @umijs/mako@0.11.0 * chore: bundler-mako@0.11.0 * fix: pnpm lock * docs: 📝 changelog 2024.12.26 * Revert "feat: support unplugin context (#1728)" (#1737) This reverts commit 3dd6d9d. * release: @umijs/mako@0.11.1 * chore: bundler-mako@0.11.1 * feat: support unplugin context (#1741) * feat: support plugin context * fix: napi context * chore: revert changes * chore: improve * feat: add error * feat: warn and error support object * feat: support emit_file * ci: fix test * chore: improve * chore: update test * chore: format * chore: don't support add watch file * feat: load and transform adapter, and add unplugin-replace example * chore: test unplugin-icons * chore: update pnpm-lock.yaml * docs: improve --------- Co-authored-by: xusd320 <xusd320@gmail.com> * fix: #1007 (#1738) support BinaryExpression Co-authored-by: shikuan.sk <shikuan.sk@antgroup.com> * fix: win path problem with context module and require context (#1742) * chore(mako): add debug notice for local builds (#1743) * fix: normalize Windows paths in ModuleId constructors (#1744) * fix: normalize Windows paths in Compiler output path handling (#1745) * fix: typos * release: @umijs/mako@0.11.2 * chore: bundler-mako@0.11.2 * docs: update CHANGELOG.md * feat(create-mako): refactor create-mako (#1751) * chore: add issue and pull request templates for better contribution guidelines (#1753) * fix: ensure parent directories are created when writing to disk in MemoryChunkFileCache (#1755) * chore: release @umijs/tools * release: @umijs/mako@0.11.3 * chore: update the release introduction * ci: fix ci (#1758) * chore: upgrade @umijs/tools and do github release and changelog generate and translation by script * docs: changelog for 0.11.3 * chore: add check-ecosystem-usages script (#1759) * fix: analyze don't work in safari (#1761) * fix(mako): cli delay exit (#1762) * dep: @umijs/tools@0.1.23 * fix: load wasm (#1705) * fix: 修复load .wasm文件对importObject的处理 * fix: 删除没必要的输出 * fix: 修改生成的成员表达式js代码 * fix: 变量重命名 * fix: 修复代码lint报错 * test: 补充wasm_runtime测试用例 * chore: 补充import js方式的示例 * chore: 修改import js示例wasm产物格式 * chore: wasmparser依赖包在配置文件的位置 * chore: 删除多余的.wasm load逻辑 --------- Co-authored-by: xusd320 <xusd320@gmail.com> * fix: chunk groups' order when building mpa (#1763) * feat(copy): support advanced copy configuration with custom target paths (#1711) * feat(copy): support advanced copy configuration with custom target paths - Add CopyConfig enum to support both basic and advanced copy modes - Basic mode: maintains backward compatibility with string[] format - Advanced mode: supports {from: string, to: string} format for custom paths - Update copy plugin to handle both configuration formats - Ensure target directories are created automatically Example config: { 'copy': [ 'public', // basic mode { 'from': 'assets', 'to': 'static' } // advanced mode ] } * fix(copy): prevent path traversal in copy plugin Add path canonicalization and validation to ensure target paths remain within the destination directory * chore: Update `copy` config type in Mako bundler - Updated the type of the `copy` property in the `BuildParams` interface to support both `string` and `{ from: string; to: string }`. - Ensured the `copy` configuration is properly validated to handle both types. * docs: Update `copy` config type in documentation - Updated the `copy` property type in the configuration documentation to reflect the change from `string[]` to `(string | { from: string; to: string })[]`. - Clarified that the `copy` configuration can now accept both strings and objects with `from` and `to` properties. * test(copy): add e2e tests for copy plugin from/to pattern - Update config.copy test fixtures to cover from/to pattern - Add assertions for copied files in new location - Adjust copy plugin path validation * fix(copy): improve path validation and cleanup for copy plugin - Add directory cleanup when path validation fails - Use canonicalized paths for more reliable path validation - Add concatenateModules option type to BuildParams * fix: ci (#1768) * release: @umijs/mako@0.11.4 * chore: bump version * docs: 📝 changelog 2025.02.12 * chore: update changelog 2025.02.12 * fix: plugin context gc (#1769) * fix: mako已经支持了scss 但是没有支持module.scss文件 (#1770) Co-authored-by: shikuan.sk <shikuan.sk@antgroup.com> * feat: add module federation plugin (#1764) * feat: support module federation * feat: mf exposes to remote entries * chore: code styles * feat: mf container entry impl * fix: mf container entry * fix: mf runtime initOptions * feat: add containter references * feat: impl mf remote * feat: improve mf exposes * fix: mf exposes runtime factory * fix: mf plugin execution order * chore: update mf demo * feat: generate mf manifest in rust * fix: remote stats.json * refactor: code styles * chore: add some FIXME * refactor: mf plugin mods files * refactor: mf plugin mods files * chore: remove dead code * --wip-- [skip ci] * fix: remote stats.json * fix: typos * chore: simpify mf runtime codes fmt * refactor: mf containter plugin * feat: mf shared workaround * feat: mf shared workaround * fix: runtime template and remove some useless codes * fix: mf dev server * fix: mf shared config * feat: supports chunk group exclude * feat: mf patch code splitting * feat: mf shared manifest * feat: add config hash for mf shared module * chore: update mako typings * chore: code styles * chore: fix typo * chore: code styles * perf: improve performance * chore: code styles * chore: rename types * feat: add options to disable mf manifest * feat: entry config should be defined as BTreeMap * fix: mf shared consume and supports eager config * fix: mf shared eager * fix: not generate chunk for mf remote module * fix: typos * feat: add entry filename supports * chore: remove meaning less changes * fix: entry filename and mf config * release: @umijs/mako@0.11.4-canary.20250206.0 * fix: ignore shared dep when it is been external * Revert "release: @umijs/mako@0.11.4-canary.20250206.0" This reverts commit d3105d9. * release: @umijs/mako@0.11.4-canary.20250207.0 * fix: skip serialize mf manifest remoteEntry if none * fix: mf manifest remoteEntry address * Revert "release: @umijs/mako@0.11.4-canary.20250207.0" This reverts commit 6179982. * fix: typo * fix: mako mf manifest publicPath * fix: mf manifest panic * fix: mf typings * test: add e2e test for mf * fix: typo * chore: update README * fix: update mf bingding typings * fix: typings * fix: should not generate mf remotes runtime when remotes is empty * chore: remote wrong comment * feat: add chunk matcher for mf * fix: mf binding typings * chore: remove debug print statements * docs: update moduleFederation configuration docs * fix: mf config docs * chore: update CONTRIBUTING.md * release: @umijs/mako@0.11.5 * chore: update CHANGELOG.md and versions * feat: support to disable camel2DashComponentName of transformImport (#1773) * feat: support to disable camel2DashComponentName of transformImport * fix: typings * fix: 修复sass/less-loader的路径解析 (#1771) * fix: 支持webpack中sass-loader的路径解析 * chore: 调整目录 * chore: 移除注释等 * chore: 引入loader-runner * chore: sass-loader * chore: 修改loader返回空值处理 * test: 设置loader resolver的别名 * chore: update lock * fix: loader options * refactor: 提取插件代码 * fix: getResolve * fix: 修复runLoaders中的错误处理逻辑 * release: @umijs/mako@0.11.6 * fix: pnpm-lock * chore: update changelog for v0.11.6 * chore: update changelog for v0.11.6 * chore: update changelog for v0.11.6 * fix: watch less and sass dependencies (#1779) * chore: stash * chore: stash * feat: LessModuleGraph * feat: less-import-plugin * chore: 删除多余代码 * fix: 兼容url() * chore: plugin * feat: add beforeRebuild hook * ci: clippy format * fix: paths去重 * fix: rename _path * chore: rust层增加临时过滤文件方式 * chore: 提取createParallelLoader * refactor: before_rebuild hook (#1785) * refactor: before_rebuild hook -n * fix: typos * feat: postcss-loader (#1787) * feat: 支持postcss-loader * chore: 合并postcss到options传给render * chore: 更新.gitignore以排除less.postcss的node_modules目录 * feat: 添加PostCSS插件支持并更新相关类型定义 * refactor: 简化Less和Sass插件中的选项传递 * docs: 添加postcss支持的配置说明 * feat: 添加对PostCSS的支持,更新相关插件以集成postLoaders * feat: 更新Less和Sass插件以移除postLoaders,增强PostCSS支持 * test: 补充postcss测试用例 * fix: use transpiled hmr runtime (#1813) * fix: use transpiled hmr runtime (#1814) * release: @umijs/mako@0.11.7 * fix: package-lock.json * fix: use transpiled hmr runtime entry (#1815) * fix: disable parallel sassLoader because sassOptions.function cann't be shared cross workers (#1816) * release: @umijs/mako@0.11.8 * fix: package-lock.json * fix: package-lock.json * fix: typos * chore: update changelog for v0.11.8 * fix: less,sass,postcss loader panic (#1818) * release: @umijs/mako@0.11.9 * fix: package-lock.json * chore: update changelog for v0.11.9 * fix: worker threads panic on linux (#1823) * release: @umijs/mako@0.11.10 * fix: package-lock.json * chore: update changelog for v0.11.10 * fix: dev支持inline-source-map (#1859) Co-authored-by: dongqing.mdq <dongqing.mdq@antgroup.com> * release: @umijs/mako@0.11.11 * fix: package-lock.json * chore: update changelog for v0.11.11 * Update PULL_REQUEST_TEMPLATE.md * Update PULL_REQUEST_TEMPLATE.md * fix: less resolve alias (#1906) * docs: update README.md (#1907) * Update README.md * Apply suggestions from code review Co-authored-by: Peach <scdzwyxst@gmail.com> * Update README.md * Update README.md --------- Co-authored-by: Peach <scdzwyxst@gmail.com> * Update README.md * Update README.md * release: @umijs/mako@0.11.12 * feat: update pnpm log * chore: update changelog for v0.11.12 * fix: panic on docker linux (#1909) * doc: add openomy (#1910) * release: @umijs/mako@0.11.13 * chore: update changelog for v0.11.13 * chore: remove codecov * chore: update examples/multiple-entries-heavy * feat: support inline-source-map devtool option (#1965) Co-authored-by: hanzebang.hzb <hanzebang.hzb@antgroup.com> * chore: truncate old codes --------- Co-authored-by: pshu <pishu.spf@antfin.com> Co-authored-by: chencheng (云谦) <sorrycc@gmail.com> Co-authored-by: Jinbao1001 <nodewebli@gmail.com> Co-authored-by: money <hualigushi@163.com> Co-authored-by: eisonhower <why490078184@gmail.com> Co-authored-by: huanyu.why <huanyu.why@antgroup.com> Co-authored-by: PeachScript <scdzwyxst@gmail.com> Co-authored-by: Wu-kung <1434246346@qq.com> Co-authored-by: 聪小陈 <xiaohuoni@users.noreply.github.com> Co-authored-by: akitaSummer <akitasummer@outlook.com> Co-authored-by: Shi Kuan <shikuan1992@gmail.com> Co-authored-by: shikuan.sk <shikuan.sk@antgroup.com> Co-authored-by: yezao <75713784+yezaoshu@users.noreply.github.com> Co-authored-by: 御风 <18012261618@126.com> Co-authored-by: bqxbqx <132878537+BQXBQX@users.noreply.github.com> Co-authored-by: miaodongqing <dongqing_miao@163.com> Co-authored-by: dongqing.mdq <dongqing.mdq@antgroup.com> Co-authored-by: kiner-tang(星河) <1127031143@qq.com> Co-authored-by: hanzebang <46307343+hanzebang@users.noreply.github.com> Co-authored-by: hanzebang.hzb <hanzebang.hzb@antgroup.com>
part of #1238
Summary by CodeRabbit
新功能
JsHooks和TsFnHooks结构中添加了可选字段resolve_id,支持基于源和导入者字符串解析标识符。Resolution结构体,封装文件路径及其相关信息。resolve_id方法被引入到JsPlugin结构,允许插件解析标识符。Plugin接口中新增resolve_id方法,增强插件功能。resolve模块的可见性更新为公共,便于外部访问。文档
binding.d.ts文件,增加了JsHooks接口的可选方法resolveId及新接口ResolveIdResult。测试
resolve_id钩子的验证。