Search code examples
githubcompiler-constructionsveltesvelte-3

Svelte use compiler cloned from GitHub


I know this message might sound stupid. But I'm trying to play around a bit with the Svelte Compiler from GitHub https://github.com/sveltejs/svelte. I cloned and installed everything just like in the Instructions. But how can I now use the compiler to run a Project I programmed in Svelte?


Solution

  • You can use a local version of a project in another project with npm link.

    In the case of Svelte, you also need to ensure that you rebuild after any change (to Svelte). You can generally find the build script in the scripts section of package.json. For Svelte, it's npm run build, or npm run dev to watch & rebuild as you change.

    git clone git@github.com:sveltejs/svelte.git svelte
    cd svelte
    npm install
    npm link
    npm run dev # watch & rebuild
    

    In another terminal:

    npx degit sveltejs/template my-app
    cd my-app
    npm install
    npm link svelte # <--------- here
    ls -l node_modules | grep svelte # confirm svelte is a symlink
    npm run dev