I
I
Ilya Kochkin2021-09-08 21:15:38
webpack
Ilya Kochkin, 2021-09-08 21:15:38

Why does import throw an error _splidejs_splide__WEBPACK_IMPORTED_MODULE_0__ is not a constructor?

Good afternoon, I'm trying to use the Splide slider, webpack is used for assembly, more precisely gulp with the webpack setting,
here is the task for scripts

function scripts() {
  return src(["app/js/*.js", "!app/js/*.min.js"])
    .pipe(
      webpackStream(
        {
          mode: 'development',
      
          performance: {hints: false},
          module: {
            rules: [
              {
                test: /\.m?js$/,
                exclude: /(node_modules)/,
                use: {
                  loader: "babel-loader",
                  options: {
                    presets: ["@babel/preset-env"],
                    plugins: ["babel-plugin-root-import"],
                  },
                },
              },
            ],
          },
          optimization: {
            minimize: true,
            minimizer: [
              new TerserPlugin({
                terserOptions: {format: {comments: false}},
                extractComments: false,
              }),
            ],
          },
        },
        webpack
      )
    )
    .on("error", function handleError() {
      this.emit("end");
    })
    .pipe(concat("app.min.js"))
    .pipe(dest("app/js"))
    .pipe(browserSync.stream());
}


in js I use import
import Splide from '@splidejs/splide';
var splide = new Splide( '.splide' ).mount();

in console i get error
6138fdc081934205373074.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question