feat: add DSH IDE open-file references
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { build } from 'esbuild'
|
||||
import { mkdir, rm, writeFile } from 'node:fs/promises'
|
||||
|
||||
const watch = process.argv.includes('--watch')
|
||||
const packageId = '@prophet/dsh-plugin-coop-with-vs'
|
||||
|
||||
await rm('lib', { recursive: true, force: true })
|
||||
await mkdir('lib', { recursive: true })
|
||||
|
||||
const common = {
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
target: 'es2022',
|
||||
logLevel: 'info',
|
||||
}
|
||||
|
||||
await build({
|
||||
...common,
|
||||
entryPoints: ['src/index.ts'],
|
||||
outfile: 'lib/index.js',
|
||||
platform: 'node',
|
||||
format: 'esm',
|
||||
packages: 'external',
|
||||
})
|
||||
|
||||
const client = await build({
|
||||
...common,
|
||||
entryPoints: ['src/client.ts'],
|
||||
platform: 'browser',
|
||||
format: 'cjs',
|
||||
packages: 'external',
|
||||
write: false,
|
||||
})
|
||||
const body = client.outputFiles[0].text
|
||||
const wrapped = `window.__ModuleLoader__.load({\n id: ${JSON.stringify(packageId)},\n factory: (require) => {\n var module = { exports: {} };\n var exports = module.exports;\n${body}\n return module.exports;\n },\n});\n`
|
||||
await writeFile('lib/client.js', wrapped, 'utf8')
|
||||
|
||||
if (watch) {
|
||||
console.error('Watch mode performs one deterministic rebuild; rerun via your file watcher.')
|
||||
}
|
||||
Reference in New Issue
Block a user