diff --git a/_scripts/webpack.web.config.js b/_scripts/webpack.web.config.js index 9fcbce40..e14e0e25 100644 --- a/_scripts/webpack.web.config.js +++ b/_scripts/webpack.web.config.js @@ -111,6 +111,7 @@ const config = { fs: 'empty', net: 'empty', tls: 'empty', + child_process: 'empty' }, plugins: [ // new WriteFilePlugin(), diff --git a/src/process/comment-module-controller.js b/src/process/comment-module-controller.js index 557eb410..2fc252d1 100644 --- a/src/process/comment-module-controller.js +++ b/src/process/comment-module-controller.js @@ -1,5 +1,4 @@ const ModuleScraper = require('yt-comment-scraper') -const fs = require('fs') let scraper = null let currentSort = null let currentVideoId = null diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.js b/src/renderer/components/watch-video-comments/watch-video-comments.js index 32b07a88..9093dac0 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.js +++ b/src/renderer/components/watch-video-comments/watch-video-comments.js @@ -7,6 +7,8 @@ import FtTimestampCatcher from '../../components/ft-timestamp-catcher/ft-timesta import autolinker from 'autolinker' import { fork } from 'child_process' import path from 'path' +// eslint-disable-next-line +import commentControllerRelativePath from 'file-loader!../../../process/comment-module-controller.js' export default Vue.extend({ name: 'WatchVideoComments', @@ -39,6 +41,10 @@ export default Vue.extend({ } }, computed: { + isDev: function () { + return process.env.NODE_ENV === 'development' + }, + backendPreference: function () { return this.$store.getters.getBackendPreference }, @@ -140,9 +146,17 @@ export default Vue.extend({ getCommentDataLocal: function () { // we need the path from the working directory to fork correctly if (this.commentProcess === null) { - this.commentProcess = fork('./src/process/comment-module-controller.js', ['args'], { + let modulePath + if (this.isDev) { + modulePath = '../../../process/comment-module-controller.js' + } else { + modulePath = commentControllerRelativePath + } + + this.commentProcess = fork(path.join(__dirname, modulePath), ['args'], { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }) + this.commentProcess.on('message', (msg) => { if (msg.error === null) { const commentJSON = JSON.parse(msg.comments) @@ -212,6 +226,7 @@ export default Vue.extend({ } }) } + this.commentProcess.send({ id: this.id, sortNewest: this.sortNewest }) },