KingSora / OverlayScrollbars

A javascript scrollbar plugin that hides the native scrollbars, provides custom styleable overlay scrollbars, and preserves the native functionality and feel.
https://kingsora.github.io/OverlayScrollbars
MIT License
3.78k stars 214 forks source link

Incompatibility with Nuxt 3 for SSG #536

Closed chrism-bc closed 1 year ago

chrism-bc commented 1 year ago

At present, it seems attempting SSG via nuxt 3 is broken with overlay scrollbars. Trying to do so returns the following

[nuxt] [request error] [unhandled] [500] Named export 'OverlayScrollbarsComponent' not found. The requested module 'file:///path-to-project/node_modules/overlayscrollbars-vue/overlayscrollbars-vue.umd.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'file:///home/chris/project/analyticsproject/analytics/web/node_modules/overlayscrollbars-vue/overlayscrollbars-vue.umd.js';
const { OverlayScrollbarsComponent } = pkg;

To Reproduce: Import and use OverlayScrollbarsComponent in a Nuxt 3 project and attempt SSG via npm run generate

Expected behavior Vite should be able to handle importing the module without issue

KingSora commented 1 year ago

Good day @chrism-bc :)

Thats seems weird.. Are you able to provide a reproduction repository or example? Otherwise its hard for me to pinpoint the issue here

KingSora commented 1 year ago

@chrism-bc I've releases overlayscrollbars-vue v0.5.2 which should fix that issue.

Thanks for the report, in case the new release didn't fix the issue please don't hesitate to re-open this issue or open a new one

Ardear commented 11 months ago

I meet the same problem with overlayscrollbars-react:0.5.2 in remix:2.0.0

KingSora commented 11 months ago

@Ardear I'm not 100% sure why this happens since all OverlayScrollbars packages are cjs and esm compatible. I believe it could be a bug on remix side. What I found out is that if you add the following to your remix.config.js it will resolve the issue:

/** @type {import('@remix-run/dev').AppConfig} */
export default {
  serverDependenciesToBundle: [/^overlayscrollbars/],
};
Ardear commented 11 months ago

@KingSora Thank you