chore: 更新依赖和构建配置
This commit is contained in:
@@ -58,7 +58,8 @@
|
||||
"lint": "turbo run lint",
|
||||
"lint:fix": "turbo run lint:fix",
|
||||
"build:wasm": "cd packages/engine && wasm-pack build --dev --out-dir pkg",
|
||||
"build:wasm:release": "cd packages/engine && wasm-pack build --release --out-dir pkg"
|
||||
"build:wasm:release": "cd packages/engine && wasm-pack build --release --out-dir pkg",
|
||||
"copy-modules": "node scripts/copy-engine-modules.mjs"
|
||||
},
|
||||
"author": "yhh",
|
||||
"license": "MIT",
|
||||
@@ -120,3 +121,4 @@
|
||||
"ws": "^8.18.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
253
pnpm-lock.yaml
generated
253
pnpm-lock.yaml
generated
@@ -166,6 +166,25 @@ importers:
|
||||
specifier: ^5.8.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/asset-system-editor:
|
||||
dependencies:
|
||||
'@esengine/asset-system':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
rimraf:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.10
|
||||
tsup:
|
||||
specifier: ^8.0.0
|
||||
version: 8.5.1(@microsoft/api-extractor@7.55.1(@types/node@20.19.25))(@swc/core@1.15.3)(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1)
|
||||
typescript:
|
||||
specifier: ^5.8.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/audio:
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
@@ -285,6 +304,9 @@ importers:
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@types/node':
|
||||
specifier: ^20.19.17
|
||||
version: 20.19.25
|
||||
@@ -497,6 +519,9 @@ importers:
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@esengine/material-system':
|
||||
specifier: workspace:*
|
||||
version: link:../material-system
|
||||
'@esengine/sprite':
|
||||
specifier: workspace:*
|
||||
version: link:../sprite
|
||||
@@ -519,6 +544,9 @@ importers:
|
||||
'@esengine/asset-system':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system
|
||||
'@esengine/asset-system-editor':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system-editor
|
||||
'@esengine/audio':
|
||||
specifier: workspace:*
|
||||
version: link:../audio
|
||||
@@ -555,6 +583,12 @@ importers:
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@esengine/material-editor':
|
||||
specifier: workspace:*
|
||||
version: link:../material-editor
|
||||
'@esengine/material-system':
|
||||
specifier: workspace:*
|
||||
version: link:../material-system
|
||||
'@esengine/physics-rapier2d':
|
||||
specifier: workspace:*
|
||||
version: link:../physics-rapier2d
|
||||
@@ -564,9 +598,15 @@ importers:
|
||||
'@esengine/runtime-core':
|
||||
specifier: workspace:*
|
||||
version: link:../runtime-core
|
||||
'@esengine/shader-editor':
|
||||
specifier: workspace:*
|
||||
version: link:../shader-editor
|
||||
'@esengine/sprite':
|
||||
specifier: workspace:*
|
||||
version: link:../sprite
|
||||
'@esengine/sprite-editor':
|
||||
specifier: workspace:*
|
||||
version: link:../sprite-editor
|
||||
'@esengine/tilemap':
|
||||
specifier: workspace:*
|
||||
version: link:../tilemap
|
||||
@@ -707,6 +747,9 @@ importers:
|
||||
'@esengine/asset-system':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system
|
||||
'@esengine/asset-system-editor':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system-editor
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
@@ -853,6 +896,70 @@ importers:
|
||||
specifier: ^5.3.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/material-editor:
|
||||
dependencies:
|
||||
'@esengine/material-system':
|
||||
specifier: workspace:*
|
||||
version: link:../material-system
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@esengine/editor-core':
|
||||
specifier: workspace:*
|
||||
version: link:../editor-core
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@types/react':
|
||||
specifier: ^18.2.0
|
||||
version: 18.3.27
|
||||
lucide-react:
|
||||
specifier: ^0.545.0
|
||||
version: 0.545.0(react@18.3.1)
|
||||
react:
|
||||
specifier: ^18.3.1
|
||||
version: 18.3.1
|
||||
rimraf:
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.10
|
||||
tsup:
|
||||
specifier: ^8.0.0
|
||||
version: 8.5.1(@microsoft/api-extractor@7.55.1(@types/node@20.19.25))(@swc/core@1.15.3)(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1)
|
||||
typescript:
|
||||
specifier: ^5.3.3
|
||||
version: 5.9.3
|
||||
zustand:
|
||||
specifier: ^5.0.8
|
||||
version: 5.0.8(@types/react@18.3.27)(react@18.3.1)(use-sync-external-store@1.6.0(react@18.3.1))
|
||||
|
||||
packages/material-system:
|
||||
devDependencies:
|
||||
'@esengine/asset-system':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
rimraf:
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.10
|
||||
tsup:
|
||||
specifier: ^8.0.0
|
||||
version: 8.5.1(@microsoft/api-extractor@7.55.1(@types/node@20.19.25))(@swc/core@1.15.3)(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1)
|
||||
typescript:
|
||||
specifier: ^5.3.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/math:
|
||||
devDependencies:
|
||||
'@rollup/plugin-commonjs':
|
||||
@@ -928,9 +1035,12 @@ importers:
|
||||
|
||||
packages/physics-rapier2d:
|
||||
dependencies:
|
||||
'@dimforge/rapier2d-compat':
|
||||
specifier: ^0.14.0
|
||||
version: 0.14.0
|
||||
'@esengine/platform-common':
|
||||
specifier: workspace:*
|
||||
version: link:../platform-common
|
||||
'@esengine/rapier2d':
|
||||
specifier: workspace:*
|
||||
version: link:../rapier2d
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
@@ -1016,58 +1126,26 @@ importers:
|
||||
version: 5.9.3
|
||||
|
||||
packages/platform-web:
|
||||
dependencies:
|
||||
'@esengine/runtime-core':
|
||||
specifier: workspace:*
|
||||
version: link:../runtime-core
|
||||
devDependencies:
|
||||
'@esengine/asset-system':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system
|
||||
'@esengine/audio':
|
||||
specifier: workspace:*
|
||||
version: link:../audio
|
||||
'@esengine/behavior-tree':
|
||||
specifier: workspace:*
|
||||
version: link:../behavior-tree
|
||||
'@esengine/camera':
|
||||
specifier: workspace:*
|
||||
version: link:../camera
|
||||
'@esengine/ecs-engine-bindgen':
|
||||
specifier: workspace:*
|
||||
version: link:../ecs-engine-bindgen
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@esengine/physics-rapier2d':
|
||||
specifier: workspace:*
|
||||
version: link:../physics-rapier2d
|
||||
'@esengine/platform-common':
|
||||
specifier: workspace:*
|
||||
version: link:../platform-common
|
||||
'@esengine/runtime-core':
|
||||
specifier: workspace:*
|
||||
version: link:../runtime-core
|
||||
'@esengine/sprite':
|
||||
specifier: workspace:*
|
||||
version: link:../sprite
|
||||
'@esengine/tilemap':
|
||||
specifier: workspace:*
|
||||
version: link:../tilemap
|
||||
'@esengine/ui':
|
||||
specifier: workspace:*
|
||||
version: link:../ui
|
||||
'@rollup/plugin-alias':
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0(rollup@4.53.3)
|
||||
'@rollup/plugin-commonjs':
|
||||
specifier: ^28.0.3
|
||||
version: 28.0.9(rollup@4.53.3)
|
||||
'@rollup/plugin-node-resolve':
|
||||
specifier: ^16.0.1
|
||||
version: 16.0.3(rollup@4.53.3)
|
||||
'@rollup/plugin-replace':
|
||||
specifier: ^6.0.3
|
||||
version: 6.0.3(rollup@4.53.3)
|
||||
'@rollup/plugin-typescript':
|
||||
specifier: ^11.1.6
|
||||
version: 11.1.6(rollup@4.53.3)(tslib@2.8.1)(typescript@5.9.3)
|
||||
@@ -1118,6 +1196,18 @@ importers:
|
||||
specifier: ^5.8.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/rapier2d:
|
||||
devDependencies:
|
||||
rimraf:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.10
|
||||
tsup:
|
||||
specifier: ^8.0.0
|
||||
version: 8.5.1(@microsoft/api-extractor@7.55.1(@types/node@20.19.25))(@swc/core@1.15.3)(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1)
|
||||
typescript:
|
||||
specifier: ^5.0.0
|
||||
version: 5.9.3
|
||||
|
||||
packages/runtime-core:
|
||||
devDependencies:
|
||||
'@esengine/asset-system':
|
||||
@@ -1145,6 +1235,42 @@ importers:
|
||||
specifier: ^5.3.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/shader-editor:
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@esengine/editor-core':
|
||||
specifier: workspace:*
|
||||
version: link:../editor-core
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@esengine/material-system':
|
||||
specifier: workspace:*
|
||||
version: link:../material-system
|
||||
'@types/react':
|
||||
specifier: ^18.2.0
|
||||
version: 18.3.27
|
||||
lucide-react:
|
||||
specifier: ^0.453.0
|
||||
version: 0.453.0(react@18.3.1)
|
||||
react:
|
||||
specifier: ^18.3.1
|
||||
version: 18.3.1
|
||||
rimraf:
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.10
|
||||
tsup:
|
||||
specifier: ^8.0.0
|
||||
version: 8.5.1(@microsoft/api-extractor@7.55.1(@types/node@20.19.25))(@swc/core@1.15.3)(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1)
|
||||
typescript:
|
||||
specifier: ^5.3.3
|
||||
version: 5.9.3
|
||||
|
||||
packages/sprite:
|
||||
devDependencies:
|
||||
'@esengine/asset-system':
|
||||
@@ -1183,12 +1309,18 @@ importers:
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@esengine/material-system':
|
||||
specifier: workspace:*
|
||||
version: link:../material-system
|
||||
'@esengine/sprite':
|
||||
specifier: workspace:*
|
||||
version: link:../sprite
|
||||
'@types/react':
|
||||
specifier: ^18.2.0
|
||||
version: 18.3.27
|
||||
lucide-react:
|
||||
specifier: ^0.453.0
|
||||
version: 0.453.0(react@18.3.1)
|
||||
react:
|
||||
specifier: ^18.3.1
|
||||
version: 18.3.1
|
||||
@@ -2080,9 +2212,6 @@ packages:
|
||||
resolution: {integrity: sha512-gwRLBLra/Dozj2OywopeuHj2ac26gjGkz2cZ+86cTJOdtWfiRRr4+e77ZDAGc6MDWxaWheI+mAV5TLWWRwqrFg==}
|
||||
engines: {node: '>=v18'}
|
||||
|
||||
'@dimforge/rapier2d-compat@0.14.0':
|
||||
resolution: {integrity: sha512-sljQVPstRS63hVLnVNphsZUjH51TZoptVM0XlglKAdZ8CT+kWnmA6olwjkF7omPWYrlKMd/nHORxOUdJDOSoAQ==}
|
||||
|
||||
'@docsearch/css@3.8.2':
|
||||
resolution: {integrity: sha512-y05ayQFyUmCXze79+56v/4HpycYF3uFqB78pLPrSV5ZKAlDuIAAJNhaRi8tTdRNXh05yxX/TyNnzD6LwSM89vQ==}
|
||||
|
||||
@@ -3249,15 +3378,6 @@ packages:
|
||||
'@rolldown/pluginutils@1.0.0-beta.47':
|
||||
resolution: {integrity: sha512-8QagwMH3kNCuzD8EWL8R2YPW5e4OrHNSAHRFDdmFqEwEaD/KcNKjVoumo+gP2vW5eKB2UPbM6vTYiGZX0ixLnw==}
|
||||
|
||||
'@rollup/plugin-alias@6.0.0':
|
||||
resolution: {integrity: sha512-tPCzJOtS7uuVZd+xPhoy5W4vThe6KWXNmsFCNktaAh5RTqcLiSfT4huPQIXkgJ6YCOjJHvecOAzQxLFhPxKr+g==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
peerDependencies:
|
||||
rollup: '>=4.0.0'
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/plugin-babel@6.1.0':
|
||||
resolution: {integrity: sha512-dFZNuFD2YRcoomP4oYf+DvQNSUA9ih+A3vUqopQx5EdtPGo3WBnQcI/S8pwpz91UsGfL0HsMSOlaMld8HrbubA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
@@ -3289,15 +3409,6 @@ packages:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/plugin-replace@6.0.3':
|
||||
resolution: {integrity: sha512-J4RZarRvQAm5IF0/LwUUg+obsm+xZhYnbMXmXROyoSE1ATJe3oXSb9L5MMppdxP2ylNSjv6zFBwKYjcKMucVfA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/plugin-terser@0.4.4':
|
||||
resolution: {integrity: sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
@@ -6380,6 +6491,11 @@ packages:
|
||||
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
lucide-react@0.453.0:
|
||||
resolution: {integrity: sha512-kL+RGZCcJi9BvJtzg2kshO192Ddy9hv3ij+cPrVPWSRzgCWCVazoQJxOjAwgK53NomL07HB7GPHW120FimjNhQ==}
|
||||
peerDependencies:
|
||||
react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc
|
||||
|
||||
lucide-react@0.545.0:
|
||||
resolution: {integrity: sha512-7r1/yUuflQDSt4f1bpn5ZAocyIxcTyVyBBChSVtBKn5M+392cPmI5YJMWOJKk/HUWGm5wg83chlAZtCcGbEZtw==}
|
||||
peerDependencies:
|
||||
@@ -9791,8 +9907,6 @@ snapshots:
|
||||
dependencies:
|
||||
chalk: 4.1.2
|
||||
|
||||
'@dimforge/rapier2d-compat@0.14.0': {}
|
||||
|
||||
'@docsearch/css@3.8.2': {}
|
||||
|
||||
'@docsearch/js@3.8.2(@algolia/client-search@5.44.0)(@types/react@18.3.27)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.3)':
|
||||
@@ -11009,10 +11123,6 @@ snapshots:
|
||||
|
||||
'@rolldown/pluginutils@1.0.0-beta.47': {}
|
||||
|
||||
'@rollup/plugin-alias@6.0.0(rollup@4.53.3)':
|
||||
optionalDependencies:
|
||||
rollup: 4.53.3
|
||||
|
||||
'@rollup/plugin-babel@6.1.0(@babel/core@7.28.5)(@types/babel__core@7.20.5)(rollup@4.53.3)':
|
||||
dependencies:
|
||||
'@babel/core': 7.28.5
|
||||
@@ -11046,13 +11156,6 @@ snapshots:
|
||||
optionalDependencies:
|
||||
rollup: 4.53.3
|
||||
|
||||
'@rollup/plugin-replace@6.0.3(rollup@4.53.3)':
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.3.0(rollup@4.53.3)
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
rollup: 4.53.3
|
||||
|
||||
'@rollup/plugin-terser@0.4.4(rollup@4.53.3)':
|
||||
dependencies:
|
||||
serialize-javascript: 6.0.2
|
||||
@@ -14727,6 +14830,10 @@ snapshots:
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
|
||||
lucide-react@0.453.0(react@18.3.1):
|
||||
dependencies:
|
||||
react: 18.3.1
|
||||
|
||||
lucide-react@0.545.0(react@18.3.1):
|
||||
dependencies:
|
||||
react: 18.3.1
|
||||
|
||||
259
scripts/copy-engine-modules.mjs
Normal file
259
scripts/copy-engine-modules.mjs
Normal file
@@ -0,0 +1,259 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copy Engine Modules Script
|
||||
* 复制引擎模块脚本
|
||||
*
|
||||
* Copies module.json and dist/index.js from each engine module package
|
||||
* to packages/editor-app/dist/engine/{moduleId}/ directory.
|
||||
* 将每个引擎模块包的 module.json 和 dist/index.js 复制到
|
||||
* packages/editor-app/dist/engine/{moduleId}/ 目录。
|
||||
*
|
||||
* This ensures the same directory structure is used in development and production.
|
||||
* 这确保开发和生产环境使用相同的目录结构。
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/copy-engine-modules.mjs
|
||||
* pnpm run copy-modules
|
||||
*
|
||||
* Output structure:
|
||||
* packages/editor-app/dist/
|
||||
* engine/
|
||||
* index.json <- Module registry index
|
||||
* sprite/
|
||||
* module.json
|
||||
* index.js
|
||||
* tilemap/
|
||||
* module.json
|
||||
* index.js
|
||||
* sprite-editor/
|
||||
* index.js
|
||||
* ...
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(__dirname, '..');
|
||||
const packagesDir = path.join(rootDir, 'packages');
|
||||
const outputDir = path.join(packagesDir, 'editor-app', 'dist', 'engine');
|
||||
|
||||
/**
|
||||
* Get all engine modules (packages with module.json)
|
||||
* 获取所有引擎模块(带 module.json 的包)
|
||||
*/
|
||||
function getEngineModules() {
|
||||
const modules = [];
|
||||
|
||||
let packages;
|
||||
try {
|
||||
packages = fs.readdirSync(packagesDir);
|
||||
} catch {
|
||||
console.error(`[copy-modules] Error: Cannot read packages directory: ${packagesDir}`);
|
||||
return modules;
|
||||
}
|
||||
|
||||
for (const pkg of packages) {
|
||||
const pkgDir = path.join(packagesDir, pkg);
|
||||
const moduleJsonPath = path.join(pkgDir, 'module.json');
|
||||
|
||||
// Skip if not a directory
|
||||
try {
|
||||
if (!fs.statSync(pkgDir).isDirectory()) continue;
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if no module.json
|
||||
if (!fs.existsSync(moduleJsonPath)) continue;
|
||||
|
||||
try {
|
||||
const moduleJson = JSON.parse(fs.readFileSync(moduleJsonPath, 'utf-8'));
|
||||
|
||||
// Only include if isEngineModule is not explicitly false
|
||||
if (moduleJson.isEngineModule !== false) {
|
||||
modules.push({
|
||||
id: moduleJson.id || pkg,
|
||||
name: moduleJson.name || `@esengine/${pkg}`,
|
||||
displayName: moduleJson.displayName || pkg,
|
||||
packageDir: pkgDir,
|
||||
moduleJsonPath,
|
||||
distPath: path.join(pkgDir, 'dist', 'index.js'),
|
||||
editorPackage: moduleJson.editorPackage,
|
||||
isCore: moduleJson.isCore || false,
|
||||
category: moduleJson.category || 'Other'
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(` ⚠ Warning: Failed to parse ${moduleJsonPath}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a single runtime module to output directory
|
||||
* 将单个运行时模块复制到输出目录
|
||||
*/
|
||||
function copyModule(module) {
|
||||
const moduleOutputDir = path.join(outputDir, module.id);
|
||||
|
||||
// Create output directory
|
||||
if (!fs.existsSync(moduleOutputDir)) {
|
||||
fs.mkdirSync(moduleOutputDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Copy module.json
|
||||
const destModuleJson = path.join(moduleOutputDir, 'module.json');
|
||||
fs.copyFileSync(module.moduleJsonPath, destModuleJson);
|
||||
|
||||
// Copy dist/index.js if exists
|
||||
let hasRuntime = false;
|
||||
let sizeKB = 'N/A';
|
||||
|
||||
if (fs.existsSync(module.distPath)) {
|
||||
const destIndexJs = path.join(moduleOutputDir, 'index.js');
|
||||
fs.copyFileSync(module.distPath, destIndexJs);
|
||||
|
||||
// Also copy source map if exists
|
||||
const sourceMapPath = module.distPath + '.map';
|
||||
if (fs.existsSync(sourceMapPath)) {
|
||||
fs.copyFileSync(sourceMapPath, destIndexJs + '.map');
|
||||
}
|
||||
|
||||
const stats = fs.statSync(module.distPath);
|
||||
sizeKB = (stats.size / 1024).toFixed(1);
|
||||
hasRuntime = true;
|
||||
}
|
||||
|
||||
return { hasRuntime, sizeKB };
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy an editor package
|
||||
* 复制编辑器包
|
||||
*/
|
||||
function copyEditorPackage(editorPackageName) {
|
||||
// Extract package folder name from @esengine/xxx-editor
|
||||
const match = editorPackageName.match(/@esengine\/(.+)/);
|
||||
if (!match) return null;
|
||||
|
||||
const pkgName = match[1];
|
||||
const pkgDir = path.join(packagesDir, pkgName);
|
||||
const distPath = path.join(pkgDir, 'dist', 'index.js');
|
||||
|
||||
if (!fs.existsSync(distPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const editorOutputDir = path.join(outputDir, pkgName);
|
||||
if (!fs.existsSync(editorOutputDir)) {
|
||||
fs.mkdirSync(editorOutputDir, { recursive: true });
|
||||
}
|
||||
|
||||
const destIndexJs = path.join(editorOutputDir, 'index.js');
|
||||
fs.copyFileSync(distPath, destIndexJs);
|
||||
|
||||
// Copy source map if exists
|
||||
const sourceMapPath = distPath + '.map';
|
||||
if (fs.existsSync(sourceMapPath)) {
|
||||
fs.copyFileSync(sourceMapPath, destIndexJs + '.map');
|
||||
}
|
||||
|
||||
const stats = fs.statSync(distPath);
|
||||
return {
|
||||
name: pkgName,
|
||||
sizeKB: (stats.size / 1024).toFixed(1)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function
|
||||
*/
|
||||
function main() {
|
||||
console.log('\n📦 Copying engine modules to editor-app/dist/engine/\n');
|
||||
|
||||
// Ensure editor-app/dist exists
|
||||
const editorDistDir = path.join(packagesDir, 'editor-app', 'dist');
|
||||
if (!fs.existsSync(editorDistDir)) {
|
||||
fs.mkdirSync(editorDistDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Clean and recreate output directory
|
||||
if (fs.existsSync(outputDir)) {
|
||||
fs.rmSync(outputDir, { recursive: true });
|
||||
}
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
|
||||
// Get all engine modules
|
||||
const modules = getEngineModules();
|
||||
|
||||
if (modules.length === 0) {
|
||||
console.log(' No engine modules found.\n');
|
||||
return;
|
||||
}
|
||||
|
||||
// Collect editor packages
|
||||
const editorPackages = new Set();
|
||||
|
||||
// Copy runtime modules
|
||||
console.log('Runtime modules:');
|
||||
const moduleInfos = [];
|
||||
|
||||
for (const module of modules) {
|
||||
const { hasRuntime, sizeKB } = copyModule(module);
|
||||
|
||||
if (hasRuntime) {
|
||||
console.log(` ✓ ${module.id} (${sizeKB} KB)`);
|
||||
} else {
|
||||
console.log(` ○ ${module.id} (config only)`);
|
||||
}
|
||||
|
||||
moduleInfos.push({
|
||||
id: module.id,
|
||||
name: module.name,
|
||||
displayName: module.displayName,
|
||||
hasRuntime,
|
||||
editorPackage: module.editorPackage,
|
||||
isCore: module.isCore,
|
||||
category: module.category
|
||||
});
|
||||
|
||||
if (module.editorPackage) {
|
||||
editorPackages.add(module.editorPackage);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy editor packages
|
||||
if (editorPackages.size > 0) {
|
||||
console.log('\nEditor packages:');
|
||||
for (const editorPkg of editorPackages) {
|
||||
const result = copyEditorPackage(editorPkg);
|
||||
if (result) {
|
||||
console.log(` ✓ ${result.name} (${result.sizeKB} KB)`);
|
||||
} else {
|
||||
console.log(` ⚠ ${editorPkg} (not built)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create index.json with all module info
|
||||
const indexData = {
|
||||
version: '1.0.0',
|
||||
generatedAt: new Date().toISOString(),
|
||||
modules: moduleInfos
|
||||
};
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(outputDir, 'index.json'),
|
||||
JSON.stringify(indexData, null, 2)
|
||||
);
|
||||
|
||||
console.log(`\n✅ Copied ${modules.length} modules to dist/engine/`);
|
||||
console.log(` Index file: dist/engine/index.json\n`);
|
||||
}
|
||||
|
||||
// Run
|
||||
main();
|
||||
65
scripts/update-module-sizes.mjs
Normal file
65
scripts/update-module-sizes.mjs
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Update module.json files with actual bundle sizes from dist/index.js
|
||||
*
|
||||
* Run after build to update estimatedSize in module.json files
|
||||
* Usage: node scripts/update-module-sizes.mjs
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const packagesDir = path.resolve(__dirname, '../packages');
|
||||
|
||||
function updateModuleSizes() {
|
||||
const packages = fs.readdirSync(packagesDir);
|
||||
let updated = 0;
|
||||
let skipped = 0;
|
||||
|
||||
for (const pkg of packages) {
|
||||
const pkgDir = path.join(packagesDir, pkg);
|
||||
const moduleJsonPath = path.join(pkgDir, 'module.json');
|
||||
const distIndexPath = path.join(pkgDir, 'dist', 'index.js');
|
||||
|
||||
// Skip if no module.json
|
||||
if (!fs.existsSync(moduleJsonPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if no dist/index.js
|
||||
if (!fs.existsSync(distIndexPath)) {
|
||||
console.log(` Skip ${pkg}: no dist/index.js`);
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get actual file size
|
||||
const stat = fs.statSync(distIndexPath);
|
||||
const actualSize = stat.size;
|
||||
|
||||
// Read module.json
|
||||
const moduleJson = JSON.parse(fs.readFileSync(moduleJsonPath, 'utf-8'));
|
||||
const oldSize = moduleJson.estimatedSize;
|
||||
|
||||
// Update if different
|
||||
if (oldSize !== actualSize) {
|
||||
moduleJson.estimatedSize = actualSize;
|
||||
fs.writeFileSync(moduleJsonPath, JSON.stringify(moduleJson, null, 2) + '\n');
|
||||
const oldKB = oldSize ? (oldSize / 1024).toFixed(1) : 'N/A';
|
||||
const newKB = (actualSize / 1024).toFixed(1);
|
||||
console.log(` ${pkg}: ${oldKB} KB -> ${newKB} KB`);
|
||||
updated++;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(` Error processing ${pkg}:`, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nUpdated ${updated} modules, skipped ${skipped}`);
|
||||
}
|
||||
|
||||
console.log('Updating module sizes from dist/index.js...\n');
|
||||
updateModuleSizes();
|
||||
@@ -19,6 +19,11 @@
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["dist/**", "bin/**", "pkg/**"]
|
||||
},
|
||||
"copy-modules": {
|
||||
"dependsOn": ["build"],
|
||||
"outputs": ["packages/editor-app/dist/engine/**"],
|
||||
"cache": false
|
||||
},
|
||||
"type-check": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": []
|
||||
|
||||
Reference in New Issue
Block a user