alloc / vite-plugin-legacy

Vite-generated legacy bundles
MIT License
53 stars 6 forks source link

Fixes the "no output.name" error. #13

Closed blvz closed 3 years ago

blvz commented 3 years ago

Without a name, the bundle exports can't be accessed.

$ vite build -c vite.legacy.config.ts
vite v2.0.2 building for production...
✓ 19 modules transformed.
rendering chunks (1)...creating legacy bundle...
If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.
dist/lit-element-sample.iife.js          29.59kb / brotli: 6.94kb
dist/lit-element-sample.iife.js.map      155.20kb
dist/lit-element-sample.iife.legacy.js   85.81kb / brotli: 25.34kb
dist/lit-element-sample.iife.legacy.js.map 117.21kb
✨  Done in 6.98s.
aleclarson commented 3 years ago

Why would you use this plugin on a library?

blvz commented 3 years ago

I was developing a library/third-party script that'd have both ESM and "classic" exports (where the latter would just add itself to window and be compatible with most browsers). What would be the correct approach then?