-
Notifications
You must be signed in to change notification settings - Fork 408
fix: support default component import #1473
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
fix: support default component import #1473
Conversation
WalkthroughThe changes introduce and apply TypeScript interfaces to clarify and enforce type safety for component dependency management and dynamic imports. Global window properties are explicitly declared. Functions for script/style loading, object copying, dynamic imports, and component registration are updated for improved typing and flexibility. Internal data structures for third-party dependency generation are also refined. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
🧹 Nitpick comments (2)
packages/plugins/materials/src/composable/useMaterial.ts (1)
254-272
: Potential O(N²) lookup – replace the linear search with aMap
for scalabilityInside the loop we call
scripts.find(...)
on every component.
For large bundles (hundreds of items) this degrades to quadratic time.A lightweight win:
-const currentPkg = scripts.find((item) => item.package === pkg) +let currentPkg = pkgMap.get(pkg) if (currentPkg) { … } else { … } // initialise once, outside the loop -const scripts: …[] = [] +const scripts: …[] = [] +const pkgMap = new Map<string, typeof scripts[number]>()Update
pkgMap
whenever a new entry is pushed.
This keeps the code simple while moving the complexity back to O(N).packages/canvas/common/src/utils.ts (1)
121-132
: Minor: prefer explicit branch whendestructuring === false
butexportName
is providedCurrent fallback ignores
exportName
wheneverdestructuring
isfalse
.
If a library authors setdestructuring: false
by mistake the whole module is
returned, silently hiding the wrong field.-const config = item as ComponentConfig -window.TinyLowcodeComponent[componentId] = - config?.destructuring && config?.exportName ? modules[config.exportName] : modules +const { destructuring = true, exportName } = item as ComponentConfig +window.TinyLowcodeComponent[componentId] = + exportName && destructuring !== false ? modules[exportName] : modulesThis still honours the flag but makes incorrect combos (
destructuring: false
+
exportName: 'Foo'
) more obvious during testing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/canvas/common/src/utils.ts
(6 hunks)packages/plugins/materials/src/composable/useMaterial.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
【问题描述】
画布不支持默认导出的物料。比如:
【解决方案】
物料解析的过程中,增加 destructuring 的判断,如果是
destructuring: false
则使用模块本身作为组件引用。What is the current behavior?
Issue Number: #1325
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit