Standardised module loading system & fixed build system

Fixed broken build system in broken webpack version.
Also updates module system to standardise on ES6 import/exports,
Especially since babel has changed it's 'default' logic for the old
module system.
This commit is contained in:
Dan Brown 2018-11-09 21:17:35 +00:00
parent 5b36ddb12f
commit e3230f8f21
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
37 changed files with 384 additions and 3372 deletions

3519
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,9 +10,9 @@
"permissions": "chown -R $USER:$USER bootstrap/cache storage public/uploads"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/core": "^7.1.5",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-env": "^7.1.5",
"autoprefixer": "^8.6.5",
"babel-loader": "^8.0.4",
"css-loader": "^0.28.11",
@ -24,8 +24,8 @@
"sass-loader": "^7.1.0",
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.3.0",
"webpack": "^4.24.0",
"webpack-cli": "^2.1.5"
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2"
},
"dependencies": {
"axios": "^0.18.0",

View File

@ -56,4 +56,4 @@ class BackToTop {
}
module.exports = BackToTop;
export default BackToTop;

View File

@ -69,4 +69,4 @@ class ChapterToggle {
}
module.exports = ChapterToggle;
export default ChapterToggle;

View File

@ -34,4 +34,4 @@ class Collapsible {
}
module.exports = Collapsible;
export default Collapsible;

View File

@ -45,4 +45,4 @@ class DropDown {
}
module.exports = DropDown;
export default DropDown;

View File

@ -44,4 +44,4 @@ class EditorToolbox {
}
module.exports = EditorToolbox;
export default EditorToolbox;

View File

@ -44,4 +44,4 @@ class EntitySelectorPopup {
}
}
module.exports = EntitySelectorPopup;
export default EntitySelectorPopup;

View File

@ -115,4 +115,4 @@ class EntitySelector {
}
module.exports = EntitySelector;
export default EntitySelector;

View File

@ -62,4 +62,4 @@ class ExpandToggle {
}
module.exports = ExpandToggle;
export default ExpandToggle;

View File

@ -19,4 +19,4 @@ class HomepageControl {
}
module.exports = HomepageControl;
export default HomepageControl;

View File

@ -56,4 +56,4 @@ class ImagePicker {
}
module.exports = ImagePicker;
export default ImagePicker;

View File

@ -1,30 +1,51 @@
import dropdown from "./dropdown";
import overlay from "./overlay";
import backToTop from "./back-to-top";
import notification from "./notification";
import chapterToggle from "./chapter-toggle";
import expandToggle from "./expand-toggle";
import entitySelectorPopup from "./entity-selector-popup";
import entitySelector from "./entity-selector";
import sidebar from "./sidebar";
import pagePicker from "./page-picker";
import pageComments from "./page-comments";
import wysiwygEditor from "./wysiwyg-editor";
import markdownEditor from "./markdown-editor";
import editorToolbox from "./editor-toolbox";
import imagePicker from "./image-picker";
import collapsible from "./collapsible";
import toggleSwitch from "./toggle-switch";
import pageDisplay from "./page-display";
import shelfSort from "./shelf-sort";
import homepageControl from "./homepage-control";
let componentMapping = {
'dropdown': require('./dropdown'),
'overlay': require('./overlay'),
'back-to-top': require('./back-top-top'),
'notification': require('./notification'),
'chapter-toggle': require('./chapter-toggle'),
'expand-toggle': require('./expand-toggle'),
'entity-selector-popup': require('./entity-selector-popup'),
'entity-selector': require('./entity-selector'),
'sidebar': require('./sidebar'),
'page-picker': require('./page-picker'),
'page-comments': require('./page-comments'),
'wysiwyg-editor': require('./wysiwyg-editor'),
'markdown-editor': require('./markdown-editor'),
'editor-toolbox': require('./editor-toolbox'),
'image-picker': require('./image-picker'),
'collapsible': require('./collapsible'),
'toggle-switch': require('./toggle-switch'),
'page-display': require('./page-display'),
'shelf-sort': require('./shelf-sort'),
'homepage-control': require('./homepage-control'),
const componentMapping = {
'dropdown': dropdown,
'overlay': overlay,
'back-to-top': backToTop,
'notification': notification,
'chapter-toggle': chapterToggle,
'expand-toggle': expandToggle,
'entity-selector-popup': entitySelectorPopup,
'entity-selector': entitySelector,
'sidebar': sidebar,
'page-picker': pagePicker,
'page-comments': pageComments,
'wysiwyg-editor': wysiwygEditor,
'markdown-editor': markdownEditor,
'editor-toolbox': editorToolbox,
'image-picker': imagePicker,
'collapsible': collapsible,
'toggle-switch': toggleSwitch,
'page-display': pageDisplay,
'shelf-sort': shelfSort,
'homepage-control': homepageControl,
};
window.components = {};
let componentNames = Object.keys(componentMapping);
const componentNames = Object.keys(componentMapping);
/**
* Initialize components of the given name within the given element.

View File

@ -1,8 +1,8 @@
const MarkdownIt = require("markdown-it");
const mdTasksLists = require('markdown-it-task-lists');
const code = require('../services/code');
import MarkdownIt from "markdown-it";
import mdTasksLists from 'markdown-it-task-lists';
import code from '../services/code';
const DrawIO = require('../services/drawio');
import DrawIO from "../services/drawio";
class MarkdownEditor {
@ -427,4 +427,4 @@ class MarkdownEditor {
}
module.exports = MarkdownEditor ;
export default MarkdownEditor ;

View File

@ -43,4 +43,4 @@ class Notification {
}
module.exports = Notification;
export default Notification;

View File

@ -36,4 +36,4 @@ class Overlay {
}
module.exports = Overlay;
export default Overlay;

View File

@ -1,4 +1,4 @@
const MarkdownIt = require("markdown-it");
import MarkdownIt from "markdown-it";
const md = new MarkdownIt({ html: false });
class PageComments {
@ -172,4 +172,4 @@ class PageComments {
}
module.exports = PageComments;
export default PageComments;

View File

@ -233,4 +233,4 @@ class PageDisplay {
}
}
module.exports = PageDisplay;
export default PageDisplay;

View File

@ -59,4 +59,4 @@ function toggleElem(elem, show) {
elem.style.display = show ? display : 'none';
}
module.exports = PagePicker;
export default PagePicker;

View File

@ -1,3 +1,4 @@
import "jquery-sortable";
class ShelfSort {
@ -9,9 +10,8 @@ class ShelfSort {
}
initSortable() {
const sortable = require('jquery-sortable');
const placeHolderContent = this.getPlaceholderHTML();
// TODO - Load sortable at this point
return $('.scroll-box').sortable({
group: 'shelf-books',
exclude: '.instruction,.scroll-box-placeholder',
@ -68,4 +68,4 @@ class ShelfSort {
}
module.exports = ShelfSort;
export default ShelfSort;

View File

@ -13,4 +13,4 @@ class Sidebar {
}
module.exports = Sidebar;
export default Sidebar;

View File

@ -16,4 +16,4 @@ class ToggleSwitch {
}
module.exports = ToggleSwitch;
export default ToggleSwitch;

View File

@ -1,5 +1,5 @@
const Code = require('../services/code');
const DrawIO = require('../services/drawio');
import Code from "../services/code";
import DrawIO from "../services/drawio";
/**
* Handle pasting images from clipboard.
@ -593,4 +593,4 @@ class WysiwygEditor {
}
module.exports = WysiwygEditor;
export default WysiwygEditor;

View File

@ -1,27 +1,27 @@
const CodeMirror = require('codemirror');
const Clipboard = require("clipboard");
import CodeMirror from "codemirror";
import Clipboard from "clipboard";
// Modes
require('codemirror/mode/css/css');
require('codemirror/mode/clike/clike');
require('codemirror/mode/diff/diff');
require('codemirror/mode/go/go');
require('codemirror/mode/htmlmixed/htmlmixed');
require('codemirror/mode/javascript/javascript');
require('codemirror/mode/markdown/markdown');
require('codemirror/mode/nginx/nginx');
require('codemirror/mode/php/php');
require('codemirror/mode/powershell/powershell');
require('codemirror/mode/python/python');
require('codemirror/mode/ruby/ruby');
require('codemirror/mode/shell/shell');
require('codemirror/mode/sql/sql');
require('codemirror/mode/toml/toml');
require('codemirror/mode/xml/xml');
require('codemirror/mode/yaml/yaml');
import 'codemirror/mode/css/css';
import 'codemirror/mode/clike/clike';
import 'codemirror/mode/diff/diff';
import 'codemirror/mode/go/go';
import 'codemirror/mode/htmlmixed/htmlmixed';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/markdown/markdown';
import 'codemirror/mode/nginx/nginx';
import 'codemirror/mode/php/php';
import 'codemirror/mode/powershell/powershell';
import 'codemirror/mode/python/python';
import 'codemirror/mode/ruby/ruby';
import 'codemirror/mode/shell/shell';
import 'codemirror/mode/sql/sql';
import 'codemirror/mode/toml/toml';
import 'codemirror/mode/xml/xml';
import 'codemirror/mode/yaml/yaml';
// Addons
require('codemirror/addon/scroll/scrollpastend');
import 'codemirror/addon/scroll/scrollpastend';
const modeMap = {
css: 'css',
@ -255,7 +255,7 @@ function getMetaKey() {
return mac ? "Cmd" : "Ctrl";
}
module.exports = {
export default {
highlight: highlight,
wysiwygView: wysiwygView,
popupEditor: popupEditor,

View File

@ -66,4 +66,4 @@ function drawPostMessage(data) {
iFrame.contentWindow.postMessage(JSON.stringify(data), '*');
}
module.exports = {show, close};
export default {show, close};

View File

@ -25,4 +25,4 @@ class Events {
}
}
module.exports = Events;
export default Events;

View File

@ -107,4 +107,4 @@ class Translator {
}
module.exports = Translator;
export default Translator;

View File

@ -1,5 +1,5 @@
const draggable = require('vuedraggable');
const dropzone = require('./components/dropzone');
import draggable from "vuedraggable";
import dropzone from "./components/dropzone";
function mounted() {
this.pageId = this.$el.getAttribute('page-id');
@ -137,6 +137,6 @@ let methods = {
};
module.exports = {
export default {
data, methods, mounted, components,
};

View File

@ -1,4 +1,4 @@
const codeLib = require('../services/code');
import codeLib from "../services/code";
const methods = {
show() {
@ -37,7 +37,7 @@ const data = {
callback: null
};
module.exports = {
export default {
methods,
data
};

View File

@ -125,4 +125,4 @@ const methods = {
};
module.exports = {template, data, props, methods};
export default {template, data, props, methods};

View File

@ -1,4 +1,4 @@
const DropZone = require("dropzone");
import DropZone from "dropzone";
const template = `
<div class="dropzone-container">
@ -60,7 +60,7 @@ const methods = {
}
};
module.exports = {
export default {
template,
props,
mounted,

View File

@ -39,6 +39,6 @@ function mounted() {
this.type = this.$el.getAttribute('entity-type');
}
module.exports = {
export default {
data, computed, methods, mounted
};

View File

@ -1,7 +1,5 @@
import * as Dates from "../services/dates";
const dropzone = require('./components/dropzone');
import dropzone from "./components/dropzone";
let page = 0;
let previousClickTime = 0;
@ -193,7 +191,7 @@ function mounted() {
baseUrl = window.baseUrl('/images/' + this.imageType + '/all/')
}
module.exports = {
export default {
mounted,
methods,
data,

View File

@ -145,6 +145,6 @@ let computed = {
}
};
module.exports = {
export default {
mounted, data, methods, computed,
};

View File

@ -188,6 +188,6 @@ function created() {
this.dateParse(this.termString);
}
module.exports = {
export default {
data, computed, methods, created
};

View File

@ -1,5 +1,5 @@
const draggable = require('vuedraggable');
const autosuggest = require('./components/autosuggest');
import draggable from 'vuedraggable';
import autosuggest from './components/autosuggest';
let data = {
entityId: false,
@ -63,6 +63,6 @@ function mounted() {
});
}
module.exports = {
export default {
data, methods, mounted, components, directives
};

View File

@ -1,17 +1,25 @@
const Vue = require("vue");
import Vue from "vue";
function exists(id) {
return document.getElementById(id) !== null;
}
import searchSystem from "./search";
import entityDashboard from "./entity-dashboard";
import codeEditor from "./code-editor";
import imageManager from "./image-manager";
import tagManager from "./tag-manager";
import attachmentManager from "./attachment-manager";
import pageEditor from "./page-editor";
let vueMapping = {
'search-system': require('./search'),
'entity-dashboard': require('./entity-dashboard'),
'code-editor': require('./code-editor'),
'image-manager': require('./image-manager'),
'tag-manager': require('./tag-manager'),
'attachment-manager': require('./attachment-manager'),
'page-editor': require('./page-editor'),
'search-system': searchSystem,
'entity-dashboard': entityDashboard,
'code-editor': codeEditor,
'image-manager': imageManager,
'tag-manager': tagManager,
'attachment-manager': attachmentManager,
'page-editor': pageEditor,
};
window.vues = {};