Using Chart.js with SvelteKit

I’m trying to use Chart.js with SvelteKit. In development mode everything works fine, but when I try to build the project I get the following error.

Directory import 'C:directorynode_moduleschart.jsauto' is not supported resolving ES modules imported from C:directory.svelte-kitoutputserverapp.js

Did you mean to import chart.js/auto/auto.js?

Importing the Chart.js module with an exact path is not a good idea, and only introduces more errors.

I am using @sveltejs/adapter-netlify as my adapter in svelte.config.js, but I get the same error if I run the preview of my build.

I also added the following options to svelte.config.js, but it doesn’t seem to make any difference either way:

vite: {
            build: {
                rollupOptions: {
                    // make sure to externalize deps that shouldn't be bundled
                    // into your library
                    external: ['chart.js/auto/auto.js'],
                    output: {
                        // Provide global variables to use in the UMD build
                        // for externalized deps
                        globals: {
                            'chart.js/auto/auto.js': 'chart.js/auto/auto.js'
                        }
                    }
                }
            }
        }