sveltesvelte-4

What's the replacement of svelte/register for Svelte 4?


I have this project svelte-mpa, what's that I tried to upgrade to svelte-4, but svelte/register already deprecated on svelte-4. What's the proper replacement of it?


Solution

  • nevermind, just use svelte/compiler works, change

    require('svelte/register')
    

    to

    const compile = require('svelte/compiler').compile
    

    then change

    const renderedSvelte = require(path + '.svelte').default.render()
    

    to

    const renderedSvelte = compile(path + '.svelte')