-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve all imports from svelte/...
to the same copy
#58
Comments
A potential issue: Imports from We could resolve this by going back to the first idea I had - just manually resolving all |
@mrkishi suggested using the |
Never mind, I couldn't find it because I stopped looking before I got to it. rollup/rollup#371 This was added ages ago. |
0.60 had the Now, adding the resolve to the top of the plugins is definitely breaking to me :P |
Initial hacky implementation: diff --git a/index.js b/index.js
index 330e8b9..14555e9 100644
--- a/index.js
+++ b/index.js
@@ -7,6 +7,8 @@ const { encode, decode } = require('sourcemap-codec');
const major_version = +version[0];
+const home_svelte_path = require.resolve('svelte/package.json').slice(0, -19);
+
const { compile, preprocess } = major_version >= 3
? require('svelte/compiler.js')
: require('svelte');
@@ -165,6 +167,9 @@ module.exports = function svelte(options = {}) {
},
resolveId(importee, importer) {
+ if (importee === 'svelte' || importee.startsWith('svelte/')) {
+ return this.resolve(home_svelte_path + importee);
+ }
if (cssLookup.has(importee)) { return importee; }
if (!importer || importee[0] === '.' || importee[0] === '\0' || path.isAbsolute(importee))
return null; I was running into some weird errors when I was trying to use the I was also running into some weird errors when I was linking a local copy of rollup-plugin-svelte into an app. I tested the above changes by directly editing |
This has been fixed in the Svelte and Sapper templates by using the new |
As mentioned here
npm link
ing in a package containing a Svelte component can cause issues with two copies of the Svelte internals, because imports fromsvelte/internals
will resolve to that linked package'snode_modules/svelte
.One way to address this is to compile with
sveltePath: '\0svelte'
(to prevent rollup-plugin-node-resolve from trying to resolve these modules, even if itsresolveId
hook runs before ours), and then to manually resolve those imports in ourresolveId
hook.The text was updated successfully, but these errors were encountered: