FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 921 forks source link

[FEATURE] Custom resolver plugins #3179

Open DylanPiercey opened 3 years ago

DylanPiercey commented 3 years ago

The problem that you want to solve. I'm wondering if there are any plans for supporting more advanced "resolver" style plugins (like resolveId in rollup https://rollupjs.org/guide/en/#resolveid).

For some context on my question I'm one of the maintainers of Marko and as it stands I see no clear way of integrating Marko with snowpack. Largely that's because we like to have more control over the whole experience, including the bundler.

One thing we do in all of our supported bundlers (webpack, rollup & lasso) is support passing in a .marko file as the client side entry point, similar to how snowpack expects an .html file. Then we have the Marko compiler crawl the component tree and output a .js file which only includes output from top level stateful components. This is part of our partial hydration story.

For the most part the implementation in these bundlers is to write a resolve plugin that resolves entry Marko files to a virtual file which will contain the hydrate ready content.

It looks like virtual files are not yet supported by snowpack either though (https://github.com/snowpackjs/snowpack/issues/1122).

I'm curious if this is something you all are willing to have a discussion about and see how we can bring Marko into the snowpack ecosystem.

Your take on the correct solution to problem.

I'm not sure implementing a "resolveId" style hook is the only solve, or the correct solve for snowpack. Similar hooks is simply how we've achieved our integrations in other bundlers.

Are you willing to submit a pull request to implement this change?

Potentially!

natemoo-re commented 3 years ago

Thank you for opening this discussion! We definitely want to see Marko support in Snowpack. I'll be sure to flag this issue to the rest of the team tomorrow so we can see what it will take.

For my own reference, here are the links to the other bundler integrations:

DylanPiercey commented 3 years ago

Sounds great, happy to join in on the conversations if helpful!