Build: Add a commonjs bundle to dataverse
This commit is contained in:
parent
90d26ecd32
commit
14b3207680
9 changed files with 65 additions and 7 deletions
35
packages/dataverse/devEnv/build.ts
Normal file
35
packages/dataverse/devEnv/build.ts
Normal 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)
|
3
packages/dataverse/devEnv/tsconfig.json
Normal file
3
packages/dataverse/devEnv/tsconfig.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue