I am trying to build a module using the module-bundler ParcelJS. I would like this certain module to be import-friendly:
- it should be import friendly (ES6)
- It should be require friendly (Node)
- It should be script-src friendly (Browser)
- It should support the UMD convention...
I tried the following:
TestClass.js
export class TestClass {
constructor(msg) {
this.msg = msg;
this.init();
}
init() {
document.body.insertAdjacentHTML('afterbegin', `
<div class="message">${this.msg}</div>`);
}
}
index.js (file that creates the bundle)
//import styling for TestClass
import styles from '../css/styles';
//import class TestClass library
import { TestClass } from './TestClass';
//export TestClass
export default TestClass;
Trying to create the universal bundle by running: parcel index.js --global TestClass
Is there someone who can give me more information/help on exporting modules using parceljs?