-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
rollup-plugin-html-module #2932
Comments
Sounds like a duplicate of #2873, at least concerning html entry points. Import of |
Thing is, I am stretched to the limit regarding my capacity, so I would hope someone else would pick this up. Maybe someone like @surma already has something up their sleeve? |
I'm definitely not asking you to do it! Looks like it's definitely a dupe of 2873! I'm already working on this because it's sort of a blocker on our ability to use Rollup since plugins like html-fill or html-entry just don't allow the level of control over the output-ted html. I do have questions though! Which hook would I need to use to setup tracking dependencies for an html file? I assume I'd call Can I set this up to have different behavior depending on what file is importing the html? (If it's an entry just create the html asset, if it's a javascript file import it as a string, for example). None of the plugins I see use |
Ok, let me see if I can help you.
First let me explain about
Because both of these things are to be configured by the user via a naming pattern. If this works for you, this is probably the preferred method of adding files due to the improved user control. A good example for this is emitting an image file. As long as you have a way to reference it in the places that matter, you probably do not care where the file ends up. As for referencing, you can use Now if you need to add a file to the bundle where you need full control over file name and directory, there is not yet a proper API (but it is high in my priority list). However, if you can just manually add them to the bundle in Now for HTML files, I think there are two very distinct cases here, using HTML as an entry point and importing an HTML file. Using it as an entry point is not possible directly, see #2873 and the suggestions in that issue. In short, you can fake this by using the For referenced JavaScript files, you would want to use As for the importing case, this needs to be handled by providing a load(id) {
if (id.endsWith('.html') {
// bonus points for using the non-sync version and returning a Promise
return `export default '${fs.readFileSync(id)}'`;
}
} If you also want to emit chunks and assets in that hook, that is up to you.
Tricky. What if both an entry point and a non-entry point import the file, which logic should apply? This is why the
Files that are imported never need to be watched manually as this is done automatically. So in our example, the files you want to watch manually are
Everything else, i.e. emitted chunks, should be watched automatically. I hope this helped a little. |
If this plugin does approach completion, I'd be happy to vote for it as an official-of-sorts plugin and add it to the org here on Github. Moving forward, let's close this as pending-a-plugin and track the wider issue of handling assets on #2872. |
Feature Use Case
I'd love if there was officially supported html module support that handled dependencies correctly.
Feature Proposal
If I import (or use as an entry) an html file, I want rollup to find all the relevant dependencies (see: Parcel's HtmlAsset.js), and emit a chunk for each dependency (replacing the url as appropriate).
If this is the wrong place to ask for an official plugin feel free to close.
The text was updated successfully, but these errors were encountered: