feat: migrate to DSH 0.1.5-rc.2 with TypeScript refactor, official slot footer and codex selector
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const esbuild = require('esbuild');
|
||||
|
||||
async function build() {
|
||||
console.log('Building host entry: src/index.ts -> lib/index.js...');
|
||||
await esbuild.build({
|
||||
entryPoints: [path.resolve(__dirname, 'src/index.ts')],
|
||||
outfile: path.resolve(__dirname, 'lib/index.js'),
|
||||
bundle: false,
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
target: 'node18'
|
||||
});
|
||||
|
||||
console.log('Building client bundle: src/client/index.ts -> lib/client.js...');
|
||||
const clientBuildResult = await esbuild.build({
|
||||
entryPoints: [path.resolve(__dirname, 'src/client/index.ts')],
|
||||
bundle: true,
|
||||
write: false,
|
||||
format: 'cjs',
|
||||
platform: 'browser',
|
||||
target: 'es2022',
|
||||
external: [
|
||||
'react',
|
||||
'react-dom',
|
||||
'react/jsx-runtime',
|
||||
'@deepseek-ai/cordis',
|
||||
'@deepseek-ai/dsh-client-store',
|
||||
'@deepseek-ai/dsh-client-ui-slots',
|
||||
'@deepseek-ai/dsh-client-ui-primitives',
|
||||
'@deepseek-ai/dsh-client-ui-dockkit'
|
||||
]
|
||||
});
|
||||
|
||||
const bundledCjs = clientBuildResult.outputFiles[0].text;
|
||||
|
||||
// Wrap in window.__ModuleLoader__.load({ id: "dsh-plugin-model-enhancer", factory: (require) => { ... } })
|
||||
const wrappedClientCode = `window.__ModuleLoader__.load({
|
||||
id: "dsh-plugin-model-enhancer",
|
||||
factory: (require) => {
|
||||
var module = { exports: {} };
|
||||
var exports = module.exports;
|
||||
${bundledCjs}
|
||||
return module.exports;
|
||||
}
|
||||
});
|
||||
`;
|
||||
|
||||
fs.mkdirSync(path.resolve(__dirname, 'lib'), { recursive: true });
|
||||
fs.writeFileSync(path.resolve(__dirname, 'lib/client.js'), wrappedClientCode, 'utf8');
|
||||
console.log('Successfully generated lib/client.js (length: ' + wrappedClientCode.length + ')');
|
||||
}
|
||||
|
||||
build().catch((err) => {
|
||||
console.error('Build failed:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user