Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(project): a project can force an engine module in, or refuse one

esengine3fdedb459e96
diff --git a/pipeline/src/bundle/engineInstalls.ts b/pipeline/src/bundle/engineInstalls.ts
index 2301fd61b..743ea48d8 100644
--- a/pipeline/src/bundle/engineInstalls.ts
+++ b/pipeline/src/bundle/engineInstalls.ts
@@ -17,6 +17,7 @@
* one, and neither wants a second copy of this table.
*/
import { SUBSYSTEM_INSTALL, type Subsystem } from '../project/targetSupport';
+import type { ModuleChoice, ProjectFeatures } from '../project/format';
import { ESENGINE_SUBPATHS } from './esengineResolve';
/** A subsystem a document names by ASSET rather than by component: nothing in a
@@ -35,6 +36,29 @@ const SIDE_MODULE_SUBPATH: Readonly<Record<string, string>> = {
dragonbones: 'esengine/dragonbones',
};
+/**
+ * What a project SAYS, against what the build detects. Keyed by the subpath the
+ * module is installed from, and absorbing the older `features.physics.enabled`,
+ * which was this for one module: a way to name what only a script reaches.
+ */
+export function moduleChoices(features: ProjectFeatures | undefined): Readonly<Record<string, ModuleChoice>> {
+ const out: Record<string, ModuleChoice> = { ...(features?.modules ?? {}) };
+ // The old field, and only where the new one is silent: a project that says
+ // both means the one it was last edited with.
+ if (features?.physics?.enabled && out['esengine/physics'] === undefined) {
+ out['esengine/physics'] = 'include';
+ }
+ return out;
+}
+
+/** A module the project refused that its own content uses. */
+export interface ExcludedInUse {
+ /** The subpath specifier, as `features.modules` names it. */
+ specifier: string;
+ /** What said the project uses it, for a message someone can act on. */
+ evidence: string;
+}
+
/** What a project's content and code say it needs. Each field is one kind of
* evidence; an export passes the ones it can see. */
export interface EngineInstallEvidence {
@@ -46,6 +70,8 @@ export interface EngineInstallEvidence {
sideModuleIds?: Iterable<string>;
/** Bare `esengine/*` specifiers the game's own bundles import. */
scriptImports?: Iterable<string>;
+ /** What the project said, from {@link moduleChoices}. */
+ choices?: Readonly<Record<string, ModuleChoice>>;
}
/** What a package installs, and whether a lean entry can carry it. */
@@ -54,6 +80,10 @@ export interface EngineInstallPlan {
lean: boolean;
/** The subpaths to import, sorted. Empty when nothing optional is in use. */
subpaths: readonly string[];
+ /** Modules the project excluded that its content uses anyway. An export with
+ * any of these must fail: the alternative is a package missing half a scene
+ * and nothing saying which half. */
+ refused: readonly ExcludedInUse[];
}
function extensionOf(p: string): string {
@@ -68,28 +98,47 @@ function extensionOf(p: string): string {
* entry, which carries everything, so the subpath list stops mattering.
*/
export function engineInstalls(evidence: EngineInstallEvidence): EngineInstallPlan {
- const subpaths = new Set<string>();
+ /** Subpath → the first thing that said this project uses it. Kept so a
+ * refusal can name what it is arguing with, rather than the module. */
+ const why = new Map<string, string>();
+ const saw = (subpath: string, evidenceOf: string): void => {
+ if (!why.has(subpath)) why.set(subpath, evidenceOf);
+ };
let lean = true;
for (const subsystem of evidence.subsystems ?? []) {
const install = SUBSYSTEM_INSTALL[subsystem];
if (install === 'base') continue;
if (install === 'whole-entry') { lean = false; continue; }
- subpaths.add(install);
+ saw(install, `a ${subsystem} component in the content`);
}
for (const p of evidence.assetPaths ?? []) {
const subpath = ASSET_SUBPATH[extensionOf(p)];
- if (subpath) subpaths.add(subpath);
+ if (subpath) saw(subpath, p);
}
for (const id of evidence.sideModuleIds ?? []) {
// Spine's module id names the runtime version it was built for.
const subpath = id.startsWith('spine:') ? 'esengine/spine' : SIDE_MODULE_SUBPATH[id];
- if (subpath) subpaths.add(subpath);
+ if (subpath) saw(subpath, `the "${id}" side module`);
}
for (const specifier of evidence.scriptImports ?? []) {
// A script may import a subpath no content mentions — the game opens a
// socket itself, or builds a tilemap in code. Its word is evidence too,
// and only the ones the SDK publishes are ours to stage.
- if (specifier in ESENGINE_SUBPATHS) subpaths.add(specifier);
+ if (specifier in ESENGINE_SUBPATHS) saw(specifier, `a project script imports "${specifier}"`);
+ }
+
+ const choices = evidence.choices ?? {};
+ const refused: ExcludedInUse[] = [];
+ const subpaths = new Set<string>();
+ for (const [specifier, evidenceOf] of why) {
+ if (choices[specifier] === 'exclude') refused.push({ specifier, evidence: evidenceOf });
+ else subpaths.add(specifier);
+ }
+ // `include` is for what no evidence can reach — a module a script loads by a
+ // name no bundler resolves. Only for a subpath the SDK publishes, so a typo
+ // is not a module nobody can stage.
+ for (const [specifier, choice] of Object.entries(choices)) {
+ if (choice === 'include' && specifier in ESENGINE_SUBPATHS) subpaths.add(specifier);
}
- return { lean, subpaths: [...subpaths].sort() };
+ return { lean, subpaths: [...subpaths].sort(), refused };
}
diff --git a/pipeline/src/export/exportGame.ts b/pipeline/src/export/exportGame.ts
index f6f9be1e6..6282d642a 100644
--- a/pipeline/src/export/exportGame.ts
+++ b/pipeline/src/export/exportGame.ts
@@ -34,7 +34,7 @@ import {
DEFAULT_RUNTIME_CONFIG, packagedRuntimeFields, type RuntimeProjectConfig,
} from '../project/runtimeConfig';
import { engineImportMap, FULL_IMPORT_MAP, LEAN_ENTRY_FILE, FULL_ENTRY_FILE, type EngineImportMap } from '../bundle/importMap';
-import { engineInstalls, type EngineInstallPlan } from '../bundle/engineInstalls';
+import { engineInstalls, moduleChoices, type EngineInstallPlan } from '../bundle/engineInstalls';
import { exportMiniGame } from './exportMiniGame';
import { wechatExportProfile, douyinExportProfile } from './miniGameExportProfile';
import type { MiniGameExportProfile } from './miniGameExportProfile';
@@ -63,7 +63,7 @@ import { assembleDesktopApp } from '../../../build-tools/utils/desktopApp.js';
import { emitSteamBuild, defaultDepotId } from '../../../build-tools/utils/steamChannel.js';
import { debugSigningKey, type SigningKey } from '../../../build-tools/utils/androidKeystore.js';
import { compileTargetFor, isNativePlatform, desktopTemplateFor, type DesktopOs, type ExportPlatform } from '../project/platforms';
-import type { DesktopPackaging, SteamPackaging } from '../project/format';
+import type { DesktopPackaging, ProjectFeatures, SteamPackaging } from '../project/format';
import type { SizeBudget } from '../project/sizeBudget';
import { measureBuild, type BuildSizeReport } from './sizeReport';
import { sizeSettingsOf } from './sizeHistory';
@@ -412,6 +412,9 @@ export interface ExportGameOptions {
* resolved by the caller since a project can define its own. Absent ⇒ generic. */
playableAdProfile?: PlayableAdProfile;
+ /** What the project says about its engine modules (`ProjectFeatures.modules`).
+ * Absent ⇒ every module is `auto`, which is what detection alone gives. */
+ features?: ProjectFeatures;
/** Desktop product/display name (Project Settings); default the project title. */
desktopProductName?: string;
/**
@@ -628,6 +631,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
hostsDir: opts.hostsDir,
title,
appid: opts.miniGameAppid,
+ features: opts.features,
orientation,
runtime,
minify: opts.minify,
@@ -660,6 +664,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
hostsDir: opts.hostsDir,
title,
appid: opts.miniGameAppid,
+ features: opts.features,
orientation,
runtime,
minify: opts.minify,
@@ -819,7 +824,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
: [];
/** The subpaths this package installs, and whether a lean entry can carry it.
* Set on the browser path once the project's own imports are known. */
- let plan: EngineInstallPlan = { lean: false, subpaths: [] };
+ let plan: EngineInstallPlan = { lean: false, subpaths: [], refused: [] };
try {
const { build } = await loadEsbuild();
// 2. Project bundle (defineComponent/defineSystem). ESM with `esengine`
@@ -847,7 +852,14 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
assetPaths: cook.includedPaths,
sideModuleIds,
scriptImports,
+ choices: moduleChoices(opts.features),
});
+ // A package missing half a scene, with nothing saying which half, is worse
+ // than one that refuses to be made.
+ for (const r of plan.refused) {
+ errors.push(`${r.specifier} is excluded in Project Settings, and this build uses it — `
+ + `${r.evidence}. Set it to Auto or Include, or take it out of the content.`);
+ }
progress({ phase: 'Bundling game host' });
// An entry that IMPORTS what this package installs, then the host. Staging
// a subpath only lets the page resolve it; a subsystem is installed by
diff --git a/pipeline/src/export/exportMiniGame.ts b/pipeline/src/export/exportMiniGame.ts
index 2aa05ddf1..d74d35bb7 100644
--- a/pipeline/src/export/exportMiniGame.ts
+++ b/pipeline/src/export/exportMiniGame.ts
@@ -29,6 +29,7 @@
* own path. Pure Node (esbuild + fs) — IPC wiring is in main.ts.
*/
import { loadEsbuild } from '../bundle/esbuildRuntime';
+import type { ProjectFeatures } from '../project/format';
import {
DEFAULT_RUNTIME_CONFIG, packagedRuntimeFields, type RuntimeProjectConfig,
} from '../project/runtimeConfig';
@@ -52,7 +53,7 @@ import { buildCompiledSystems, type BuildMode } from '../bundle/buildCompiledSys
import { resolveEmcc, runEmcc } from '../bundle/emccPath';
import type { MiniGameExportProfile, MiniGameVendor } from './miniGameExportProfile';
import { contentSubsystems } from './contentSubsystems';
-import { engineInstalls } from '../bundle/engineInstalls';
+import { engineInstalls, moduleChoices } from '../bundle/engineInstalls';
@@ -273,6 +274,8 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {
/** The project's `packaging.engineSubpackage`: move the engine binary out of
* the main package into a 分包 the host loads at startup. */
engineSubpackage?: boolean;
+ /** What the project says about its engine modules; see ProjectFeatures.modules. */
+ features?: ProjectFeatures;
onProgress?: OnExportProgress;
}): Promise<ExportMiniGameResult> {
const title = opts.title ?? 'Game';
@@ -465,7 +468,14 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {
subsystems: usedSubsystems.keys(),
assetPaths: cook.includedPaths,
sideModuleIds: sideModules.map((m) => m.id),
+ choices: moduleChoices(opts.features),
});
+ // A package missing half a scene, with nothing saying which half, is worse than
+ // one that refuses to be made.
+ for (const r of plan.refused) {
+ errors.push(`${r.specifier} is excluded in Project Settings, and this build uses it — `
+ + `${r.evidence}. Set it to Auto or Include, or take it out of the content.`);
+ }
// Only when the SDK build actually produced one: a tree without it (an older
// dist, a test fixture) must fall back to the whole entry rather than alias
// `esengine` to a file that is not there.
diff --git a/pipeline/src/project/format.ts b/pipeline/src/project/format.ts
index 4b4706489..ba6b31bd6 100644
--- a/pipeline/src/project/format.ts
+++ b/pipeline/src/project/format.ts
@@ -106,8 +106,23 @@ export interface ProjectScripts {
* that spawns RigidBodies from a script at runtime). Absence ⇒ off; physics also
* auto-installs when a scene actually uses physics components.
*/
+/**
+ * What a project says about one engine module, against what the build detects.
+ * `auto` is almost always right; the other two are for what detection cannot
+ * see — a module reached only from code, and one a build must not carry.
+ */
+export type ModuleChoice = 'auto' | 'include' | 'exclude';
+
export interface ProjectFeatures {
+ /**
+ * Per-module override, keyed by the `esengine/` subpath that installs it — the
+ * same names the export stages. `include` is the older `physics.enabled`
+ * generalised; `exclude` refuses one, and an export whose content uses it
+ * anyway fails rather than shipping half a scene.
+ */
+ modules?: Record<string, ModuleChoice>;
physics?: {
+ /** @deprecated `modules.physics = 'include'` — kept so older projects load. */
enabled?: boolean;
gravity?: { x: number; y: number };
/** Names for the 16 Box2D collision-filter layers (the inspector's layer masks). */
@@ -573,6 +588,15 @@ export function parseManifest(raw: unknown): ProjectManifest {
if (o.features && typeof o.features === 'object') {
const f = o.features as Record<string, unknown>;
const features: ProjectFeatures = {};
+ if (f.modules && typeof f.modules === 'object') {
+ const modules: Record<string, ModuleChoice> = {};
+ for (const [id, v] of Object.entries(f.modules as Record<string, unknown>)) {
+ // `auto` is the default, so recording it would be a second way to spell
+ // "nothing here" that every reader would then have to handle.
+ if (v === 'include' || v === 'exclude') modules[id] = v;
+ }
+ if (Object.keys(modules).length > 0) features.modules = modules;
+ }
if (f.physics && typeof f.physics === 'object') {
const p = f.physics as Record<string, unknown>;
const physics: NonNullable<ProjectFeatures['physics']> = {};
diff --git a/pipeline/src/project/runtimeConfig.ts b/pipeline/src/project/runtimeConfig.ts
index 4d7612aeb..970120a4a 100644
--- a/pipeline/src/project/runtimeConfig.ts
+++ b/pipeline/src/project/runtimeConfig.ts
@@ -27,7 +27,7 @@
* or is not listed there as a declared, reasoned gap.
*/
import type { AudioProjectConfig, PackagedGameConfig, Physics2DPluginConfig } from 'esengine';
-import { resolveScreenFit, SORTING_LAYER_COUNT, type ProjectManifest } from './format';
+import { resolveScreenFit, SORTING_LAYER_COUNT, type ProjectFeatures, type ProjectManifest } from './format';
/** The project's camera fit as a runtime takes it (`scaleMode < 0` ⇒ off). */
export interface RuntimeScreenFit {
@@ -237,6 +237,8 @@ export function cookOptionsOf(manifest: Pick<ProjectManifest, 'packaging'>): Coo
* package silently differed from the one a person makes.
*/
export interface PackagingOptions {
+ /** What the project says about its engine modules; see ProjectFeatures.modules. */
+ features: ProjectFeatures | undefined;
compressWasm: boolean;
engineSubpackage: boolean;
excludeScenes: string[];
@@ -244,9 +246,13 @@ export interface PackagingOptions {
appIcon: string | undefined;
}
-export function packagingOptionsOf(manifest: Pick<ProjectManifest, 'packaging'>): PackagingOptions {
+export function packagingOptionsOf(manifest: Pick<ProjectManifest, 'packaging' | 'features'>): PackagingOptions {
const p = manifest.packaging;
return {
+ // What the project says about its engine modules rides with the packaging
+ // options because every caller already spreads those — a second place to
+ // remember is a place one caller forgets.
+ features: manifest.features,
compressWasm: p?.compressWasm ?? false,
engineSubpackage: p?.engineSubpackage ?? false,
excludeScenes: p?.excludeScenes ?? [],
diff --git a/pipeline/tests/engine-installs.test.ts b/pipeline/tests/engine-installs.test.ts
index 02c6232d7..0fbddc78e 100644
--- a/pipeline/tests/engine-installs.test.ts
+++ b/pipeline/tests/engine-installs.test.ts
@@ -9,14 +9,14 @@
* fine — it was never installed.
*/
import { describe, it, expect } from 'vitest';
-import { engineInstalls } from '../src/bundle/engineInstalls';
+import { engineInstalls, moduleChoices } from '../src/bundle/engineInstalls';
import { ESENGINE_SUBPATHS } from '../src/bundle/esengineResolve';
import { SUBSYSTEM_INSTALL, type Subsystem } from '../src/project/targetSupport';
describe('the engine modules a package installs', () => {
it('takes a subsystem from the components its content authored', () => {
expect(engineInstalls({ subsystems: ['tilemap', 'ai'] }))
- .toEqual({ lean: true, subpaths: ['esengine/ai', 'esengine/tilemap'] });
+ .toEqual({ lean: true, subpaths: ['esengine/ai', 'esengine/tilemap'], refused: [] });
});
it('takes one a document names by asset rather than by component', () => {
@@ -41,7 +41,7 @@ describe('the engine modules a package installs', () => {
it('asks for nothing when everything in use is in the base entry', () => {
expect(engineInstalls({ subsystems: ['text', 'particles', 'postprocess'] }))
- .toEqual({ lean: true, subpaths: [] });
+ .toEqual({ lean: true, subpaths: [], refused: [] });
});
// Video has no subpath to install it, so a project with video cannot be lean
@@ -95,3 +95,73 @@ describe('every subpath the SDK publishes', () => {
expect(unpublished).toEqual([]);
});
});
+
+/**
+ * What a project SAYS, against what the build detects. Detection is right about
+ * almost everything, so these two exist for what it cannot see: a module only a
+ * script reaches, and a module a build must not carry whatever the content says.
+ */
+describe('a project that overrides what the build detected', () => {
+ it('installs one nothing detected, which is what `include` is for', () => {
+ const plan = engineInstalls({ choices: { 'esengine/physics': 'include' } });
+ expect(plan.subpaths).toEqual(['esengine/physics']);
+ expect(plan.refused).toEqual([]);
+ });
+
+ it('ignores an `include` for a module the SDK does not publish', () => {
+ expect(engineInstalls({ choices: { 'esengine/nope': 'include' } }).subpaths).toEqual([]);
+ });
+
+ it('leaves out one it excluded that nothing uses', () => {
+ expect(engineInstalls({
+ subsystems: ['tilemap'], choices: { 'esengine/ai': 'exclude' },
+ })).toMatchObject({ subpaths: ['esengine/tilemap'], refused: [] });
+ });
+
+ // The half that matters: a package missing the subsystem its own scene needs
+ // boots, draws, and is simply wrong — so the export has to refuse instead.
+ it('refuses one it excluded that the content uses, naming what said so', () => {
+ const plan = engineInstalls({
+ subsystems: ['tilemap'], choices: { 'esengine/tilemap': 'exclude' },
+ });
+ expect(plan.subpaths).toEqual([]);
+ expect(plan.refused).toEqual([
+ { specifier: 'esengine/tilemap', evidence: 'a tilemap component in the content' },
+ ]);
+ });
+
+ it('names the asset that argues with an exclusion, not the module', () => {
+ expect(engineInstalls({
+ assetPaths: ['assets/logic/Door.esgraph'], choices: { 'esengine/logic': 'exclude' },
+ }).refused[0]).toEqual({ specifier: 'esengine/logic', evidence: 'assets/logic/Door.esgraph' });
+ });
+
+ it('names the script that argues with one', () => {
+ expect(engineInstalls({
+ scriptImports: ['esengine/replication'], choices: { 'esengine/replication': 'exclude' },
+ }).refused[0].evidence).toContain('a project script imports');
+ });
+});
+
+describe('what a project said, read off its manifest', () => {
+ it('is empty when it said nothing', () => {
+ expect(moduleChoices(undefined)).toEqual({});
+ expect(moduleChoices({})).toEqual({});
+ });
+
+ // physics.enabled was this for one module, and older projects still carry it.
+ it('reads the older physics.enabled as an include', () => {
+ expect(moduleChoices({ physics: { enabled: true } }))
+ .toEqual({ 'esengine/physics': 'include' });
+ });
+
+ it('lets the module a project last edited win over the older field', () => {
+ expect(moduleChoices({
+ physics: { enabled: true }, modules: { 'esengine/physics': 'exclude' },
+ })).toEqual({ 'esengine/physics': 'exclude' });
+ });
+
+ it('says nothing for physics.enabled false — off is the default, not a refusal', () => {
+ expect(moduleChoices({ physics: { enabled: false } })).toEqual({});
+ });
+});
diff --git a/pipeline/tests/export-engine-installs.test.ts b/pipeline/tests/export-engine-installs.test.ts
index f61c79cf4..0e309bf88 100644
--- a/pipeline/tests/export-engine-installs.test.ts
+++ b/pipeline/tests/export-engine-installs.test.ts
@@ -16,6 +16,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { exportGame } from '../src/export/exportGame';
import { writeFakeSdkDist } from './fixtures/fakeSdkDist';
+import type { ModuleChoice } from '../src/project/format';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const HOSTS = path.join(HERE, '..', 'src', 'runtime');
@@ -123,3 +124,52 @@ describe('a web package built on a lean entry', () => {
} finally { rmSync(f.root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }); }
});
});
+
+/**
+ * A module a project refused, against content that uses it.
+ *
+ * The package this would otherwise make boots and draws and is missing the
+ * subsystem its own scene needs, with nothing saying which one — so the export
+ * refuses to make it, and names what argued.
+ */
+describe('a web package whose project excluded a module', () => {
+ /** The export takes what the project said as an option, the way it takes every
+ * other project-derived setting; `packagingOptionsOf` is what derives it. */
+ const withChoice = (components: string[], modules: Record<string, ModuleChoice>) => ({
+ ...setup(components), features: { modules },
+ });
+ const runWith = (f: ReturnType<typeof withChoice>) => exportGame({
+ root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,
+ sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),
+ outDir: f.out, features: f.features,
+ });
+
+ it('fails, naming the module and what said the project uses it', async () => {
+ const f = withChoice(['Tilemap'], { 'esengine/tilemap': 'exclude' });
+ try {
+ const res = await runWith(f);
+ expect(res.ok).toBe(false);
+ expect(res.errors.join('\n')).toContain('esengine/tilemap is excluded');
+ expect(res.errors.join('\n')).toContain('a tilemap component in the content');
+ } finally { rmSync(f.root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }); }
+ });
+
+ it('builds when the excluded module is one the content does not use', async () => {
+ const f = withChoice(['Tilemap'], { 'esengine/ai': 'exclude' });
+ try {
+ const res = await runWith(f);
+ expect(res.errors).toEqual([]);
+ expect(readFileSync(path.join(f.out, 'game.js'), 'utf8')).toContain('import "esengine/tilemap"');
+ } finally { rmSync(f.root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }); }
+ });
+
+ // What `include` is for: a module only a script reaches, which no scan sees.
+ it('installs one the project forced in although nothing detected it', async () => {
+ const f = withChoice(['Transform'], { 'esengine/replication': 'include' });
+ try {
+ await runWith(f);
+ expect(readFileSync(path.join(f.out, 'game.js'), 'utf8'))
+ .toContain('import "esengine/replication"');
+ } finally { rmSync(f.root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }); }
+ });
+});
diff --git a/pipeline/tests/packaging-settings-reach.test.ts b/pipeline/tests/packaging-settings-reach.test.ts
index bc9a16823..fb0270ada 100644
--- a/pipeline/tests/packaging-settings-reach.test.ts
+++ b/pipeline/tests/packaging-settings-reach.test.ts
@@ -40,3 +40,39 @@ describe('a packaging setting a project declares', () => {
expect(packagingOptionsOf(m).excludeScenes).toEqual(['assets/scenes/dev.esscene']);
});
});
+
+/**
+ * What a project says about its engine modules rides with the packaging options
+ * because every caller already spreads those. A second place to remember is a
+ * place one caller forgets — which is how `compressWasm` reached the dialog and
+ * nothing else.
+ */
+describe('the modules a project declares', () => {
+ it('survives the parser', () => {
+ const m = parseManifest({
+ formatVersion: '1', name: 'p',
+ features: { modules: { 'esengine/tilemap': 'exclude', 'esengine/ai': 'include' } },
+ });
+ expect(m.features?.modules)
+ .toEqual({ 'esengine/tilemap': 'exclude', 'esengine/ai': 'include' });
+ });
+
+ it('drops `auto`, which is what saying nothing already means', () => {
+ const m = parseManifest({
+ formatVersion: '1', name: 'p', features: { modules: { 'esengine/ai': 'auto' } },
+ });
+ expect(m.features?.modules).toBeUndefined();
+ });
+
+ it('reaches the export options every caller spreads', () => {
+ const m = parseManifest({
+ formatVersion: '1', name: 'p', features: { modules: { 'esengine/ai': 'exclude' } },
+ });
+ expect(packagingOptionsOf(m).features?.modules).toEqual({ 'esengine/ai': 'exclude' });
+ });
+
+ it('carries an older project\'s physics.enabled through as well', () => {
+ const m = parseManifest({ formatVersion: '1', name: 'p', features: { physics: { enabled: true } } });
+ expect(packagingOptionsOf(m).features?.physics?.enabled).toBe(true);
+ });
+});