Skip to content

fix(theme): replace cross-package relative style imports with package… - #2039

Merged
cipchk merged 2 commits into
masterfrom
fix-sf-2631-pnpm-style-imports
Jun 16, 2026
Merged

fix(theme): replace cross-package relative style imports with package…#2039
cipchk merged 2 commits into
masterfrom
fix-sf-2631-pnpm-style-imports

Conversation

@cipchk

@cipchk cipchk commented Jun 16, 2026

Copy link
Copy Markdown
Member

…-name imports

Change all relative path imports (../abc/, ../chart/, ../../../form/) to package-name imports (@delon/abc/, @delon/form/) to fix pnpm strict module resolution.

  • Remove @import '../chart/index.less' from default.less/variable.less (chart is not a declared dependency of theme)
  • Add @import './theme-default.less' to abc/index.less for self-contained styles
  • Add dist/ to generate-css.js paths to resolve package-name imports during build
  • All 8 theme CSS files compile successfully with zero errors

Close ng-alain/ng-alain#2631

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

Preview is ready!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates relative Less imports to package-name imports (e.g., using @delon/abc) across various theme files and adds the dist directory to the Less compiler paths in the build script. However, importing theme-default.less directly inside packages/abc/index.less breaks multi-theme support and should be avoided. Additionally, in the build script, the dist/ directory path should be ordered before node_modules/ to ensure that Less resolves package imports from the newly built files rather than stale node_modules.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/abc/index.less
@@ -1,3 +1,4 @@
@import './theme-default.less';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Importing ./theme-default.less directly inside packages/abc/index.less breaks multi-theme support (such as dark, compact, and variable themes). When other themes (e.g., theme-dark.less or theme-variable.less) import @delon/abc/index.less, they will inadvertently pull in the default theme styles and variables, leading to style conflicts, overrides, and duplicate CSS rules. Component styles should remain theme-agnostic and rely on the global theme variables being present during compilation, rather than hardcoding a specific theme import.

Comment thread scripts/build/generate-css.js
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.14%. Comparing base (569e8ac) to head (2901380).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2039    +/-   ##
========================================
  Coverage   95.14%   95.14%            
========================================
  Files         270      270            
  Lines        8776     8776            
  Branches     1811     1706   -105     
========================================
  Hits         8350     8350            
  Misses        338      338            
  Partials       88       88            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…-name imports

Change all relative path imports (`../abc/`, `../chart/`, `../../../form/`)
to package-name imports (`@delon/abc/`, `@delon/form/`) to fix pnpm strict
module resolution.

- Remove `@import '../chart/index.less'` from default.less/variable.less
  (chart is not a declared dependency of theme)
- Add `@import './theme-default.less'` to abc/index.less for self-contained styles
- Add `dist/` to generate-css.js paths (ordered before node_modules/) to
  resolve package-name imports during build
- All 8 theme CSS files compile successfully with zero errors

Close ng-alain/ng-alain#2631

Co-Authored-By: Claude <noreply@anthropic.com>
@cipchk
cipchk force-pushed the fix-sf-2631-pnpm-style-imports branch from 1877fcd to 316da32 Compare June 16, 2026 03:26
After changing theme style imports from relative paths to package-name
imports (@delon/abc/), the site:gen command failed because
ng-alain-plugin-theme couldn't resolve @delon/abc/theme-variable.less
from node_modules/ in the monorepo.

Added 'ln -sf ../dist/@delon node_modules/@delon' to the site:gen
script, creating a symlink that lets Less resolve @delon/abc/ imports
through the standard node_modules/ search path. The dist/@delon/
directory is always built before site:gen in CI via build-delon.sh.

Close ng-alain/ng-alain#2631

Co-Authored-By: Claude <noreply@anthropic.com>
@cipchk
cipchk merged commit 3e599e1 into master Jun 16, 2026
8 checks passed
@cipchk
cipchk deleted the fix-sf-2631-pnpm-style-imports branch June 16, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

当使用pnpm,又引用了@delen的样式时,会导致编译出错。

1 participant