-
Notifications
You must be signed in to change notification settings - Fork 34
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: output insertStyle as part of rollup bundle #163
Conversation
b671342
to
71ac1c6
Compare
This comment was marked as resolved.
This comment was marked as resolved.
71ac1c6
to
3e78b0b
Compare
6b2c6e0
to
f9dec13
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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.
Left some comments.
d372283
to
801bb09
Compare
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.
Left comments:
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.
Restored explicit types on generateBundle
using correct types from rollup
.
Also moved destructing of plugin state and plugin options at the beginning of the function to reduce the improve readability of the first if
Updated comment to state result of code a bit clearer.
__insertStyle
function into './dist/node_modules/...' #158This PR aims to replace referencing insertStyle file using the path to the
dist
folder with rollup build hooks.They can generate a separate chunk that is processed as any other js files in the rollup lifecycle.
If
preserveModules
option is used the separated chunk with be created directly inside a_virtual
folder rather than inside anode_modules/...
folderThe results is something like this:
rollup config
I added a screenshot to better show the result:
Implementation
Using load and resolveId build hooks we can map a special moduleID and when it is loaded we directly return the code of insertStyle function adding a
virtual
module.Another benefit of this approach is that the
insertStyle
function is now imported directly in the source code.This means that the separate build task to have insertStyle generated with
ESM
can be removed.Warning
I noticed these issue after finishing #162 so this branch is based on the one of that PR.
That PR adds prettier as a formatter so after merging it the diff here should affect less files.
Relevant diff can be seen in the feat: output insertStyle as part of rollup bundle commit