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.19k stars 127 forks source link

speeds up the loading of third-party libraries #70

Closed FranckFreiburger closed 3 years ago

FranckFreiburger commented 3 years ago

Is your feature request related to a problem? Please describe. Loading 3rd party libraries could be very long since vue3-sfc-loader is processing every dependencies through babel (for CJS transformation and dependencies static analysis). For instance, babylon.max.js takes around 17s to load.

Describe the solution you'd like The simplest solution is to give control to the caller about what to transpile and what to not transpile. eg. do not transpile babylon

    const options = {
      ...
      async handleModule(type, getContentData, path, options) {

        if ( path.toString().endsWith('babylon.max.js') )
          return createCJSModule(type, await getContentData(false), options)

        return undefined;
      },
      ...

These libraries must be leaves of the whole dependency graph since no static analysis will be performed on them. These libraries must already be CJS (or obviously UMD).

Additional context see https://github.com/FranckFreiburger/vue3-sfc-loader/discussions/50