0

I want to switch from gulp to webpack but I am facing some issues that I can't figure out.

First, I'm making an editor, and with gulp I used to instantiate the editor this way:

new RSMDE({
    variables: vars,
    element: document.getElementById('mdediror'),
    initialValue:
    '# EasyMDE \n Go ahead, play around with the editor! Be sure to check out **bold**, *italic* and ~~strikethrough~~ styling, [links](https://google.com) and all the other features. You can type the Markdown syntax, use the toolbar, or use shortcuts like `ctrl-b` or `cmd-b`.',
    });

And in my editor file I used to have this:

// Importing libraries here.

function RSMDE(options) {
   // Handle options parameter
    options = options || {};

    // Used later to refer to it"s parent
    options.parent = this;

    var autoDownload = true;
    // Editor code goes here
    ....
}
module.exports = RSMDE;

But Now I want to switch to webpack, but I'm facing a problem when I compile. I get this error: Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

I've changed module.exports = RSMDE; with export default RSMDE the problem goes away, but when I change the function RSMDE(options){} to class RSMDE so the code will be like this :

// Importing libraries here.

class RSMDE {
   // Handle options parameter
    options = options || {};

    // Used later to refer to it"s parent
    options.parent = this;

    var autoDownload = true;
    // Editor code goes here
    ....
}
export default RSMDE;

But now I get a different error:

  • Unexpected token => this error is in options.parent
  • Also now I don't know how to pass the parameters from my HTML to the class
Felipe
  • 10,606
  • 5
  • 40
  • 57
  • Have a look https://stackoverflow.com/a/53399292/3390200 – SuperDJ Apr 22 '19 at 15:29
  • Gulp is a task runner that can be used for builds, webpack is a build system. You don't show either your gulp file nor your webpack config, so we can't see what you have done to try and "convert". – crashmstr Apr 22 '19 at 15:31

0 Answers0