1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-21 14:19:42 +02:00

Code splitting now works through awaited import (#6)

This commit is contained in:
Peter Savchenko 2018-10-03 12:26:41 +03:00 committed by GitHub
parent e7e64cea3e
commit 5c0560a2ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 214 additions and 500 deletions

View file

@ -1,8 +1,10 @@
/**
* Module for pages create/edit
*/
module.exports = class Writing {
export default class Writing {
constructor(){
this.editorWrapper = null;
this.editor = null;
}
/**
@ -14,15 +16,14 @@ module.exports = class Writing {
moduleEl.appendChild(this.editorWrapper);
this.loadEditor().then(() => {
console.log('Editor loaded');
this.loadEditor().then((editor) => {
this.editor = editor;
})
};
loadEditor(){
return import(/* webpackChunkName: "codex-editor" */ 'codex.editor').then(({ default: CodexEditor }) => {
console.log('codex-editor', new CodexEditor());
}).catch(error => 'An error occurred while loading CodeX Editor');
async loadEditor(){
const {default: Editor} = await import(/* webpackChunkName: "editor" */ './../classes/editor');
return new Editor();
}
};
}