sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
7k stars 434 forks source link

Getting multiple route related js files #1414

Closed Bradley-H closed 4 years ago

Bradley-H commented 4 years ago

Currently when i make a sapper project, and I check my sapper/client, i'm overwhelmed by how many index.js files i have that are almost identical in content.

sapper

I updated Sapper, Svelte, Polka, Sirv, rollup, and I'm still getting this.

Conduitry commented 4 years ago

Do you have a reproduction? Is the issue that files from previous builds aren't getting deleted? If you delete the __sapper__ directory and rebuild (once), do all of the duplicate files reappear?

Bradley-H commented 4 years ago

They don't reappear, when I delete the sapper folder. However, when I save they aren't being replace.

Conduitry commented 4 years ago

If this is happening when you're running npm run dev and then making subsequent edits to the site while the dev server is running (which triggers more rebuilds), this is expected and not a problem. If you're seeing it when running npm run build, that is a problem, because that's supposed to clear the directory first.

Bradley-H commented 4 years ago

I don't think that is a good design philosophy. Imagine if you will sapper is being used in a full enterprise level website, that is going to clutter up my disk space after an entire day of work if not part of the day at work and I don't think it's a good idea to stop what I'm doing, delete my sapper directory, run npm run dev and pick up where I left off or vice a versa.

ajbouh commented 4 years ago

@Bradley-H Is this during dev or build?

pngwn commented 4 years ago

Sapper doesn't really have too many opinions about how you set up your dev environment so we leave these kinds of choices to the user. As such, I'm afraid this isn't a feature we are interested in implementing right now.

However it is pretty easy to add using something like rollup-plugin-delete.

You should just be able to add the following to your client rollup config and get the desired behaviour:

export default {
  client: {
    ...config,
    plugins: [
      ...other_plugins,
      del({ targets: '__sapper__/*' })
    ]
  },
  server: { ... }
}