2025-11-21 10:03:18 +08:00
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
|
|
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
|
|
|
import typescript from '@rollup/plugin-typescript';
|
|
|
|
|
import dts from 'rollup-plugin-dts';
|
|
|
|
|
|
2025-12-03 22:15:22 +08:00
|
|
|
/**
|
|
|
|
|
* Platform-web Rollup Configuration
|
|
|
|
|
*
|
|
|
|
|
* Builds:
|
|
|
|
|
* 1. ESM + CJS bundles for editor usage
|
|
|
|
|
* 2. TypeScript declarations
|
|
|
|
|
*
|
|
|
|
|
* All @esengine/* packages are external to avoid bundling.
|
|
|
|
|
* Game builds use import maps to resolve modules at runtime.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
const external = [
|
|
|
|
|
'@esengine/ecs-framework',
|
2025-12-03 22:15:22 +08:00
|
|
|
'@esengine/runtime-core',
|
|
|
|
|
'@esengine/platform-common',
|
|
|
|
|
'@esengine/asset-system',
|
2025-11-27 20:42:46 +08:00
|
|
|
'@esengine/ecs-components',
|
2025-12-03 22:15:22 +08:00
|
|
|
'@esengine/ecs-engine-bindgen',
|
2025-11-27 20:42:46 +08:00
|
|
|
'@esengine/tilemap',
|
|
|
|
|
'@esengine/ui',
|
|
|
|
|
'@esengine/behavior-tree',
|
2025-12-03 22:15:22 +08:00
|
|
|
// Editor packages (should never be in runtime)
|
|
|
|
|
'@esengine/editor-core',
|
|
|
|
|
'@esengine/ui-editor',
|
|
|
|
|
'@esengine/tilemap-editor',
|
|
|
|
|
'@esengine/behavior-tree-editor',
|
|
|
|
|
'@esengine/blueprint-editor',
|
|
|
|
|
'@esengine/physics-rapier2d-editor',
|
|
|
|
|
// React (editor only)
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
2025-11-27 20:42:46 +08:00
|
|
|
];
|
2025-11-21 10:03:18 +08:00
|
|
|
|
|
|
|
|
export default [
|
2025-12-03 22:15:22 +08:00
|
|
|
// Main bundle (ESM + CJS)
|
2025-11-21 10:03:18 +08:00
|
|
|
{
|
|
|
|
|
input: 'src/index.ts',
|
|
|
|
|
output: [
|
|
|
|
|
{
|
|
|
|
|
file: 'dist/index.mjs',
|
|
|
|
|
format: 'esm',
|
|
|
|
|
sourcemap: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
file: 'dist/index.js',
|
|
|
|
|
format: 'cjs',
|
|
|
|
|
sourcemap: true
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
external,
|
|
|
|
|
plugins: [
|
2025-12-03 22:15:22 +08:00
|
|
|
resolve({
|
|
|
|
|
browser: true,
|
|
|
|
|
preferBuiltins: false
|
|
|
|
|
}),
|
2025-11-21 10:03:18 +08:00
|
|
|
commonjs(),
|
|
|
|
|
typescript({
|
|
|
|
|
tsconfig: './tsconfig.json',
|
|
|
|
|
declaration: false
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
},
|
2025-12-03 22:15:22 +08:00
|
|
|
// TypeScript declarations
|
2025-11-21 10:03:18 +08:00
|
|
|
{
|
|
|
|
|
input: 'src/index.ts',
|
|
|
|
|
output: {
|
|
|
|
|
file: 'dist/index.d.ts',
|
|
|
|
|
format: 'esm'
|
|
|
|
|
},
|
|
|
|
|
external,
|
|
|
|
|
plugins: [dts()]
|
|
|
|
|
}
|
|
|
|
|
];
|