// Copyright 2017-2026 @pezkuwi/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0

import path from 'path';

import { createBundle } from '@pezkuwi/dev/config/rollup';

const pkgs = [
  '@pezkuwi/extension-dapp'
];

const external = [
  ...pkgs,
  '@pezkuwi/networks',
  '@pezkuwi/util',
  '@pezkuwi/util-crypto'
];

const entries = ['extension-base', 'extension-chains', 'extension-inject'].reduce((all, p) => ({
  ...all,
  [`@pezkuwi/${p}`]: path.resolve(process.cwd(), `packages/${p}/build`)
}), {});

const overrides = {};

export default pkgs.map((pkg) => {
  const override = (overrides[pkg] || {});

  return createBundle({
    external,
    pkg,
    ...override,
    entries: {
      ...entries,
      ...(override.entries || {})
    }
  });
});
