From f315586f0295250149adcdf7e8c785234bb2e211 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 2 Jun 2026 22:34:17 +0800 Subject: [PATCH 1/3] fix: hack for rspack module federation due to `dayjs -> dayjs/esm` alias --- package.json | 2 -- scripts/build.js | 18 ++++++++++---- scripts/copy-resources.js | 49 --------------------------------------- 3 files changed, 14 insertions(+), 55 deletions(-) delete mode 100644 scripts/copy-resources.js diff --git a/package.json b/package.json index 6cd256c9f..3292dd586 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,6 @@ ], "scripts": { "build": "node scripts/build.js", - "build:copy": "node scripts/copy-resources", - "build:lib": "ng-packagr -c tsconfig.lib.json", "build:watch": "node scripts/build.js --watch", "debug": "node scripts/build.js --debug --watch", "dev": "yarn start", diff --git a/scripts/build.js b/scripts/build.js index 94d93fa9a..72b4beea0 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -14,7 +14,7 @@ const debugNgPackage = '../ng-package.debug.json'; const releaseDest = isDebug ? require(debugNgPackage).dest : 'release'; -function copyResources() { +function afterBuild() { const themeDest = path.resolve(releaseDest, 'theme'); // 复制 SCSS 源文件 @@ -55,6 +55,17 @@ function copyResources() { console.error('Sass compilation error:', error); process.exit(1); } + + // hack for rspack module federation due to `dayjs -> dayjs/esm` alias + const esmEntry = path.resolve(releaseDest, 'fesm2022/alauda-ui.mjs'); + const esmEntryContent = fs.readFileSync(esmEntry, 'utf-8'); + fs.writeFileSync( + esmEntry, + esmEntryContent.replace( + "import dayjs from 'dayjs';", + "import dayjs_ from 'dayjs';\nconst dayjs = 'default' in dayjs_ ? dayjs_.default : dayjs_;", + ), + ); } const packagr = ngPackagr @@ -66,7 +77,7 @@ const packagr = ngPackagr if (watch) { packagr.watch().subscribe(() => { - copyResources(); + afterBuild(); if (!isDebug) { const src = path.resolve(__dirname, '../release'); @@ -76,6 +87,5 @@ if (watch) { } }); } else { - - packagr.build().then(copyResources); + packagr.build().then(afterBuild); } diff --git a/scripts/copy-resources.js b/scripts/copy-resources.js deleted file mode 100644 index a8d6470f8..000000000 --- a/scripts/copy-resources.js +++ /dev/null @@ -1,49 +0,0 @@ -const path = require('node:path'); -const fs = require('node:fs'); -const gulp = require('gulp'); -const sass = require('sass'); - -const isDebug = process.argv[2] === '--debug'; - -const debugNgPackage = '../ng-package.debug.json'; - -const dest = (isDebug ? require(debugNgPackage).dest : 'release') + '/theme'; - -// 复制 SCSS 源文件 -gulp - .src([ - 'src/theme/_base-var.scss', - 'src/theme/_pattern.scss', - 'src/theme/_var.scss', - 'src/theme/_theme-preset.scss', - 'src/theme/_mixin.scss', - ]) - .pipe(gulp.dest(dest)); - -// 复制 Angular CDK overlay CSS 文件 -gulp - .src('node_modules/@angular/cdk/overlay-prebuilt.css') - .pipe(gulp.dest(dest)); - -// 使用现代 sass API 编译 style.scss(移除 CDK 导入) -try { - // 临时创建一个不包含 CDK 导入的版本 - const styleContent = fs.readFileSync('src/theme/style.scss', 'utf8'); - const tempStyleContent = styleContent.replace(/@use 'node_modules\/@angular\/cdk\/overlay-prebuilt';\n?/, ''); - - const result = sass.compileString(tempStyleContent, { - style: 'compressed', - loadPaths: ['src/theme', 'node_modules'] - }); - - // 确保目标目录存在 - if (!fs.existsSync(dest)) { - fs.mkdirSync(dest, { recursive: true }); - } - - // 写入编译后的 CSS - fs.writeFileSync(path.join(dest, 'style.css'), result.css); -} catch (error) { - console.error('Sass compilation error:', error); - process.exit(1); -} From 4a02ab9ac6c0120efb1994ff0f7f2815cccdf7e4 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 2 Jun 2026 22:41:16 +0800 Subject: [PATCH 2/3] Create pink-houses-lose.md --- .changeset/pink-houses-lose.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pink-houses-lose.md diff --git a/.changeset/pink-houses-lose.md b/.changeset/pink-houses-lose.md new file mode 100644 index 000000000..916232178 --- /dev/null +++ b/.changeset/pink-houses-lose.md @@ -0,0 +1,5 @@ +--- +"@alauda/ui": patch +--- + +fix: hack for rspack module federation due to `dayjs -> dayjs/esm` alias From e60c20da3effcf482f9cf9c4ac71e70198c16c52 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 2 Jun 2026 23:01:15 +0800 Subject: [PATCH 3/3] ci: check beta tag availability --- scripts/publish-version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-version.js b/scripts/publish-version.js index c1ed1a1e8..92014865c 100644 --- a/scripts/publish-version.js +++ b/scripts/publish-version.js @@ -11,7 +11,7 @@ if (version.startsWith('v')) { execSync('npm view @alauda/ui dist-tags --json').toString(), ); const { beta, latest } = distTags.data || distTags; - if (semver.gt(beta, latest)) { + if (beta && semver.gt(beta, latest)) { version = beta.endsWith('-beta') ? beta + '.0' : beta.replace(/(-beta\.)(\d+)$/, (_, $0, $1) => $0 + (+$1 + 1));