The export const some = 1
compiled by vite into ... exports.some = some; ...
.
How to make it to use native ES modules?
I tried target: "esnext"
, esModule: true
, format: 'es'
– none works.
The config (I’m using script instead of config because I need it to run for list of files).
import path from 'path'
import { build } from 'vite'
['lib.ts']
.map(name => [name, path.resolve(__dirname, name)])
.forEach(async ([name, entry]) => {
// console.log(name, entry)
await build({
configFile: false,
build: {
target: "esnext",
emptyOutDir: false,
minify: false,
lib: {
entry,
name
},
rollupOptions: {
external: ['base'],
output: {
esModule: true,
format: 'es',
entryFileNames: '[name].mjs',
dir: 'releases/tmp'
}
}
}
})
})