// @flow
const {Transformer} = require('@parcel/plugin');

module.exports = new Transformer({
  async transform({asset}) {
    let code = await asset.getCode();

    if (code.includes('PROCESS_ME')) {
      asset.setCode(`export {a} from "xyz";`);

      return [
        asset,
        {
          type: 'js',
          uniqueKey: 'xyz',
          content: 'export const a = 123; export const b = 789;',
        },
      ];
    } else {
      return [asset];
    }
  },
});
