-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
perf(core/options) added scope of the icon sources package #341
Conversation
Run & review this pull request in StackBlitz Codeflow. |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@iconify/utils@2.1.12 |
@Scrum with this PR you can only use 1 source (scope) (?), we need to add new node loader (s) to allow use it inside the collection. How can we use multiple
|
@Scrum I'm going to refactor this PR to include a new loader for new scope removing the scope from global configuration or do you want to give it a try? We also need to add a test for scope, for example adding 2 scoped collections in examples/vite-vue3 (you have included a fixture in iconify IIRC, we can use it here => EDIT: use file protocol in dev dependencies. |
Good point, I’m not sure if this is worth implementing in the current functionality, but my thoughts are:
{
scope: ["@my-primary-json", "@my-secondary-json" ,"@iconify-icon"]
}
{
scope: ["@my-primary-json", "@my-secondary-json" ,"@iconify-icon"]
}
loadNodeIcon('collection-name', 'icon-name', { scope: '@my-secondary-json' }) |
Great, let me know if there is anything I can do or should do. |
I'm going to review iconify PR, I think your PR there has introduced a breaking change. |
@Scrum we should add a lot of stuff here to resolve the scoped collections before calling If you check |
It is still difficult for me to grasp the meaning of your direction. I will describe how I would like to use this with examples: npm package @my-scope
- icons
-- package.json
-- dist
--- index.js vite.config.js import IconsResolver from "unplugin-icons/resolver";
import Icons from "unplugin-icons/vite";
import Components from "unplugin-vue-components/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
Components({
resolvers: [IconsResolver({ componentPrefix: "my-collection", customCollections: ['icons'], })],
}),
Icons({
autoInstall: true,
scope: "@my-scope",
}),
]
}); my-vue-component.vue <my-collection-icons-user /> I understand that if I want to use another scope, I will no longer be able to do so. As far as I understand, we need to be able to multiscoping, I suggested options earlier vite.config.js import IconsResolver from "unplugin-icons/resolver";
import Icons from "unplugin-icons/vite";
import Components from "unplugin-vue-components/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
Components({
resolvers: [IconsResolver({ componentPrefix: "my-collection", customCollections: ['icons'], })],
}),
Icons({
autoInstall: true,
scope: ["@my-scope", "my-super-scope"],
}),
]
}); There's still the issue of race. I don't think the multiscoping resolution should be in I tried my best to describe everything (thoughts/ideas and suggestions) in this post. Let me know if I'm heading in the wrong direction. |
@Scrum the solution is not correct in iconify repo, since we need to know the scope before knowing what collection we need to resolve: the EDIT: about |
@Scrum this is my first try in iconify, we'll need to call |
@Scrum your iconify PR reverted in |
Solution for me import { addCollection } from "@iconify/vue";
import { icons } from "@my-scope/icons";
addCollection(icons); |
@Scrum we need to find a better way to load external collections. FYI: any |
Undoubtedly, now I lack a complete picture of the code base of both projects and it will take me considerable time to dive in and find a solution. I will take into account all the points you provided in the comments above and try to find the best way. Thanks anyway. |
FYI: I moved
and the iconify PR here: iconify/iconify#97 In the meantime, you can use a custom loader to load your package, add the collection to the customCollections entry and a new loaded like this one: https://github.com/iconify/tools/blob/main/%40iconify-demo/unocss/unocss.config.ts#L16-L72 If you want I can help you with a GH repo to show you how to use it. Previous example in iconify tools requires some changes for your needs. |
Thanks, I'll look into this.
I need time to immerse myself in projects to understand the needs. Now I only have a goal but no understanding. |
@Scrum using custom loader and |
Wow, that's cool, you're very fast 🚀 |
@Scrum https://github.com/userquin/custom-scoped-unplugin-icons-loader, check custom-loader.ts and the unplugin icons configuration. |
This is incredibly cool, I can't keep up with you. I am incredibly grateful to you. |
I'm going to send a new PR to iconify to include the new EDIT: this way we don't need to change anything here and in UnoCSS Preset Icons, just using |
Description
This performance will make it possible to use automatic loading of icons in the package unplugin-icons from arbitrary packages.
Linked Issues
Additional context
I will be glad to receive any comments and suggestions.