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(cocos): esengine/cocos as a published subpath, cc and cc/env resolved to it in every script bundle with legacy decorators, and an entry the importer writes that brings the Cocos scripts into the bundle

yhh52592a558c3b
diff --git a/pipeline/src/bundle/buildScripts.ts b/pipeline/src/bundle/buildScripts.ts
index 2a93974f0..9e288b5b8 100644
--- a/pipeline/src/bundle/buildScripts.ts
+++ b/pipeline/src/bundle/buildScripts.ts
@@ -18,6 +18,7 @@ import path from 'node:path';
import { loadEsbuild } from './esbuildRuntime';
import { explainBundleErrors, type BundleMessage } from './bundleDiagnostics';
import { officialPackagesPlugin } from './officialPackages';
+import { cocosCompatPlugin } from './cocosCompat';
/** esengine and any subpath import are left for the realm's import map to resolve. */
const EXTERNAL = ['esengine', 'esengine/*'];
@@ -58,7 +59,7 @@ export async function buildProjectScripts(
platform: 'browser',
target: 'es2020',
external: EXTERNAL,
- plugins: [officialPackagesPlugin(opts.packagesDir)],
+ plugins: [officialPackagesPlugin(opts.packagesDir), cocosCompatPlugin()],
outfile: outputPath,
sourcemap: true,
write: true,
diff --git a/pipeline/src/bundle/cocosCompat.ts b/pipeline/src/bundle/cocosCompat.ts
new file mode 100644
index 000000000..c71a2be6a
--- /dev/null
+++ b/pipeline/src/bundle/cocosCompat.ts
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file Scripts written for Cocos Creator build against the engine, in every bundle a project's scripts go into.
+ *
+ * Two things a Cocos script assumes that a plain bundle does not give it:
+ *
+ * - `import { Component } from 'cc'` (and `'cc/env'` for its build flags). Both name the compatibility layer, `esengine/cocos`.
+ * The import is handed back to the bundler as that specifier, so it resolves however the build resolves `esengine/*`:
+ * left external for the page's import map, or aliased and inlined.
+ * - Legacy (`experimentalDecorators`) decorators, with fields assigned by the constructor rather than defined. Cocos scripts are
+ * written for that, the layer's `@ccclass` / `@property` have that signature, and esbuild's default for a file whose nearest
+ * tsconfig says nothing is the newer standard form, under which every decorator in the project would run with the wrong
+ * arguments. A Cocos project's own tsconfig usually extends a file the editor generates and the checkout lacks, so it cannot
+ * be relied on to say it.
+ *
+ * Only files that import `cc` are touched: a script that does not is not a Cocos script, and keeps whatever its own tsconfig says.
+ * The project's files are read, never written.
+ */
+import { readFile } from 'node:fs/promises';
+import path from 'node:path';
+import type { Plugin } from 'esbuild';
+import { loadEsbuild } from './esbuildRuntime';
+
+/** What `cc` and `cc/env` resolve to. */
+export const COCOS_LAYER = 'esengine/cocos';
+
+const CC = /^cc(\/env)?$/;
+const IMPORTS_CC = /(?:from|import)\s*\(?\s*['"]cc(?:\/env)?['"]/;
+const TS = /\.tsx?$/;
+
+const RESOLVING = Symbol('cocos-compat:resolving');
+
+export function cocosCompatPlugin(): Plugin {
+ return {
+ name: 'estella-cocos-compat',
+ setup(build) {
+ build.onResolve({ filter: CC }, async (args) => {
+ if (args.pluginData === RESOLVING) return undefined;
+ const layer = await build.resolve(COCOS_LAYER, {
+ kind: args.kind, importer: args.importer, resolveDir: args.resolveDir, pluginData: RESOLVING,
+ });
+ if (layer.errors.length > 0) {
+ return { errors: [{ text: `"${args.path}" is the Cocos Creator module, which the engine provides as "${COCOS_LAYER}" — and that did not resolve here: ${layer.errors[0]!.text}` }] };
+ }
+ return { path: layer.path, external: layer.external, sideEffects: layer.sideEffects };
+ });
+
+ build.onLoad({ filter: TS }, async (args) => {
+ if (args.path.includes(`${path.sep}node_modules${path.sep}`)) return undefined;
+ let source: string;
+ try {
+ source = await readFile(args.path, 'utf8');
+ } catch {
+ return undefined;
+ }
+ if (!IMPORTS_CC.test(source)) return undefined;
+ const esbuild = await loadEsbuild();
+ const out = await esbuild.transform(source, {
+ loader: args.path.endsWith('x') ? 'tsx' : 'ts',
+ sourcefile: args.path,
+ sourcemap: 'inline',
+ target: 'es2020',
+ tsconfigRaw: { compilerOptions: { experimentalDecorators: true, useDefineForClassFields: false } },
+ });
+ return { contents: out.code, loader: 'js', resolveDir: path.dirname(args.path) };
+ });
+ },
+ };
+}
diff --git a/pipeline/src/bundle/engineSubpaths.ts b/pipeline/src/bundle/engineSubpaths.ts
index 232fa5adb..fa310e075 100644
--- a/pipeline/src/bundle/engineSubpaths.ts
+++ b/pipeline/src/bundle/engineSubpaths.ts
@@ -28,6 +28,7 @@ export const ESENGINE_SUBPATHS: Readonly<Record<string, string>> = {
'esengine/replication': 'net/replication/index.js',
'esengine/session': 'net/session/index.js',
'esengine/gameplay': 'gameplay/index.js',
+ 'esengine/cocos': 'cocos/index.js',
'esengine/dragonbones': 'dragonbones/index.js',
'esengine/physics': 'physics/index.js',
'esengine/physics3d': 'physics3d/index.js',
@@ -47,7 +48,7 @@ export const ESENGINE_SUBPATHS: Readonly<Record<string, string>> = {
* the debug channel a development export adds, and the session layer, which a
* game's own code imports and nothing in a scene asks for. Named here so the pickable set is derived rather than written twice.
*/
-export const NOT_A_MODULE: ReadonlySet<string> = new Set(['esengine/wasm', 'esengine/debug-channel', 'esengine/session', 'esengine/douyin', 'esengine/kuaishou', 'esengine/bilibili', 'esengine/quickgame', 'esengine/alipay', 'esengine/huawei', 'esengine/openpaas']);
+export const NOT_A_MODULE: ReadonlySet<string> = new Set(['esengine/wasm', 'esengine/debug-channel', 'esengine/session', 'esengine/cocos', 'esengine/douyin', 'esengine/kuaishou', 'esengine/bilibili', 'esengine/quickgame', 'esengine/alipay', 'esengine/huawei', 'esengine/openpaas']);
/** The modules a project can force in or refuse, as `features.modules` keys it. */
export const ENGINE_MODULES: readonly string[] =
diff --git a/pipeline/src/export/exportGame.ts b/pipeline/src/export/exportGame.ts
index fd160ad05..44041d5df 100644
--- a/pipeline/src/export/exportGame.ts
+++ b/pipeline/src/export/exportGame.ts
@@ -60,6 +60,7 @@ import { genericPlayableProfile, type PlayableAdProfile } from './playableAdProf
import type { OnExportProgress } from './exportProgress';
import { ESENGINE_EXTERNAL, ESENGINE_SUBPATHS } from '../bundle/esengineResolve';
import { officialPackagesPlugin } from '../bundle/officialPackages';
+import { cocosCompatPlugin } from '../bundle/cocosCompat';
import type { RpkSigningKey } from './rpk';
import { buildCompiledSystems, type BuildMode } from '../bundle/buildCompiledSystems';
import { resolveEmcc, runEmcc } from '../bundle/emccPath';
@@ -947,7 +948,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
platform: 'browser',
target: 'es2020',
external: ESENGINE_EXTERNAL,
- plugins: [officialPackagesPlugin(opts.packagesDir)],
+ plugins: [officialPackagesPlugin(opts.packagesDir), cocosCompatPlugin()],
minify: opts.minify ?? false,
sourcemap: sourceMaps,
write: true,
@@ -1047,7 +1048,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
const proj = nativeContent
? await build({
...common, format: 'iife', external: [],
- plugins: [esengineGlobalPlugin(), officialPackagesPlugin(opts.packagesDir)],
+ plugins: [esengineGlobalPlugin(), officialPackagesPlugin(opts.packagesDir), cocosCompatPlugin()],
entryPoints: [scriptsAbs], outfile: path.join(payloadDir, 'scripts.js'),
})
: await build({ ...common, entryPoints: [scriptsAbs], outfile: path.join(payloadDir, 'scripts.mjs') });
diff --git a/pipeline/src/export/exportMiniGame.ts b/pipeline/src/export/exportMiniGame.ts
index b8fc5ff76..d190cac2e 100644
--- a/pipeline/src/export/exportMiniGame.ts
+++ b/pipeline/src/export/exportMiniGame.ts
@@ -49,6 +49,7 @@ import { runtimeHostEntry } from '../bundle/runtimeHosts';
import { breakdownOf, type ModuleBytes } from './bundleBreakdown';
import { esengineAlias } from '../bundle/esengineResolve';
import { officialPackagesPlugin } from '../bundle/officialPackages';
+import { cocosCompatPlugin } from '../bundle/cocosCompat';
import { explainBundleErrors, type BundleMessage } from '../bundle/bundleDiagnostics';
import { scanSideModuleIds, sideModuleFiles, textureDecoderBytes } from '../bundle/sideModuleScan';
import { exportedAssetFiles, pruneExportedAssets } from './assetCleanup';
@@ -586,7 +587,7 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {
// devtools accepts it; es2017 down-levels those while keeping async/await.
target: profile.esTarget,
alias: esengineAlias(opts.sdkDir, lean ? leanEntry! : profile.sdkEntryFile),
- plugins: [officialPackagesPlugin(opts.packagesDir)],
+ plugins: [officialPackagesPlugin(opts.packagesDir), cocosCompatPlugin()],
minify: opts.minify ?? false,
sourcemap: false,
outfile: path.join(absOut, 'game-bundle.js'),
diff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.ts
index f86b48eb8..01efd7258 100644
--- a/pipeline/src/export/exportPlayable.ts
+++ b/pipeline/src/export/exportPlayable.ts
@@ -33,6 +33,7 @@ import { optimizePlayableAssets, playableAssetsJsonBytes, type PlayableOptimizat
import type { OnExportProgress } from './exportProgress';
import { esengineAlias } from '../bundle/esengineResolve';
import { officialPackagesPlugin } from '../bundle/officialPackages';
+import { cocosCompatPlugin } from '../bundle/cocosCompat';
import { explainBundleErrors, type BundleMessage } from '../bundle/bundleDiagnostics';
import type { ScreenOrientation } from './orientationHtml';
import { genericPlayableProfile, playableAdInjection, isPlayableZipFileName, type PlayableAdProfile } from './playableAdProfile';
@@ -319,7 +320,7 @@ export async function exportPlayable(opts: {
// esengine is INLINED (single-file, no import map) → resolve it from the SDK
// dist; the project root has no esengine installed.
alias: esengineAlias(opts.sdkDir),
- plugins: [officialPackagesPlugin(opts.packagesDir)],
+ plugins: [officialPackagesPlugin(opts.packagesDir), cocosCompatPlugin()],
minify: opts.minify ?? true,
write: false,
outfile: 'game-bundle.js',
diff --git a/pipeline/src/import/cocos/importProject.ts b/pipeline/src/import/cocos/importProject.ts
index fad585124..f214463e8 100644
--- a/pipeline/src/import/cocos/importProject.ts
+++ b/pipeline/src/import/cocos/importProject.ts
@@ -127,9 +127,15 @@ export function importCocosProject(opts: CocosImportOptions): ImportReportData {
};
const scripts = buildScriptIndex(index);
+ /** The scripts a converted document refers to, which the project has to bundle for those components to exist. */
+ const usedScripts = new Set<string>();
const ctx: ConvertContext = {
assets: index,
- scriptClass: (classId) => scripts.get(classId),
+ scriptClass: (classId) => {
+ const found = scripts.get(classId);
+ if (found) usedScripts.add(found.rel);
+ return found;
+ },
prefabAssetRef: (uuid) => ctx.prefabRef(uuid),
report,
where: '',
@@ -224,6 +230,25 @@ export function importCocosProject(opts: CocosImportOptions): ImportReportData {
}
}
+ if (usedScripts.size > 0) {
+ // The scripts stay where they are, unchanged; this file is how the new project's bundle reaches them.
+ const entry = path.join(out, 'src', 'cocos-scripts.ts');
+ const imports = [...usedScripts].sort().map((rel) => {
+ const target = path.join(assetsDir, rel.replace(/\.(ts|js)$/, ''));
+ // On another drive there is no relative path, only the absolute one, which an import takes just as well.
+ const rel2 = path.relative(path.dirname(entry), target).split(path.sep).join('/');
+ return `import '${path.isAbsolute(rel2) || /^[A-Za-z]:/.test(rel2) || rel2.startsWith('.') ? rel2 : `./${rel2}`}';`;
+ });
+ const text = [
+ "// Generated by import-cocos. Brings the Cocos project's scripts into this project's bundle, read from where they are.",
+ "// Import this file from src/main.ts. Scripts resolve `cc` to the engine's compatibility layer.",
+ "import 'esengine/cocos';",
+ ...imports, '',
+ ].join('\n');
+ if (!opts.dryRun) writeOut(entry, text);
+ report.note('cocos-scripts-entry', `${path.relative(out, entry).split(path.sep).join('/')}: ${usedScripts.size} script(s)`);
+ }
+
report.textures = textures.size;
if (!opts.dryRun) {
for (const { entry, slice, hints } of textures.values()) {
diff --git a/pipeline/tests/cocos-compat-bundle.test.ts b/pipeline/tests/cocos-compat-bundle.test.ts
new file mode 100644
index 000000000..2f6b71e3b
--- /dev/null
+++ b/pipeline/tests/cocos-compat-bundle.test.ts
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file A Cocos script bundles against the engine: `cc` and `cc/env` become `esengine/cocos`, however the build resolves that, and
+ * the script's decorators come out in the legacy form the layer's `@ccclass` / `@property` take.
+ */
+import { existsSync, mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { afterAll, beforeAll, describe, expect, it } from 'vitest';
+import { build } from 'esbuild';
+import { cocosCompatPlugin } from '../src/bundle/cocosCompat';
+
+const SCRIPT = `
+import { _decorator, Component } from 'cc';
+import { EDITOR } from 'cc/env';
+const { ccclass, property } = _decorator;
+
+@ccclass('Counter')
+export class Counter extends Component {
+ @property speed = 3;
+ start() { if (EDITOR) return; this.speed++; }
+}
+`;
+
+describe('bundling a Cocos script', () => {
+ let root: string;
+ beforeAll(() => {
+ root = mkdtempSync(path.join(tmpdir(), 'cocos-compat-'));
+ mkdirSync(path.join(root, 'scripts'));
+ writeFileSync(path.join(root, 'scripts', 'Counter.ts'), SCRIPT);
+ // A file that is not a Cocos script keeps its own rules: no `cc` import, so it is not touched.
+ writeFileSync(path.join(root, 'scripts', 'Plain.ts'), 'export const answer: number = 42;\n');
+ writeFileSync(path.join(root, 'layer.js'), 'export const _decorator = { ccclass: (n) => (c) => c, property: () => () => {} };\nexport class Component {}\nexport const EDITOR = false;\n');
+ });
+ afterAll(() => rmSync(root, { recursive: true, force: true }));
+
+ const run = (extra: object) => build({
+ entryPoints: [path.join(root, 'scripts', 'Counter.ts')],
+ bundle: true, write: false, format: 'esm', platform: 'browser', logLevel: 'silent',
+ plugins: [cocosCompatPlugin()], ...extra,
+ });
+
+ it('leaves cc and cc/env as esengine/cocos when the build keeps esengine external', async () => {
+ const out = (await run({ external: ['esengine', 'esengine/*'] })).outputFiles[0]!.text;
+ expect(out).toMatch(/from "esengine\/cocos"/);
+ expect(out).not.toMatch(/from "cc/);
+ });
+
+ it('inlines the layer when the build aliases it, for the builds that have no import map', async () => {
+ const out = (await run({ alias: { 'esengine/cocos': path.join(root, 'layer.js') }, format: 'iife' })).outputFiles[0]!.text;
+ expect(out).not.toMatch(/esengine\/cocos|from "cc/);
+ expect(out).toMatch(/Component = class|class Component/); // the layer's own text is in the bundle
+ });
+
+ it('lowers decorators in the legacy form with fields assigned, not defined', async () => {
+ const out = (await run({ external: ['esengine/*'] })).outputFiles[0]!.text;
+ expect(out).toMatch(/__decorateClass|__decorate\(/);
+ expect(out).not.toMatch(/__esDecorate|__publicField/);
+ expect(out).toMatch(/this\.speed = 3/);
+ });
+
+ it('says what it could not do, in the layer\'s terms, when the layer does not resolve', async () => {
+ await expect(run({})).rejects.toMatchObject({ errors: expect.arrayContaining([expect.objectContaining({ text: expect.stringContaining('esengine/cocos') })]) });
+ });
+
+ it('does not touch a file that is not a Cocos script', async () => {
+ const plain = await build({
+ entryPoints: [path.join(root, 'scripts', 'Plain.ts')], bundle: true, write: false, format: 'esm', logLevel: 'silent', plugins: [cocosCompatPlugin()],
+ });
+ expect(plain.outputFiles[0]!.text).toContain('answer = 42');
+ });
+
+ // Against the SDK as built, when it has been: every name a script imports from `cc` must be a name the layer exports, or the
+ // bundle fails with esbuild's "no matching export" at the script, not at a user's first run.
+ const BUILT = path.resolve(__dirname, '../../sdk/dist/cocos/index.js');
+ it.skipIf(!existsSync(BUILT))('bundles against the layer as built, for the names a script commonly imports', async () => {
+ const names = ['_decorator', 'Component', 'Node', 'Vec2', 'Vec3', 'Quat', 'Color', 'Size', 'Rect', 'director', 'UITransform', 'Label',
+ 'Sprite', 'Button', 'Widget', 'Layout', 'EventTouch', 'NodeEventType', 'EventHandler', 'Prefab', 'SpriteFrame', 'v2', 'v3', 'find', 'isValid'];
+ writeFileSync(path.join(root, 'scripts', 'Names.ts'), `import { ${names.join(', ')} } from 'cc';
+import { EDITOR, DEBUG } from 'cc/env';
+export default [${names.join(', ')}, EDITOR, DEBUG];
+`);
+ const result = await build({
+ entryPoints: [path.join(root, 'scripts', 'Names.ts')], bundle: true, write: false, format: 'esm', platform: 'browser', logLevel: 'silent',
+ alias: { 'esengine/cocos': BUILT }, plugins: [cocosCompatPlugin()],
+ });
+ expect(result.errors).toEqual([]);
+ });
+});
diff --git a/pipeline/tests/cocos-import-layer.test.ts b/pipeline/tests/cocos-import-layer.test.ts
index 4e80198ae..af6457793 100644
--- a/pipeline/tests/cocos-import-layer.test.ts
+++ b/pipeline/tests/cocos-import-layer.test.ts
@@ -114,6 +114,15 @@ describe('importing for the compatibility layer', () => {
expect(report.components['script:Hud']).toEqual({ mapped: 1, partial: 0, unmapped: 0 });
});
+ it('writes the entry that brings the scripts into the bundle, importing them where they are', () => {
+ const entry = readFileSync(path.join(root, 'out', 'src', 'cocos-scripts.ts'), 'utf8');
+ expect(entry).toContain("import 'esengine/cocos';");
+ const line = entry.split('\n').find((l) => l.endsWith("scripts/Hud';"))!;
+ expect(line).toBeDefined();
+ // the path leads back to the Cocos project, which is not copied
+ expect(path.resolve(root, 'out', 'src', line.slice("import '".length, -2) + '.ts')).toBe(path.join(root, 'creator', 'assets', 'scripts', 'Hud.ts'));
+ });
+
it('counts the components it maps', () => {
for (const type of ['cc.Widget', 'cc.Layout', 'cc.Button', 'cc.UITransform']) expect(report.components[type]!.unmapped).toBe(0);
});
diff --git a/sdk/package.json b/sdk/package.json
index 9441a6df1..057b7b1eb 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -33,6 +33,7 @@
"./dist/net/replication/index.js",
"./dist/net/session/index.js",
"./dist/gameplay/index.js",
+ "./dist/cocos/index.js",
"./dist/physics/index.js",
"./dist/physics3d/index.js",
"./dist/douyin/index.js",
@@ -147,6 +148,10 @@
"import": "./dist/gameplay/index.js",
"types": "./dist/gameplay/index.d.ts"
},
+ "./cocos": {
+ "import": "./dist/cocos/index.js",
+ "types": "./dist/cocos/index.d.ts"
+ },
"./physics": {
"import": "./dist/physics/index.js",
"types": "./dist/physics/index.d.ts"
diff --git a/sdk/rolldown.config.js b/sdk/rolldown.config.js
index b6f4e44dc..d2fce7a23 100644
--- a/sdk/rolldown.config.js
+++ b/sdk/rolldown.config.js
@@ -118,8 +118,8 @@ export default defineConfig([
'ai/index': 'src/ai/index.ts',
'net/replication/index': 'src/net/replication/index.ts',
'net/session/index': 'src/net/session/index.ts',
- 'net/session/index': 'src/net/session/index.ts',
'gameplay/index': 'src/gameplay/index.ts',
+ 'cocos/index': 'src/cocos/index.ts',
'dragonbones/index': 'src/dragonbones/index.ts',
'douyin/index': 'src/platform/douyin/index.ts',
'kuaishou/index': 'src/platform/kuaishou/index.ts',
diff --git a/sdk/rollup.config.js b/sdk/rollup.config.js
index 442fc9f61..019d09b30 100644
--- a/sdk/rollup.config.js
+++ b/sdk/rollup.config.js
@@ -41,6 +41,7 @@ export default [
'net/replication/index': 'src/net/replication/index.ts',
'net/session/index': 'src/net/session/index.ts',
'gameplay/index': 'src/gameplay/index.ts',
+ 'cocos/index': 'src/cocos/index.ts',
'dragonbones/index': 'src/dragonbones/index.ts',
'wasm': 'src/wasm.ts',
},
diff --git a/sdk/src/cocos/env.ts b/sdk/src/cocos/env.ts
new file mode 100644
index 000000000..79477ec39
--- /dev/null
+++ b/sdk/src/cocos/env.ts
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file cocos/env.ts
+ * @brief The build-time flags a Cocos script imports from `cc/env`.
+ *
+ * Scripts guard editor-only and debug-only code with these (`if (EDITOR) ...`, `DEV && console.log(...)`). In the engine's runtime
+ * none of the editor ones is true, which is what lets that code fall away. The platform flags say "browser", the closest honest
+ * answer for a build that is not a Cocos one; a script that needs to know more asks the engine's own platform API.
+ */
+export const EDITOR = false;
+export const EDITOR_NOT_IN_PREVIEW = false;
+export const PREVIEW = false;
+export const BUILD = true;
+export const TEST = false;
+export const DEBUG = false;
+export const DEV = false;
+export const SERVER_MODE = false;
+export const HTML5 = true;
+export const NATIVE = false;
+export const JSB = false;
+export const RUNTIME_BASED = false;
+export const MINIGAME = false;
+export const WECHAT = false;
+export const WECHAT_MINI_PROGRAM = false;
+export const BYTEDANCE = false;
+export const ALIPAY = false;
+export const XIAOMI = false;
+export const HUAWEI = false;
+export const OPPO = false;
+export const VIVO = false;
+export const COCOSPLAY = false;
+export const ANDROID = false;
+export const IOS = false;
+export const WINDOWS = false;
+export const MAC = false;
+export const LINUX = false;
+export const OHOS = false;
+export const SUPPORT_JIT = true;
+export const PHYSICS_BUILTIN = false;
+export const PHYSICS_CANNON = false;
+export const PHYSICS_AMMO = false;
+export const PHYSICS_PHYSX = false;
+export const NET_MODE = 0;
diff --git a/sdk/src/cocos/index.ts b/sdk/src/cocos/index.ts
index 72c64552c..305c378fb 100644
--- a/sdk/src/cocos/index.ts
+++ b/sdk/src/cocos/index.ts
@@ -28,6 +28,8 @@ export { registerBuiltinComponent, type BuiltinAdapter } from './builtins';
export { UITransform, Label, LabelOutline, LabelShadow, Sprite, UIOpacity, Button, EventHandler, Widget, Layout, getVisibleSize, setVisibleSize } from './ui';
export { Touch, EventTouch, pumpTouches } from './input';
export { declareBuiltinScripts, redeclareBuiltinScripts } from './builtinScripts';
+/** `cc/env` is the same module here: its flags are named exports beside the rest. */
+export * from './env';
export { classInfoNamed, classInfoOf, allClassInfos, COMPONENT_PREFIX, resetClassRegistry } from './registry';
import { declareBuiltinScripts as declare } from './builtinScripts';