vue3-sfc-loader icon indicating copy to clipboard operation
vue3-sfc-loader copied to clipboard

Slow parsing?

Open webloft opened this issue 3 years ago • 1 comments

First of all, great work!

But I tested the load-from-string example and the timing is just bad for production. It takes ~70ms to create the component from a simple string. I don't assume the problem is the content, since there is nothing great to parse.

So is it the invocation of the parser itself? Doing unnecessary steps or are the functions so big it takes so much time to load it? Can this be optimized?

const options = {
    moduleCache: {
        vue: Vue,
    },
    getFile() {
        return `<template>nothing</template>`
    },
    addStyle() { }
}

let begin = (new Date).getTime()
loadModule("foo.vue", options).then(() => {
    const elapsed = (new Date).getTime() - begin
    console.log("component created after " + elapsed + " ms")
})

webloft avatar Mar 12 '22 10:03 webloft

Hi webloft,

try to enable "compiledCache" :

const options = {
      ...
      compiledCache: {
        get: key => window.localStorage.getItem(key),
        set: (key, value) => window.localStorage.setItem(key, value),
      },
      ...
    }

FranckFreiburger avatar Jan 15 '24 20:01 FranckFreiburger

see also https://github.com/FranckFreiburger/vue3-sfc-loader/discussions/175

FranckFreiburger avatar Jan 21 '24 19:01 FranckFreiburger