Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(@angular/build): move less stylesheet preprocessor to an optional peer dependency #27524

Merged
merged 1 commit into from
Apr 24, 2024
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: 4 additions & 1 deletion packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"fast-glob": "3.3.2",
"https-proxy-agent": "7.0.4",
"inquirer": "9.2.19",
"less": "4.2.0",
"magic-string": "0.30.10",
"mrmime": "2.0.0",
"ora": "5.4.1",
Expand All @@ -48,6 +47,7 @@
"@angular/localize": "^18.0.0 || ^18.0.0-next.0",
"@angular/platform-server": "^18.0.0 || ^18.0.0-next.0",
"@angular/service-worker": "^18.0.0 || ^18.0.0-next.0",
"less": "^4.2.0",
"tailwindcss": "^2.0.0 || ^3.0.0",
"typescript": ">=5.4 <5.5"
},
Expand All @@ -61,6 +61,9 @@
"@angular/service-worker": {
"optional": true
},
"less": {
"optional": true
},
"tailwindcss": {
"optional": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,26 @@ async function compileString(
resolver: PluginBuild['resolve'],
unsafeInlineJavaScript: boolean,
): Promise<OnLoadResult> {
const less = (lessPreprocessor ??= (await import('less')).default);
try {
lessPreprocessor ??= (await import('less')).default;
} catch {
return {
errors: [
{
text: 'Unable to load the "less" stylesheet preprocessor.',
location: null,
notes: [
{
text:
'Ensure that the "less" Node.js package is installed within the project. ' +
"If not present, installation via the project's package manager should resolve the error.",
},
],
},
],
};
}
const less = lessPreprocessor;

const resolverPlugin: Less.Plugin = {
install({ FileManager }, pluginManager): void {
Expand Down