mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 08:33:58 +00:00
worker thread - using rollup config instead of plugin
This commit is contained in:
@@ -7,10 +7,9 @@ import { terser } from 'rollup-plugin-terser';
|
|||||||
import sveltePreprocess from 'svelte-preprocess';
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
import typescript from '@rollup/plugin-typescript';
|
import typescript from '@rollup/plugin-typescript';
|
||||||
import replace from '@rollup/plugin-replace';
|
import replace from '@rollup/plugin-replace';
|
||||||
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
|
// import webWorkerLoader from 'rollup-plugin-web-worker-loader';
|
||||||
import css from 'rollup-plugin-css-only';
|
import css from 'rollup-plugin-css-only';
|
||||||
|
|
||||||
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
const production = !process.env.ROLLUP_WATCH;
|
||||||
|
|
||||||
function serve() {
|
function serve() {
|
||||||
@@ -34,7 +33,27 @@ function serve() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default [
|
||||||
|
{
|
||||||
|
input: 'src/query/QueryParserWorker.js',
|
||||||
|
output: {
|
||||||
|
sourcemap: true,
|
||||||
|
format: 'iife',
|
||||||
|
file: 'public/build/QueryParserWorker.js',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
commonjs(),
|
||||||
|
resolve({
|
||||||
|
browser: true,
|
||||||
|
}),
|
||||||
|
|
||||||
|
// If we're building for production (npm run build
|
||||||
|
// instead of npm run dev), minify
|
||||||
|
production && terser(),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
input: 'src/main.ts',
|
input: 'src/main.ts',
|
||||||
output: {
|
output: {
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
@@ -102,9 +121,10 @@ export default {
|
|||||||
// instead of npm run dev), minify
|
// instead of npm run dev), minify
|
||||||
production && terser(),
|
production && terser(),
|
||||||
|
|
||||||
webWorkerLoader(),
|
// webWorkerLoader(),
|
||||||
],
|
],
|
||||||
watch: {
|
watch: {
|
||||||
clearScreen: true,
|
clearScreen: true,
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
import { handleCommandKeyDown } from '../commands/CommandListener.svelte';
|
import { handleCommandKeyDown } from '../commands/CommandListener.svelte';
|
||||||
import resizeObserver from '../utility/resizeObserver';
|
import resizeObserver from '../utility/resizeObserver';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import QueryParserWorker from 'web-worker:./QueryParserWorker';
|
// import QueryParserWorker from 'web-worker:./QueryParserWorker';
|
||||||
import queryParserWorkerFallback from './queryParserWorkerFallback';
|
import queryParserWorkerFallback from './queryParserWorkerFallback';
|
||||||
|
|
||||||
const EDITOR_ID = `svelte-ace-editor-div:${Math.floor(Math.random() * 10000000000)}`;
|
const EDITOR_ID = `svelte-ace-editor-div:${Math.floor(Math.random() * 10000000000)}`;
|
||||||
@@ -138,12 +138,14 @@
|
|||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (!queryParserWorker) {
|
if (!queryParserWorker) {
|
||||||
try {
|
try {
|
||||||
queryParserWorker = new QueryParserWorker();
|
queryParserWorker = new Worker('build/QueryParserWorker.js');
|
||||||
|
// console.log('WORKER', queryParserWorker);
|
||||||
queryParserWorker.onmessage = e => {
|
queryParserWorker.onmessage = e => {
|
||||||
processParserResult(e.data);
|
processParserResult(e.data);
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('WORKER ERROR, using fallback worker', err.message);
|
// console.error('WORKER ERROR', err);
|
||||||
|
console.log('WORKER ERROR, using fallback worker', err.message);
|
||||||
queryParserWorker = 'fallback';
|
queryParserWorker = 'fallback';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user