dbgate/common/buildPluginExternals.js
2024-11-15 11:49:25 +01:00

20 lines
585 B
JavaScript

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;