appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 471 forks source link

Unable to load vue-slider ReferenceError: require is not defined (Vue.JS/Vite) #2208

Open alancwoo opened 1 year ago

alancwoo commented 1 year ago

Affected Projects Vue.JS 2.7.14 with Vite 4.1.4

Library Version: 1.33.13

Describe the bug After building, the browser throws an error trying import the RangeSlider component: Unable to load vue-slider ReferenceError: require is not defined. Looking at the 3.x-rc, the code has been updated from:

1.33.13: @appbase-io/reactivesearch-vue/dist/es/ssr-03607d84.js

components['vue-slider-component'] = require('vue-slider-component');

to

3.0.0-rc.2: @appbase-io/reactivesearch-vue/dist/es/ssr-c630ccb9.js

  try {
    if (typeof window !== 'undefined') {
      components['vue-slider-component'] = function () {
        return import('vue-slider-component');
      };
    }
  }

Patching this removes the error but the slider does not initialize.

To Reproduce

Build a vue2/vite app, add a rangeslider and build with vite build

Expected behavior

RangeSlider component imports without error

Desktop (please complete the following information):