Skip to content
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

The requested module '@glidejs/glide' does not provide an export named 'default' #674

Open
Ahmed-M-Yasser opened this issue Oct 28, 2023 · 4 comments

Comments

@Ahmed-M-Yasser
Copy link

Ahmed-M-Yasser commented Oct 28, 2023

I'm using glidejs with sveltekit. It's working perfectly fine in my localhost, but after deployment, I'm getting this error

The requested module '@glidejs/glide' does not provide an export named 'default'

<script> ... import Glide from '@glidejs/glide'; //getting the error here on the deployment server only ... </script>

This is how I'm referencing glide.core.min.css
<svelte:head> <link rel="stylesheet" href="../node_modules/@glidejs/glide/dist/css/glide.core.min.css" /> </svelte:head>

@ericmorand
Copy link
Contributor

This is likely a sveltekit issue. Glide works perfectly fine when imported by a JavaScript module and bundled using browserify or rollup.

@Ahmed-M-Yasser
Copy link
Author

The issue is gone once I imported glide like this

<svelte:head>
	<script src="node_modules/@glidejs/glide/dist/glide.min.js"></script>
	<link rel="stylesheet" href="../node_modules/@glidejs/glide/dist/css/glide.core.min.css" />
</svelte:head>

But still, I'm curious to know why it happens with sveltekit when it's imported like this import Glide from '@glidejs/glide';

@Mardoxx
Copy link

Mardoxx commented Sep 28, 2024

Also replicable in remix

@rpdave
Copy link

rpdave commented Oct 13, 2024

I ran into the same problem using Qwik framework. Here is how I solved it.

Problem

Using the documented import like

import Glide from "@glidejs/glide"

Results in the error [vite] The requested module '@glidejs/glide' does not provide an export named 'default'

Analysis

I noted that the file imported with the above import node_modules/.pnpm/@[email protected]/node_modules/@glidejs/glide/dist/glide.js runs an IIFE this was no good or not working.

Solution

Use alternate import from

import Glide from "@glidejs/glide/dist/glide.esm";

If you go to the source of the above file you can see the last line export { Glide as default };

Then you must use your frameworks client side execution model to run the ctor. For Qwik this was to use the hook useOnWindow

export const CustomSlider = component$<CustomSliderProps>(({ images }) => {
  useOnWindow(
    "load",
    $(() => {
      var glide = new Glide(".glide");
      glide.mount();
    }),
  );
....

I hope this helps

NOTE TS will still complain if you are using TS just mock the types by using the declare module '@glidejs/glide';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants