Open nathanjhood opened 1 week ago
Working locally, testing later:
const buildOptions: ESBuild.BuildOptions = {
// defaults
...defaultBuildOptions,
// // args
// ...options,
// required
banner: {
// js: `new EventSource('/esbuild').addEventListener('change', () => location.reload(),{once:true});`,
js:
proc.env['FAST_REFRESH'] === 'false'
? ''
: `new EventSource('${wdsSocketPath}').addEventListener('change', () => ${wdsSocketHost}.reload(),{once:true});`,
},
format: 'esm',
sourcemap: proc.env['GENERATE_SOURCEMAP'] === 'true' || false,
};
getCommonOptions
:const getCommonOptions = () => { // ... platform: 'browser', // 'node' | browser | neutral, format: 'esm', // ... }
Consumers must set
"type": "module"
in theirpackage.json
.This should ensure that global vars are not broken in weird, subtle ways...
We could maybe do a require/import on paths.appPackageJson
and determine what, if any, is their "type":
entry set to, and have esbuild respond to that. There is a possibility that esbuild already does this, but it would be nice to offer a hook for end users here.
getCommonOptions
:build
:start
:Consumers must set
"type": "module"
in theirpackage.json
.This should ensure that global vars are not broken in weird, subtle ways...