sveltejs/rollup-plugin-svelte

Incompatibility with Node.js 14 ESM exports.

kriskowal opened this issue ยท 1 comments

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch rollup-plugin-svelte@5.2.3 for the project I'm working on.

The problem is that svelte has an exports map in its package.json that expresses that svelte/compiler corresponds to svelte/compiler.mjs and does not also provide a svelte/compiler.js mapping. rollup-plugin-svelte takes a dependency on the latter, depending on the Node.js version.

Here is the diff that solved my problem:

diff --git a/node_modules/rollup-plugin-svelte/index.js b/node_modules/rollup-plugin-svelte/index.js
index 0d52cfb..07bbeea 100644
--- a/node_modules/rollup-plugin-svelte/index.js
+++ b/node_modules/rollup-plugin-svelte/index.js
@@ -8,7 +8,7 @@ const { encode, decode } = require('sourcemap-codec');
 const major_version = +version[0];
 
 const { compile, preprocess } = major_version >= 3
-	? require('svelte/compiler.js')
+	? require('svelte/compiler')
 	: require('svelte');
 
 function sanitize(input) {

This issue body was partially generated by patch-package.

bluwy commented

Duplicate of #152

The latest version of rollup-plugin-svelte should fix this.