mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Load ot without script-loader
The ot library is tricky to load with Webpack, as it writes it's functions into a global `ot` object and does not export anything. I got it working using `exports-loader` to put the `ot` object into a CommonJS export and then forcing Webpack to only load using CommonJS. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
4f4a4cb747
commit
bd62e79f7d
4 changed files with 27 additions and 11 deletions
|
@ -133,7 +133,7 @@
|
||||||
"url": "https://shivering-isles.com"
|
"url": "https://shivering-isles.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"David Mehren",
|
"name": "David Mehren",
|
||||||
"email": "hedgedoc@herrmehren.de"
|
"email": "hedgedoc@herrmehren.de"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -163,6 +163,7 @@
|
||||||
"eslint-plugin-node": "11.1.0",
|
"eslint-plugin-node": "11.1.0",
|
||||||
"eslint-plugin-promise": "5.1.0",
|
"eslint-plugin-promise": "5.1.0",
|
||||||
"eslint-plugin-standard": "4.1.0",
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"exports-loader": "1.1.1",
|
||||||
"expose-loader": "1.0.3",
|
"expose-loader": "1.0.3",
|
||||||
"file-loader": "6.2.0",
|
"file-loader": "6.2.0",
|
||||||
"file-saver": "2.0.5",
|
"file-saver": "2.0.5",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-env browser, jquery */
|
/* eslint-env browser, jquery */
|
||||||
/* eslint no-console: ["error", { allow: ["warn", "error", "debug"] }] */
|
/* eslint no-console: ["error", { allow: ["warn", "error", "debug"] }] */
|
||||||
/* global Cookies, moment, serverurl,
|
/* global Cookies, moment, serverurl,
|
||||||
key, Dropbox, ot, hex2rgb, Visibility */
|
key, Dropbox, hex2rgb, Visibility */
|
||||||
|
|
||||||
import TurndownService from 'turndown'
|
import TurndownService from 'turndown'
|
||||||
import CodeMirror from 'codemirror/lib/codemirror.js'
|
import CodeMirror from 'codemirror/lib/codemirror.js'
|
||||||
|
@ -13,6 +13,8 @@ import Idle from 'Idle.Js'
|
||||||
|
|
||||||
import '../vendor/jquery-textcomplete/jquery.textcomplete'
|
import '../vendor/jquery-textcomplete/jquery.textcomplete'
|
||||||
|
|
||||||
|
import { ot } from '../vendor/ot/ot.min.js'
|
||||||
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import randomColor from 'randomcolor'
|
import randomColor from 'randomcolor'
|
||||||
import store from 'store'
|
import store from 'store'
|
||||||
|
|
|
@ -214,7 +214,6 @@ module.exports = {
|
||||||
index: [
|
index: [
|
||||||
'babel-polyfill',
|
'babel-polyfill',
|
||||||
'expose-loader?exposes=LZString!lz-string',
|
'expose-loader?exposes=LZString!lz-string',
|
||||||
'script-loader!ot',
|
|
||||||
'flowchart.js',
|
'flowchart.js',
|
||||||
'js-sequence-diagrams',
|
'js-sequence-diagrams',
|
||||||
'expose-loader?exposes=RevealMarkdown!reveal-markdown',
|
'expose-loader?exposes=RevealMarkdown!reveal-markdown',
|
||||||
|
@ -256,7 +255,6 @@ module.exports = {
|
||||||
'expose-loader?exposes=emojify!emojify.js',
|
'expose-loader?exposes=emojify!emojify.js',
|
||||||
'script-loader!gist-embed',
|
'script-loader!gist-embed',
|
||||||
'expose-loader?exposes=LZString!lz-string',
|
'expose-loader?exposes=LZString!lz-string',
|
||||||
'script-loader!ot',
|
|
||||||
'flowchart.js',
|
'flowchart.js',
|
||||||
'js-sequence-diagrams',
|
'js-sequence-diagrams',
|
||||||
'expose-loader?exposes=Viz!viz.js',
|
'expose-loader?exposes=Viz!viz.js',
|
||||||
|
@ -350,7 +348,6 @@ module.exports = {
|
||||||
modules: ['node_modules'],
|
modules: ['node_modules'],
|
||||||
extensions: ['.js'],
|
extensions: ['.js'],
|
||||||
alias: {
|
alias: {
|
||||||
ot: path.join(__dirname, 'public/vendor/ot/ot.min.js'),
|
|
||||||
mermaid: path.join(__dirname, 'node_modules/mermaid/dist/mermaid.min.js'),
|
mermaid: path.join(__dirname, 'node_modules/mermaid/dist/mermaid.min.js'),
|
||||||
handlebars: path.join(__dirname, 'node_modules/handlebars/dist/handlebars.min.js'),
|
handlebars: path.join(__dirname, 'node_modules/handlebars/dist/handlebars.min.js'),
|
||||||
'gist-embed': path.join(__dirname, 'node_modules/gist-embed/gist-embed.min.js'),
|
'gist-embed': path.join(__dirname, 'node_modules/gist-embed/gist-embed.min.js'),
|
||||||
|
@ -382,6 +379,19 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: require.resolve(path.join(__dirname, 'public/vendor/ot/ot.min.js')),
|
||||||
|
use: {
|
||||||
|
loader: 'exports-loader',
|
||||||
|
options: {
|
||||||
|
type: 'commonjs',
|
||||||
|
exports: ['ot']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parser: {
|
||||||
|
amd: false
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Idle.js must be imported as CommonJS, as its AMD export is broken
|
// Idle.js must be imported as CommonJS, as its AMD export is broken
|
||||||
test: require.resolve('Idle.Js'),
|
test: require.resolve('Idle.Js'),
|
||||||
|
|
15
yarn.lock
15
yarn.lock
|
@ -568,7 +568,6 @@
|
||||||
|
|
||||||
"Idle.Js@git+https://github.com/shawnmclean/Idle.js":
|
"Idle.Js@git+https://github.com/shawnmclean/Idle.js":
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
uid db9beb3483a460ad638ec947867720f0ed066a62
|
|
||||||
resolved "git+https://github.com/shawnmclean/Idle.js#db9beb3483a460ad638ec947867720f0ed066a62"
|
resolved "git+https://github.com/shawnmclean/Idle.js#db9beb3483a460ad638ec947867720f0ed066a62"
|
||||||
|
|
||||||
JSV@^4.0.x:
|
JSV@^4.0.x:
|
||||||
|
@ -2276,7 +2275,6 @@ code-point-at@^1.0.0:
|
||||||
|
|
||||||
"codemirror@git+https://github.com/hedgedoc/CodeMirror.git":
|
"codemirror@git+https://github.com/hedgedoc/CodeMirror.git":
|
||||||
version "5.58.2"
|
version "5.58.2"
|
||||||
uid f780b569b3717cdff4c8507538cc63101bfa02e1
|
|
||||||
resolved "git+https://github.com/hedgedoc/CodeMirror.git#f780b569b3717cdff4c8507538cc63101bfa02e1"
|
resolved "git+https://github.com/hedgedoc/CodeMirror.git#f780b569b3717cdff4c8507538cc63101bfa02e1"
|
||||||
|
|
||||||
collection-visit@^1.0.0:
|
collection-visit@^1.0.0:
|
||||||
|
@ -3287,7 +3285,6 @@ detect-libc@^1.0.2:
|
||||||
|
|
||||||
"diff-match-patch@git+https://github.com/hackmdio/diff-match-patch.git":
|
"diff-match-patch@git+https://github.com/hackmdio/diff-match-patch.git":
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
uid c2f8fb9d69aa9490b764850aa86ba442c93ccf78
|
|
||||||
resolved "git+https://github.com/hackmdio/diff-match-patch.git#c2f8fb9d69aa9490b764850aa86ba442c93ccf78"
|
resolved "git+https://github.com/hackmdio/diff-match-patch.git#c2f8fb9d69aa9490b764850aa86ba442c93ccf78"
|
||||||
|
|
||||||
diff@5.0.0:
|
diff@5.0.0:
|
||||||
|
@ -3973,6 +3970,15 @@ expand-range@^1.8.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
fill-range "^2.1.0"
|
fill-range "^2.1.0"
|
||||||
|
|
||||||
|
exports-loader@1.1.1:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/exports-loader/-/exports-loader-1.1.1.tgz#88c9a6877ee6a5519d7c41a016bdd99148421e69"
|
||||||
|
integrity sha512-CmyhIR2sJ3KOfVsHjsR0Yvo+0lhRhRMAevCbB8dhTVLHsZPs0lCQTvRmR9YNvBXDBxUuhmCE2f54KqEjZUaFrg==
|
||||||
|
dependencies:
|
||||||
|
loader-utils "^2.0.0"
|
||||||
|
schema-utils "^3.0.0"
|
||||||
|
source-map "^0.6.1"
|
||||||
|
|
||||||
expose-loader@1.0.3:
|
expose-loader@1.0.3:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/expose-loader/-/expose-loader-1.0.3.tgz#5686d3b78cac8831c4af11c3dc361563deb8a9c0"
|
resolved "https://registry.yarnpkg.com/expose-loader/-/expose-loader-1.0.3.tgz#5686d3b78cac8831c4af11c3dc361563deb8a9c0"
|
||||||
|
@ -5611,7 +5617,6 @@ js-cookie@2.2.1:
|
||||||
|
|
||||||
"js-sequence-diagrams@git+https://github.com/hedgedoc/js-sequence-diagrams.git":
|
"js-sequence-diagrams@git+https://github.com/hedgedoc/js-sequence-diagrams.git":
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
uid bda0e49b6c2754f3c7158b1dfb9ccf26efc24b39
|
|
||||||
resolved "git+https://github.com/hedgedoc/js-sequence-diagrams.git#bda0e49b6c2754f3c7158b1dfb9ccf26efc24b39"
|
resolved "git+https://github.com/hedgedoc/js-sequence-diagrams.git#bda0e49b6c2754f3c7158b1dfb9ccf26efc24b39"
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash "4.17.x"
|
lodash "4.17.x"
|
||||||
|
@ -6197,7 +6202,6 @@ lutim@^1.0.2:
|
||||||
|
|
||||||
"lz-string@git+https://github.com/hackmdio/lz-string.git":
|
"lz-string@git+https://github.com/hackmdio/lz-string.git":
|
||||||
version "1.4.4"
|
version "1.4.4"
|
||||||
uid efd1f64676264d6d8871b01f4f375fc6ef4f9022
|
|
||||||
resolved "git+https://github.com/hackmdio/lz-string.git#efd1f64676264d6d8871b01f4f375fc6ef4f9022"
|
resolved "git+https://github.com/hackmdio/lz-string.git#efd1f64676264d6d8871b01f4f375fc6ef4f9022"
|
||||||
|
|
||||||
make-dir@^1.0.0:
|
make-dir@^1.0.0:
|
||||||
|
@ -6506,7 +6510,6 @@ messageformat@^2.3.0:
|
||||||
|
|
||||||
"meta-marked@git+https://github.com/hedgedoc/meta-marked":
|
"meta-marked@git+https://github.com/hedgedoc/meta-marked":
|
||||||
version "0.4.5"
|
version "0.4.5"
|
||||||
uid "3002adae670a6de0a845f3da7a7223d458c20d76"
|
|
||||||
resolved "git+https://github.com/hedgedoc/meta-marked#3002adae670a6de0a845f3da7a7223d458c20d76"
|
resolved "git+https://github.com/hedgedoc/meta-marked#3002adae670a6de0a845f3da7a7223d458c20d76"
|
||||||
dependencies:
|
dependencies:
|
||||||
js-yaml "~4.1.0"
|
js-yaml "~4.1.0"
|
||||||
|
|
Loading…
Reference in a new issue