Skip to content

Commit 2ba44a4

Browse files
alan-agius4dgp1130
authored andcommitted
refactor(@angular-devkit/build-angular): remove support for Stylus
The usage of Stylus in the CLI is minimal and this package never reached version 1. BREAKING CHANGE: Deprecated support for Stylus has been removed. The Stylus package has never reached a stable version and its usage in the Angular CLI is minimal. It's recommended to migrate to another CSS preprocessor that the Angular CLI supports.
1 parent 12931ba commit 2ba44a4

File tree

17 files changed

+18
-143
lines changed

17 files changed

+18
-143
lines changed

docs/design/build-system-overview.dot

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ digraph G {
88
"*.css" -> "postcss-loader with postcss-import, ./postcss-cli-resources.ts, autoprefixer";
99
"*.scss\|sass" -> "sass-loader" -> "postcss-loader with postcss-import, ./postcss-cli-resources.ts, autoprefixer";
1010
"*.less" -> "less-loader" -> "postcss-loader with postcss-import, ./postcss-cli-resources.ts, autoprefixer";
11-
"*.styl" -> "stylus-loader" -> "postcss-loader with postcss-import, ./postcss-cli-resources.ts, autoprefixer";
1211
"postcss-loader with postcss-import, ./postcss-cli-resources.ts, autoprefixer" -> "raw-loader, ./optimize-css-webpack-plugin.ts" [label="component style?"];
1312
"raw-loader" -> "./optimize-css-webpack-plugin.ts"
1413
"postcss-loader with postcss-import, ./postcss-cli-resources.ts, autoprefixer" -> "style-loader, ./raw-css-loader.ts, and mini-css-extract-plugin" [label="global style?"];
1514
"style-loader, ./raw-css-loader.ts, and mini-css-extract-plugin" -> "./optimize-css-webpack-plugin.ts"
16-
}
15+
}

docs/design/build-system.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ This is used for conditional loading of code at build time.
5454
Two types of stylesheets are used in the build system: global stylesheets and component stylesheets.
5555
Global stylesheets are injected into the `index.html` file, while component stylesheets are loaded directly into compiled Angular components.
5656

57-
The build system supports plain CSS stylesheets as well as the Sass, LESS and Stylus CSS pre-processors.
58-
Stylesheet processing functionality is provided by `sass-loader`, `less-loader`, `stylus-loader`, `postcss-loader`, `postcss-import`, augmented in the build system by custom webpack plugins.
57+
The build system supports plain CSS stylesheets as well as the Sass and LESS CSS pre-processors.
58+
Stylesheet processing functionality is provided by `sass-loader`, `less-loader`, `postcss-loader`, `postcss-import`, augmented in the build system by custom webpack plugins.
5959

6060
### Assets
6161

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@
204204
"source-map-loader": "4.0.0",
205205
"source-map-support": "0.5.21",
206206
"spdx-satisfies": "^5.0.0",
207-
"stylus": "0.59.0",
208-
"stylus-loader": "7.0.0",
209207
"symbol-observable": "4.0.0",
210208
"tar": "^6.1.6",
211209
"terser": "5.15.0",

packages/angular_devkit/build_angular/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ ts_library(
170170
"@npm//semver",
171171
"@npm//source-map-loader",
172172
"@npm//source-map-support",
173-
"@npm//stylus",
174-
"@npm//stylus-loader",
175173
"@npm//terser",
176174
"@npm//text-table",
177175
"@npm//tree-kill",

packages/angular_devkit/build_angular/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
"semver": "7.3.7",
5858
"source-map-loader": "4.0.0",
5959
"source-map-support": "0.5.21",
60-
"stylus": "0.59.0",
61-
"stylus-loader": "7.0.0",
6260
"terser": "5.15.0",
6361
"text-table": "0.2.0",
6462
"tree-kill": "1.2.2",

packages/angular_devkit/build_angular/src/builders/browser-esbuild/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"input": {
7373
"type": "string",
7474
"description": "The file to include.",
75-
"pattern": "\\.(?:css|scss|sass|less|styl)$"
75+
"pattern": "\\.(?:css|scss|sass|less)$"
7676
},
7777
"bundleName": {
7878
"type": "string",
@@ -91,7 +91,7 @@
9191
{
9292
"type": "string",
9393
"description": "The file to include.",
94-
"pattern": "\\.(?:css|scss|sass|less|styl)$"
94+
"pattern": "\\.(?:css|scss|sass|less)$"
9595
}
9696
]
9797
}

packages/angular_devkit/build_angular/src/builders/browser/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"input": {
7373
"type": "string",
7474
"description": "The file to include.",
75-
"pattern": "\\.(?:css|scss|sass|less|styl)$"
75+
"pattern": "\\.(?:css|scss|sass|less)$"
7676
},
7777
"bundleName": {
7878
"type": "string",
@@ -91,7 +91,7 @@
9191
{
9292
"type": "string",
9393
"description": "The file to include.",
94-
"pattern": "\\.(?:css|scss|sass|less|styl)$"
94+
"pattern": "\\.(?:css|scss|sass|less)$"
9595
}
9696
]
9797
}

packages/angular_devkit/build_angular/src/builders/browser/specs/styles_spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { dirname } from 'path';
1313
import { browserBuild, createArchitect, host } from '../../../testing/test-utils';
1414

1515
describe('Browser Builder styles', () => {
16-
const extensionsWithImportSupport = ['css', 'scss', 'less', 'styl'];
17-
const extensionsWithVariableSupport = ['scss', 'less', 'styl'];
16+
const extensionsWithImportSupport = ['css', 'scss', 'less'];
17+
const extensionsWithVariableSupport = ['scss', 'less'];
1818
const imgSvg = `
1919
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
2020
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
@@ -223,9 +223,6 @@ describe('Browser Builder styles', () => {
223223
if (ext === 'scss') {
224224
variableAssignment = '$primary-color:';
225225
variablereference = '$primary-color';
226-
} else if (ext === 'styl') {
227-
variableAssignment = '$primary-color =';
228-
variablereference = '$primary-color';
229226
} else if (ext === 'less') {
230227
variableAssignment = '@primary-color:';
231228
variablereference = '@primary-color';

packages/angular_devkit/build_angular/src/builders/browser/tests/options/bundle-budgets_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Type } from '../../schema';
1313
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';
1414

1515
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
16-
const CSS_EXTENSIONS = ['css', 'scss', 'less', 'styl'];
16+
const CSS_EXTENSIONS = ['css', 'scss', 'less'];
1717
const BUDGET_NOT_MET_REGEXP = /Budget .+ was not met by/;
1818

1919
describe('Option: "bundleBudgets"', () => {

packages/angular_devkit/build_angular/src/builders/browser/tests/options/inline-style-language_spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,6 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
5858
harness.expectFile('dist/main.js').content.toContain('color: green');
5959
});
6060

61-
// Stylus currently does not function due to the sourcemap logic within the `stylus-loader`
62-
// which tries to read each stylesheet directly from disk. In this case, each stylesheet is
63-
// virtual and cannot be read from disk. This issue affects data URIs in general.
64-
// xit('supports Stylus inline component styles when set to "stylus"', async () => {
65-
// harness.useTarget('build', {
66-
// ...BASE_OPTIONS,
67-
// inlineStyleLanguage: InlineStyleLanguage.Stylus,
68-
// aot,
69-
// });
70-
71-
// await harness.modifyFile('src/app/app.component.ts', (content) =>
72-
// content.replace(
73-
// '__STYLE_MARKER__',
74-
// '$primary = green;\\nh1 { color: $primary; }',
75-
// ),
76-
// );
77-
78-
// const { result } = await harness.executeOnce();
79-
80-
// expect(result?.success).toBe(true);
81-
// harness.expectFile('dist/main.js').content.toContain('color: green');
82-
// });
83-
8461
it('supports Less inline component styles when set to "less"', async () => {
8562
harness.useTarget('build', {
8663
...BASE_OPTIONS,

packages/angular_devkit/build_angular/src/builders/extract-i18n/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export async function execute(
224224
module: {
225225
rules: [
226226
{
227-
test: /\.(css|scss|sass|styl|less)$/,
227+
test: /\.(css|scss|sass|less)$/,
228228
loader: require.resolve('./empty-loader'),
229229
},
230230
],

packages/angular_devkit/build_angular/src/builders/karma/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"input": {
7777
"type": "string",
7878
"description": "The file to include.",
79-
"pattern": "\\.(?:css|scss|sass|less|styl)$"
79+
"pattern": "\\.(?:css|scss|sass|less)$"
8080
},
8181
"bundleName": {
8282
"type": "string",
@@ -95,7 +95,7 @@
9595
{
9696
"type": "string",
9797
"description": "The file to include.",
98-
"pattern": "\\.(?:css|scss|sass|less|styl)$"
98+
"pattern": "\\.(?:css|scss|sass|less)$"
9999
}
100100
]
101101
}

packages/angular_devkit/build_angular/src/webpack/configs/styles.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
101101
extraPlugins.push(new RemoveHashPlugin({ chunkNames: noInjectNames, hashFormat }));
102102
}
103103

104-
if (globalStylePaths.some((p) => p.endsWith('.styl'))) {
105-
wco.logger.warn(
106-
'Stylus usage is deprecated and will be removed in a future major version. ' +
107-
'To opt-out of the deprecated behaviour, please migrate to another stylesheet language.',
108-
);
109-
}
110-
111104
const sassImplementation = new SassWorkerImplementation();
112105
const sassTildeUsageMessage = new Set<string>();
113106

@@ -366,22 +359,6 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
366359
},
367360
],
368361
},
369-
{
370-
extensions: ['styl'],
371-
use: [
372-
{
373-
loader: require.resolve('stylus-loader'),
374-
options: {
375-
sourceMap: cssSourceMap,
376-
stylusOptions: {
377-
compress: false,
378-
sourceMap: { comment: false },
379-
paths: includePaths,
380-
},
381-
},
382-
},
383-
],
384-
},
385362
];
386363

387364
return {

packages/angular_devkit/build_angular/src/webpack/plugins/any-component-style-budget-checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class AnyComponentStyleBudgetChecker {
4747
return;
4848
}
4949

50-
const cssExtensions = ['.css', '.scss', '.less', '.styl', '.sass'];
50+
const cssExtensions = ['.css', '.scss', '.less', '.sass'];
5151

5252
const componentStyles = Object.keys(compilation.assets)
5353
.filter((name) => cssExtensions.includes(path.extname(name)))

packages/angular_devkit/build_angular/src/webpack/plugins/css-optimizer-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class CssOptimizerPlugin {
5252

5353
logger.time('optimize css assets');
5454
for (const assetName of Object.keys(compilationAssets)) {
55-
if (!/\.(?:css|scss|sass|less|styl)$/.test(assetName)) {
55+
if (!/\.(?:css|scss|sass|less)$/.test(assetName)) {
5656
continue;
5757
}
5858

tests/legacy-cli/e2e/tests/build/styles/include-paths.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ export default async function () {
1818
@import 'variables';
1919
h2 { background-color: $primary-color; }
2020
`,
21-
'src/style-paths/variables.styl': '$primary-color = green',
22-
'src/styles.styl': `
23-
@import 'variables'
24-
h3
25-
color: $primary-color
26-
`,
27-
'src/app/app.component.styl': `
28-
@import 'variables'
29-
h4
30-
background-color: $primary-color
31-
`,
3221
'src/style-paths/variables.less': '@primary-color: #ADDADD;',
3322
'src/styles.less': `
3423
@import 'variables';
@@ -43,17 +32,14 @@ export default async function () {
4332
await replaceInFile(
4433
'src/app/app.component.ts',
4534
`'./app.component.css\'`,
46-
`'./app.component.scss'` + (esbuild ? '' : `, './app.component.styl', './app.component.less'`),
35+
`'./app.component.scss'` + (esbuild ? '' : `, './app.component.less'`),
4736
);
4837

4938
await updateJsonFile('angular.json', (workspaceJson) => {
5039
const appArchitect = workspaceJson.projects['test-project'].architect;
5140
appArchitect.build.options.styles = [{ input: 'src/styles.scss' }];
5241
if (!esbuild) {
53-
appArchitect.build.options.styles.push(
54-
{ input: 'src/styles.styl' },
55-
{ input: 'src/styles.less' },
56-
);
42+
appArchitect.build.options.styles.push({ input: 'src/styles.less' });
5743
}
5844
appArchitect.build.options.stylePreprocessorOptions = {
5945
includePaths: ['src/style-paths'],
@@ -64,9 +50,7 @@ export default async function () {
6450
await expectFileToMatch('dist/test-project/styles.css', /h1\s*{\s*color: red;\s*}/);
6551
await expectFileToMatch('dist/test-project/main.js', /h2.*{.*color: red;.*}/);
6652
if (!esbuild) {
67-
// These checks are for the less and stylus files
68-
await expectFileToMatch('dist/test-project/styles.css', /h3\s*{\s*color: #008000;\s*}/);
69-
await expectFileToMatch('dist/test-project/main.js', /h4.*{.*color: #008000;.*}/);
53+
// These checks are for the less files
7054
await expectFileToMatch('dist/test-project/styles.css', /h5\s*{\s*color: #ADDADD;\s*}/);
7155
await expectFileToMatch('dist/test-project/main.js', /h6.*{.*color: #ADDADD;.*}/);
7256
}
@@ -77,8 +61,6 @@ export default async function () {
7761

7862
await expectFileToMatch('dist/test-project/styles.css', /h1\s*{\s*color: red;\s*}/);
7963
await expectFileToMatch('dist/test-project/main.js', /h2.*{.*color: red;.*}/);
80-
await expectFileToMatch('dist/test-project/styles.css', /h3\s*{\s*color: #008000;\s*}/);
81-
await expectFileToMatch('dist/test-project/main.js', /h4.*{.*color: #008000;.*}/);
8264
await expectFileToMatch('dist/test-project/styles.css', /h5\s*{\s*color: #ADDADD;\s*}/);
8365
await expectFileToMatch('dist/test-project/main.js', /h6.*{.*color: #ADDADD;.*}/);
8466
}

tests/legacy-cli/e2e/tests/build/styles/stylus.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)