Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please support multiple entry points for library mode #4499

Closed
4 tasks done
franktopel opened this issue Aug 4, 2021 · 1 comment
Closed
4 tasks done

Please support multiple entry points for library mode #4499

franktopel opened this issue Aug 4, 2021 · 1 comment

Comments

@franktopel
Copy link

Clear and concise description of the problem

I'm using Vite.js to build a webcomponent library for a customer.

        lib: {
            entry: path.resolve(__dirname, 'src/webcomponents.js'),
            formats: ['es'],
            name: 'webcomponents',
        },

This does perfectly create the desired output:

vite v2.4.4 building for production...
✓ 32 modules transformed.
dist/webcomponents.es.js   36.46kb / brotli: 10.31kb
dist/webcomponents.es.js.map 101.33kb
dist/style.css                  117.61kb / brotli: 82.97kb

In the same project, we also build the application that uses this library, which basically comprises of web components as well, which serve as views. So I need a second entry point:

        lib: [{
            entry: path.resolve(__dirname, 'src/webcomponents.js'),
            formats: ['es'],
            name: 'webcomponents',
        },
        {
            entry: path.resolve(__dirname, 'src/views.js'),
            formats: ['es'],
            name: 'views',
        }],

Unfortunately, that results in an error:

vite v2.4.4 building for production...
error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
...

Suggested solution

Instead of a single entry point for libarary mode, allow an array of entry points.

Alternative

I've tried working around this limitation by using rollupOptions instead, but wasn"t able to figure it out:

rollupOptions: [
    {
        input: path.resolve(__dirname, 'src/webcomponents.js'),
        output: {
            file: path.resolve(__dirname, 'dist/webcomponents.js'),
            format: 'es'
        },
    }, {
        input: path.resolve(__dirname, 'src/views.js'),
        output: {
            file: path.resolve(__dirname, 'dist/views.js'),
            format: 'es'
        }
    }
],

Unfortunately, this does not create the files I expect:

dist/index.html                                3.03kb
dist/assets/index.1a413bf8.css                 6.54kb / brotli: 1.96kb
dist/assets/vendor.ef70301d.js                 11.19kb / brotli: 3.72kb
dist/assets/vendor.ef70301d.js.map             45.39kb
dist/assets/index.fa2e2112.js                  31.74kb / brotli: 7.88kb
dist/assets/index.fa2e2112.js.map              73.46kb

Additional context

I've read and upvoted #1736 and wanted to turn this into a feature request.

Validations

@franktopel
Copy link
Author

Closed in favor of #4530

@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant