I have library called lib.ts
, it’s made from multiple files, like lib/part1.ts
, lib/part2.ts
.
And the lib.ts
just re exports everything, content of lib.ts
:
export * from './lib/part1.js'
export * from './lib/part2.js'
I would like to produce single file lib.mjs
as ES module, with all parts merged, but the exports kept.
How can I do that, vite removes the exports.
The vite config:
import { defineConfig } from 'vite'
import { resolve } from 'path'
export default defineConfig({
build: {
rollupOptions: {
input: {
lib: resolve(__dirname, 'lib')
app: resolve(__dirname, 'app')
},
output: {
entryFileNames: '[name].mjs',
dir: 'releases'
},
external: [
'lib'
],
}
}
})
I also have the app.ts
bundle. I don’t want the lib
to be included in app
, so it’s marked as external.