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

Deeper Babel configuration. Passing options. #170

Open ru5t opened 6 months ago

ru5t commented 6 months ago

Hi there! I'm building a frontend for embedded device so working with CDN since there's no place for all required modules. Here is the case: Vue single file component imports js file. Vue file itself is loaded using sfc-loader. This action leads to method transformJSCode and to assertModuleNodeAllowed call for js file. And it fails since it is not a module but a plain javascript.

As I can see, there's nothing passed at the Babel parser level except of additionalBabelParserPlugins.

Is there a way to pass options to parser directly? I'm very interested in allowImportExportEverywhere flag.

So the questions are:

FranckFreiburger commented 5 months ago

Hi ru5t, you really want to use import and export from everywhere ?

ru5t commented 5 months ago

Hi, Frank. For sure, in general - no. But in some particular cases in the limited and controlled context - probably. I mean that it is an exception that vue single file component is going to be loaded like this. But to have possibility to tune babel's logic deeper, if needed, would be good. This particular case was solved by rewriting of provided js library in CommonJS manner. It was small enough to do so. So, basically absence of this feature is not slowing process. But it seems to me, that deeper configuration possibilities could be of some use for someone.