39da042edc
* Fix react-icons breaking in CRA 5 for some reason * Replace fuzzysort with fuzzy so we don't break Webpack Webpack messes up esbuild’s internal modules if the inlined module is an AMD module. Check any new dep you add if it is an AMD module. * Inline dataverse deps. Mainly because the CJS build consuming the ESM lodash-es broke some bundlers. * react-icons fix nr 2 * Stop eslint breaking in CRA 5 * Update r3f-cra example to CRA 5 and fix double-bundling react & co * Fix r3f tree-shaking and switch to ESM only output * Make r3f example shake studio and its extension in prod * Examples have separate and wildly differing build setups so remove them from the pre-commit hook linting * Update out-of-date yarn.lock
35 lines
813 B
TypeScript
35 lines
813 B
TypeScript
import * as 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.js'),
|
|
format: 'cjs',
|
|
})
|
|
|
|
// build({
|
|
// ...esbuildConfig,
|
|
// outfile: path.join(pathToPackage, 'dist/index.mjs'),
|
|
// format: 'esm',
|
|
// })
|
|
}
|
|
|
|
createBundles(false)
|