mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 19:13:59 +00:00
bundling refactor
This commit is contained in:
19
common/buildPluginExternals.js
Normal file
19
common/buildPluginExternals.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const useBundleExternals = require('./useBundleExternals');
|
||||
const getBundleExternals = require('./getBundleExternals');
|
||||
|
||||
function buildExternalsFromDependencies(packageJson) {
|
||||
if (useBundleExternals == 'true') {
|
||||
return getBundleExternals();
|
||||
}
|
||||
const { dependencies, optionalDependencies } = packageJson;
|
||||
const externals = {};
|
||||
for (let dep in dependencies || {}) {
|
||||
externals[dep] = `commonjs ${dep}`;
|
||||
}
|
||||
for (let dep in optionalDependencies || {}) {
|
||||
externals[dep] = `commonjs ${dep}`;
|
||||
}
|
||||
return externals;
|
||||
}
|
||||
|
||||
module.exports = buildExternalsFromDependencies;
|
||||
10
common/getBundleExternals.js
Normal file
10
common/getBundleExternals.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const volatilePackages = require('./volatilePackages');
|
||||
|
||||
function getBundleExternals() {
|
||||
return volatilePackages.reduce((acc, item) => {
|
||||
acc[item] = `commonjs ${item}`;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
module.exports = getBundleExternals;
|
||||
1
common/useBundleExternals.js
Normal file
1
common/useBundleExternals.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = 'false';
|
||||
25
common/volatilePackages.js
Normal file
25
common/volatilePackages.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// these packages will be never bundled with webpack
|
||||
|
||||
const volatilePackages = [
|
||||
'@clickhouse/client',
|
||||
'bson', // this package is already bundled and is used in mongodb
|
||||
'mongodb',
|
||||
'mongodb-client-encryption',
|
||||
'tedious',
|
||||
'msnodesqlv8',
|
||||
'mysql2',
|
||||
'oracledb',
|
||||
'pg-copy-streams',
|
||||
'pg',
|
||||
'ioredis',
|
||||
'node-redis-dump2',
|
||||
'better-sqlite3',
|
||||
'@azure/cosmos',
|
||||
'@aws-sdk/rds-signer',
|
||||
'activedirectory2',
|
||||
'axios',
|
||||
'bufferutil',
|
||||
'ssh2',
|
||||
];
|
||||
|
||||
module.exports = volatilePackages;
|
||||
Reference in New Issue
Block a user