Topic: webpack + symfony + mdb.js:9192 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

IMAJIM free asked 4 years ago


Hello, i've installed MDB pro on my symfony project with downloaded zip package (unzip to /templates/assets/mdb/)

my webpack.config.js :

var Encore = require('@symfony/webpack-encore');
if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    .addEntry('front', './templates/assets/js/front/front.js')
    .addEntry('annonces', './templates/assets/js/front/annonces.js')
    .addEntry('annonce', './templates/assets/js/front/annonce.js')
    .addEntry('login', './templates/assets/js/front/login.js')
    .addEntry('admin', './templates/assets/js/admin/admin.js')
    .addEntry('homepage', './templates/assets/js/front/homepage.js')
    .addEntry('agence', './templates/assets/js/front/agence.js')
    .addStyleEntry('extranet', './templates/assets/css/front/extranet.scss')
    .addStyleEntry('agences', './templates/assets/css/front/agences.scss')
    .addStyleEntry('mentions', './templates/assets/css/front/mentions.scss')


    .copyFiles({
        from: './templates/assets/images',
        to: 'images/[path][name].[ext]'
    })
    .splitEntryChunks()

    .enableSingleRuntimeChunk()
    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())
    .enableVersioning(Encore.isProduction())

    .configureBabel(() => {
    }, {
        useBuiltIns: 'usage',
        corejs: 3
    })
    .enableSassLoader()
    .enablePostCssLoader()
    .autoProvidejQuery()
;
module.exports = Encore.getWebpackConfig();

my homepage.js :

import '../../css/front/homepage.scss';
import $ from "jquery";
import '../../mdb/css/mdb.css';

require('../../mdb/js/bootstrap');
require('../../mdb/js/mdb');

var JsVars = null;
$(document).ready(function () {
    $('.select2').select2();
    $('.btn-group').click(function(){
        $(this).button('toggle');
    });
});

no problem on compilation, but in webdeveloper console i've got this issue :

mdb.js:9192 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
    at Object.<anonymous> (mdb.js:9192)
    at Object.push../templates/assets/mdb/js/mdb.js (mdb.js:9195)
    at i (mdb.js:36)
    at Module.<anonymous> (mdb.js:20789)
    at i (mdb.js:36)
    at Object.push../templates/assets/mdb/js/mdb.js (mdb.js:9091)
    at i (mdb.js:36)
    at mdb.js:70
    at Object.<anonymous> (mdb.js:26)
    at Object../templates/assets/mdb/js/mdb.js (homepage.js:4983)

Grzegorz Bujański staff commented 4 years ago

Hi. Unfortunately we don't officially support symphony and I'm not a symfony expert, but have you tried to add MDB in webpack.config.js instead of homepage.js?


Johann ESPANET free commented 3 years ago

i have the same problem, have you find a solution?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.19.1
  • Device: imac
  • Browser: all
  • OS: mac os
  • Provided sample code: No
  • Provided link: No