Build: Add a commonjs bundle to dataverse

This commit is contained in:
Aria Minaei 2021-06-28 16:37:02 +02:00
parent 90d26ecd32
commit 14b3207680
9 changed files with 65 additions and 7 deletions

View file

@ -0,0 +1,35 @@
import path from 'path'
import {build} from 'esbuild'
const definedGlobals = {
global: 'window',
}
function createBundles(watch: boolean) {
const pathToPackage = path.join(__dirname, '../')
const esbuildConfig: Parameters<typeof build>[0] = {
entryPoints: [path.join(pathToPackage, 'src/index.ts')],
bundle: true,
sourcemap: true,
define: definedGlobals,
watch,
platform: 'neutral',
mainFields: ['browser', 'module', 'main'],
target: ['firefox57', 'chrome58'],
conditions: ['browser', 'node'],
}
build({
...esbuildConfig,
outfile: path.join(pathToPackage, 'dist/index.cjs'),
format: 'cjs',
})
build({
...esbuildConfig,
outfile: path.join(pathToPackage, 'dist/index.mjs'),
format: 'esm',
})
}
createBundles(false)

View file

@ -0,0 +1,3 @@
{
}