From 066cc630043470cda8d0544694791e575b38e624 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 2 Jul 2025 17:24:34 +0000 Subject: [PATCH] Changes from background composer bc-e1b0b2f8-0fe8-433f-b1d5-226684f78342 --- packages/runtime-core/package.json | 29 ++++++++++++++----------- packages/runtime-core/project.json | 22 ++++++++++++++----- packages/runtime-core/rslib.config.ts | 28 +++++------------------- packages/runtime-core/tsconfig.lib.json | 1 + packages/runtime/project.json | 4 ++++ packages/runtime/src/core.ts | 4 ---- packages/runtime/tsconfig.lib.json | 11 ++++++++-- 7 files changed, 52 insertions(+), 47 deletions(-) diff --git a/packages/runtime-core/package.json b/packages/runtime-core/package.json index 5e4067f5fa1..dcd938ce280 100644 --- a/packages/runtime-core/package.json +++ b/packages/runtime-core/package.json @@ -3,9 +3,9 @@ "version": "0.14.0", "type": "module", "author": "zhouxiao ", - "main": "./dist/index.cjs.cjs", - "module": "./dist/index.esm.js", - "types": "./src/index.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "license": "MIT", "publishConfig": { "access": "public" @@ -20,35 +20,38 @@ "src/", "README.md" ], + "scripts": { + "postbuild": "npx tsc --declaration --declarationDir ./dist --emitDeclarationOnly --project tsconfig.lib.json && find dist -name 'index.d.ts' -path '*/src/index.d.ts' -exec cp {} dist/index.d.ts \\; && find dist -name 'types.d.ts' -path '*/src/types.d.ts' -exec cp {} dist/types.d.ts \\;" + }, "exports": { ".": { "import": { - "types": "./src/index.ts", - "default": "./dist/index.esm.js" + "types": "./dist/index.d.ts", + "default": "./dist/index.js" }, "require": { - "types": "./src/index.ts", - "default": "./dist/index.cjs.cjs" + "types": "./dist/index.d.ts", + "default": "./dist/index.cjs" } }, "./types": { "import": { - "types": "./src/types.ts", - "default": "./dist/types.esm.js" + "types": "./dist/types.d.ts", + "default": "./dist/types.js" }, "require": { - "types": "./src/types.ts", - "default": "./dist/types.cjs.cjs" + "types": "./dist/types.d.ts", + "default": "./dist/types.cjs" } } }, "typesVersions": { "*": { ".": [ - "./src/index.ts" + "./dist/index.d.ts" ], "types": [ - "./src/types.ts" + "./dist/types.d.ts" ] } }, diff --git a/packages/runtime-core/project.json b/packages/runtime-core/project.json index fd8d8bb8dda..8b312c0f8d1 100644 --- a/packages/runtime-core/project.json +++ b/packages/runtime-core/project.json @@ -6,13 +6,15 @@ "tags": ["type:pkg"], "targets": { "build": { - "executor": "../../tools/rslib-plugin:build", + "executor": "nx:run-commands", "outputs": ["{workspaceRoot}/packages/runtime-core/dist"], "options": { - "configFile": "rslib.config.ts", - "outputPath": "packages/runtime-core/dist", - "mode": "production", - "verbose": true + "commands": [ + "cd packages/runtime-core && npx rslib build", + "cd packages/runtime-core && npx tsc --declaration --declarationDir ./dist --emitDeclarationOnly --project tsconfig.lib.json", + "cd packages/runtime-core && find dist -name 'index.d.ts' -path '*/src/index.d.ts' -exec cp {} dist/index.d.ts \\;", + "cd packages/runtime-core && find dist -name 'types.d.ts' -path '*/src/types.d.ts' -exec cp {} dist/types.d.ts \\;" + ] }, "dependsOn": [ { @@ -21,6 +23,16 @@ } ] }, + "post-build": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "cd packages/runtime-core && npx tsc --declaration --declarationDir ./dist --emitDeclarationOnly --project tsconfig.lib.json", + "cd packages/runtime-core && find dist -name 'index.d.ts' -path '*/src/index.d.ts' -exec cp {} dist/index.d.ts \\;", + "cd packages/runtime-core && find dist -name 'types.d.ts' -path '*/src/types.d.ts' -exec cp {} dist/types.d.ts \\;" + ] + } + }, "build:rollup": { "executor": "@nx/rollup:rollup", "outputs": ["{workspaceRoot}/packages/runtime-core/dist"], diff --git a/packages/runtime-core/rslib.config.ts b/packages/runtime-core/rslib.config.ts index 96352e21ac6..e1564fc55ee 100644 --- a/packages/runtime-core/rslib.config.ts +++ b/packages/runtime-core/rslib.config.ts @@ -12,43 +12,25 @@ export default defineConfig({ }, output: { target: 'node', - format: ['esm', 'cjs'], distPath: { root: './dist', }, - filename: { - js: { - esm: '[name].esm.js', - cjs: '[name].cjs.cjs', - }, - dts: { - esm: '[name].esm.d.ts', - cjs: '[name].cjs.d.ts', - }, - }, }, lib: [ { format: 'esm', dts: true, - output: { - filename: { - js: '[name].esm.js', - dts: '[name].esm.d.ts', - }, - }, }, { format: 'cjs', dts: true, - output: { - filename: { - js: '[name].cjs.cjs', - dts: '[name].cjs.d.ts', - }, - }, }, ], + tools: { + bundlerChain: (config, { CHAIN_ID }) => { + config.output.path('./dist'); + }, + }, shims: true, bundle: false, external: ['@module-federation/sdk', '@module-federation/error-codes'], diff --git a/packages/runtime-core/tsconfig.lib.json b/packages/runtime-core/tsconfig.lib.json index a51e17924d1..05cb1979b91 100644 --- a/packages/runtime-core/tsconfig.lib.json +++ b/packages/runtime-core/tsconfig.lib.json @@ -3,6 +3,7 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "declaration": true, + "declarationMap": true, "types": ["node"] }, "include": ["src/**/*.ts", "global.d.ts"], diff --git a/packages/runtime/project.json b/packages/runtime/project.json index 4324b1ed002..4c7b4cacac1 100644 --- a/packages/runtime/project.json +++ b/packages/runtime/project.json @@ -29,6 +29,10 @@ { "target": "build", "dependencies": true + }, + { + "target": "post-build", + "projects": ["runtime-core"] } ] }, diff --git a/packages/runtime/src/core.ts b/packages/runtime/src/core.ts index e4dad252725..7bdca324337 100644 --- a/packages/runtime/src/core.ts +++ b/packages/runtime/src/core.ts @@ -1,5 +1 @@ -import runtimeCore from '@module-federation/runtime-core'; - export * from '@module-federation/runtime-core'; - -export default runtimeCore; diff --git a/packages/runtime/tsconfig.lib.json b/packages/runtime/tsconfig.lib.json index a51e17924d1..b3ebb849bf6 100644 --- a/packages/runtime/tsconfig.lib.json +++ b/packages/runtime/tsconfig.lib.json @@ -2,9 +2,16 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "declaration": true, + "declaration": false, + "skipLibCheck": true, + "declarationMap": false, "types": ["node"] }, "include": ["src/**/*.ts", "global.d.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] + "exclude": [ + "jest.config.ts", + "src/**/*.spec.ts", + "src/**/*.test.ts", + "node_modules/**/*" + ] }