Skip to content

[Feature]: support multiple output with different umdNames #579

@ZhangTaibin

Description

@ZhangTaibin

What problem does this feature solve?

I get multiple output through this options:

import { defineConfig } from '@rslib/core';

export default defineConfig({
  source: {
    entry: {
      "component-1": "./src/component-1/index.js",
      "component-2": "./src/component-2/index.js",
    }
  },

  lib: [
    {
      format: 'umd',
      umdName: 'MyLibrary',
    },
  ],

  output: {
    target: 'web',
    filename: {
      js: '[name]/index.[contenthash:8].js',
    }
  },
});

It will get dist/component-1/index.jsdist/component-2/index.js . But they use a same umdName MyLibrary.

I hope Rslib can support buding multiple output with different umdNames.

Like outputs dist/component-1/index.js with umdName component__1 and dist/component-2/index.js with umdName component__2

Thanks.

What does the proposed API look like?

lib.umdName can support function to map the entry so that i can tell which output use what name:

import { defineConfig } from '@rslib/core';

export default defineConfig({
  source: {
    entry: {
      "component-1": "./src/component-1/index.js",
      "component-2": "./src/component-2/index.js",
    }
  },

  lib: [
    {
      format: 'umd',
      umdName({ entryName }) {
        const maps = {
          "component-1": "component__1",
          "component-2": "component__2",
        }
        return maps[entryName]
      }
    },
  ],
});

or

support array config so that i can decide the output. Like this Rollup options:

import { defineConfig } from 'rollup'

export default defineConfig([
    {
        input: 'src/component-1/index.js',
        output: [
            {
                name: 'component__1',
                file: 'dist/component-1/index.js',
                format: 'umd',
            },
        ],
    },
    {
        input: 'src/component-2/index.js',
        output: [
            {
                name: 'component__2',
                file: 'dist/component-2/index.js',
                format: 'umd',
            },

        ],
    },
])

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions