FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.03k stars 116 forks source link

Support for Node environments #162

Closed leviwheatcroft closed 5 months ago

leviwheatcroft commented 11 months ago

Is your feature request related to a problem? Please describe. No support for node environments

Describe the solution you'd like To be able to use vue3-sfc-loader in a node environment

Describe alternatives you've considered I have a working proof of concept

Additional context

This is related to #132 - if you try to use vue3-sfc-loader in a node environment you get a ReferenceError complaining that self is undefined.

This is pretty much because the built package is transpiled by webpack targetting browser environments.

I forked this repo, and added a webpack profile to transpile for node targets. It seems to be working as expected, but I'm unable to test this extensively and I have no idea if this is the best approach to obtain node support.

I guess I'm hoping for some feedback and / or guidance from the maintainers. Happy to work towards a pull request if you would like.

To make this work, you'll need to:

Additionally, you need to provide an options object as in loadModule(path, options) per the examples in this repo.

I would be happy to provide a repro if someone can suggest a code sandbox that allows you to create node projects?

FranckFreiburger commented 5 months ago

Hi leviwheatcroft, since Vue is a client-side framework, in which context do you need it for node ?

FranckFreiburger commented 5 months ago

nodejs bundle is available in the main branch (yarn run build-node)

leviwheatcroft commented 4 months ago

Awesome. Amazing. Thankyou.

Sorry I didn't reply earlier but support for node environments allows this module to build components for static sites. It's pretty great.