vuejs / vue-component-compiler

Compile a single file Vue component into a CommonJS module.
MIT License
342 stars 52 forks source link

ES6 module support #80

Closed neemzy closed 4 years ago

neemzy commented 5 years ago

Hello!

Would you consider supporting compiling .vue SFCs to plain ES6 modules, instead of CommonJS? That would allow one to use such components through <script type="module">.

Thanks!

FredKSchott commented 4 years ago

Hey maintainers, we're getting requests from Snowpack users who would like to use SFC's in their application. This tool would need to compile components to ESM instead of Common.js, since only ESM can run natively in the browser.

context: http://snowpack.dev/ & https://github.com/pikapkg/snowpack/pull/174

How much work are we talking about to compile components as ESM instead of CJS? This would have benefits for both bundled applications as well: bundlers are even better at optimizing/tree-shaking ESM than CJS.

WIth your guidance I can try to donate some time to fixing, or someone from the Snowpack community might also be interested in helping as well.

Vue is one of the few web frameworks with a partial ESM story. This would go a long way to improving that.

znck commented 4 years ago

This is an outdated issue. The output JavaScript is an ES module (it has been like this for a while).