Code splitting with Rollup and Svelte changes all chunk names with new hashes even with no modifications

Viewed 1855

I'm using Svelte and Rollup with code splitting, and here are some parts of my rollup.config.js:

    input: {
        'boot': 'src/boot.js',
        'app': 'src/app.js',
        'agency': 'src/modules/agency.js',
        'buyer': 'src/modules/buyer.js',
        'buyer-group': 'src/modules/buyer-group.js',
        'investor': 'src/modules/investor.js',
        'management-unit': 'src/modules/management-unit.js',
        'platform': 'src/modules/platform.js',
        'supplier': 'src/modules/supplier.js',
        'tables': 'src/modules/tables.js',
        'pt-BR': 'src/core/locale/pt-BR.js',
        'en': 'src/core/locale/en.js',
        'external-svelte-package': 'node_modules/external-svelte-package/src/index.js'
    },

    output: {
        sourcemap: false,
        format: 'esm',
        dir: `${baseDir}/js`,
        entryFileNames: '[name]-[hash].js',
        chunkFileNames: '[name].[hash].js'
    },

Rollup generates chunks with names containing hashes (e.g. investor-fa42bee8.js).

If I run build script again, with no modifications in any file of the project, all the chunks are generated with new hashes, and this behavior harms client long term cache.

How can I change this behavior and grants same hash for all chunks that are not modified?

Any help will be wlcome.

Thanks in advance.

1 Answers

If the hashes change, something in your sources changes. Likely a plugin or a banner that contains a timestamp or something like that.

Related