Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pink-houses-lose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": patch
---

fix: hack for rspack module federation due to `dayjs -> dayjs/esm` alias
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 14 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 源文件
Expand Down Expand Up @@ -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_;",
),
);
Comment thread
JounQin marked this conversation as resolved.
}

const packagr = ngPackagr
Expand All @@ -66,7 +77,7 @@ const packagr = ngPackagr

if (watch) {
packagr.watch().subscribe(() => {
copyResources();
afterBuild();

if (!isDebug) {
const src = path.resolve(__dirname, '../release');
Expand All @@ -76,6 +87,5 @@ if (watch) {
}
});
} else {

packagr.build().then(copyResources);
packagr.build().then(afterBuild);
}
49 changes: 0 additions & 49 deletions scripts/copy-resources.js

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/publish-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading