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 inoptions.parent
- Also now I don't know how to pass the parameters from my HTML to the class