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(core): generator events #1695
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
Should |
Also, I think the event names should have keywords like |
@Dunqing I was copying the |
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.
Do you consider this an alternative to #1617 or a complement to it?
I don't have a strong opinion on this, but my concern is that this will increase the package size for a relatively rare use case. And honest I would prefer for rules to keep as pure as possible and not rely on the event system. (e.g. the config
hook is for up-level integrations but is not designed to be access directly in rules)
@@ -46,3 +46,81 @@ describe('generate-async', () => { | |||
expect(order).eql([1, 2]) | |||
}) | |||
}) | |||
|
|||
describe('firing-events', () => { |
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.
We could have a separate events.test.ts for this.
const order: number[] = [] | ||
const uno = createGenerator() | ||
|
||
uno.events.on('config', () => order.push(order.length)) |
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.
I am not very sure what order.length
is used for, maybe we could just use a fixed number?
If the event system is too heavy, what about using lifecycles in the config? |
|
Add events after each of tokens and preflights are generated. This should help usecases like #1617.
I'm unsure what data should be passed to the event. As for now, tokens & preflights event gets what each of them would normally produce, except in a cloned set to prevent modification.