one more optimalization of plugin size & load time

This commit is contained in:
Jan Prochazka
2021-05-20 08:55:50 +02:00
parent 0200c7c78b
commit e43fa96e34
19 changed files with 74 additions and 26 deletions

View File

@@ -1,5 +1,8 @@
const shell = require('./shell'); const shell = require('./shell');
const processArgs = require('./utility/processArgs'); const processArgs = require('./utility/processArgs');
const dbgateTools = require('dbgate-tools');
global['DBGATE_TOOLS'] = dbgateTools;
if (processArgs.startProcess) { if (processArgs.startProcess) {
const proc = require('./proc'); const proc = require('./proc');

View File

@@ -4,6 +4,8 @@
}; };
async function loadPlugins(pluginsDict, installedPlugins) { async function loadPlugins(pluginsDict, installedPlugins) {
window['DBGATE_TOOLS'] = dbgateTools;
const newPlugins = {}; const newPlugins = {};
for (const installed of installedPlugins || []) { for (const installed of installedPlugins || []) {
if (!_.keys(pluginsDict).includes(installed.name)) { if (!_.keys(pluginsDict).includes(installed.name)) {
@@ -63,6 +65,7 @@
import { useInstalledPlugins } from '../utility/metadataLoaders'; import { useInstalledPlugins } from '../utility/metadataLoaders';
import { buildFileFormats } from './fileformats'; import { buildFileFormats } from './fileformats';
import { buildThemes } from './themes'; import { buildThemes } from './themes';
import dbgateTools from 'dbgate-tools';
let pluginsDict = {}; let pluginsDict = {};
const installedPlugins = useInstalledPlugins(); const installedPlugins = useInstalledPlugins();

View File

@@ -15,6 +15,12 @@ var config = {
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,

View File

@@ -15,6 +15,12 @@ var config = {
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,

View File

@@ -1,4 +1,4 @@
const SqlDumper = require('dbgate-tools/lib/SqlDumper'); const { SqlDumper } = global.DBGATE_TOOLS;
class Dumper extends SqlDumper {} class Dumper extends SqlDumper {}

View File

@@ -1,4 +1,4 @@
const driverBase = require('dbgate-tools/lib/driverBase'); const { driverBase } = global.DBGATE_TOOLS;
const Dumper = require('./Dumper'); const Dumper = require('./Dumper');
const mongoIdRegex = /^[0-9a-f]{24}$/; const mongoIdRegex = /^[0-9a-f]{24}$/;

View File

@@ -15,6 +15,12 @@ var config = {
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,

View File

@@ -1,4 +1,4 @@
const SqlDumper = require('dbgate-tools/lib/SqlDumper'); const { SqlDumper } = global.DBGATE_TOOLS;
class MsSqlDumper extends SqlDumper { class MsSqlDumper extends SqlDumper {
autoIncrement() { autoIncrement() {

View File

@@ -1,4 +1,4 @@
const driverBase = require('dbgate-tools/lib/driverBase'); const { driverBase } = global.DBGATE_TOOLS;
const MsSqlDumper = require('./MsSqlDumper'); const MsSqlDumper = require('./MsSqlDumper');
/** @type {import('dbgate-types').SqlDialect} */ /** @type {import('dbgate-types').SqlDialect} */

View File

@@ -15,6 +15,12 @@ var config = {
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// optimization: { // optimization: {
// minimize: false, // minimize: false,
// }, // },

View File

@@ -1,4 +1,4 @@
const SqlDumper = require('dbgate-tools/lib/SqlDumper'); const { SqlDumper } = global.DBGATE_TOOLS;
class Dumper extends SqlDumper { class Dumper extends SqlDumper {
/** @param type {import('dbgate-types').TransformType} */ /** @param type {import('dbgate-types').TransformType} */

View File

@@ -1,4 +1,4 @@
const driverBase = require('dbgate-tools/lib/driverBase'); const { driverBase } = global.DBGATE_TOOLS;
const Dumper = require('./Dumper'); const Dumper = require('./Dumper');
/** @type {import('dbgate-types').SqlDialect} */ /** @type {import('dbgate-types').SqlDialect} */

View File

@@ -15,6 +15,12 @@ var config = {
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,

View File

@@ -1,4 +1,4 @@
const SqlDumper = require('dbgate-tools/lib/SqlDumper'); const { SqlDumper } = global.DBGATE_TOOLS;
class Dumper extends SqlDumper { class Dumper extends SqlDumper {
/** @param type {import('dbgate-types').TransformType} */ /** @param type {import('dbgate-types').TransformType} */

View File

@@ -1,4 +1,4 @@
const driverBase = require('dbgate-tools/lib/driverBase'); const { driverBase } = global.DBGATE_TOOLS;
const Dumper = require('./Dumper'); const Dumper = require('./Dumper');
/** @type {import('dbgate-types').SqlDialect} */ /** @type {import('dbgate-types').SqlDialect} */

View File

@@ -1,20 +1,26 @@
var webpack = require("webpack"); var webpack = require('webpack');
var path = require("path"); var path = require('path');
var config = { var config = {
context: __dirname + "/src/frontend", context: __dirname + '/src/frontend',
entry: { entry: {
app: "./index.js", app: './index.js',
}, },
target: "web", target: 'web',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "frontend.js", filename: 'frontend.js',
libraryTarget: "var", libraryTarget: 'var',
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,

View File

@@ -1,4 +1,4 @@
const SqlDumper = require('dbgate-tools/lib/SqlDumper'); const { SqlDumper } = global.DBGATE_TOOLS;
class Dumper extends SqlDumper {} class Dumper extends SqlDumper {}

View File

@@ -1,4 +1,4 @@
const driverBase = require('dbgate-tools/lib/driverBase'); const { driverBase } = global.DBGATE_TOOLS;
const Dumper = require('./Dumper'); const Dumper = require('./Dumper');
function getDatabaseFileLabel(databaseFile) { function getDatabaseFileLabel(databaseFile) {

View File

@@ -1,20 +1,26 @@
var webpack = require("webpack"); var webpack = require('webpack');
var path = require("path"); var path = require('path');
var config = { var config = {
context: __dirname + "/src/frontend", context: __dirname + '/src/frontend',
entry: { entry: {
app: "./index.js", app: './index.js',
}, },
target: "web", target: 'web',
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, 'dist'),
filename: "frontend.js", filename: 'frontend.js',
libraryTarget: "var", libraryTarget: 'var',
library: 'plugin', library: 'plugin',
}, },
plugins: [
new webpack.DefinePlugin({
'global.DBGATE_TOOLS': 'window.DBGATE_TOOLS',
}),
],
// uncomment for disable minimalization // uncomment for disable minimalization
// optimization: { // optimization: {
// minimize: false, // minimize: false,