Skip to content

Commit ceb6e34

Browse files
committed
build: update to marked v16 and resolve breakages
Updates the repo to the latest version of `marked` and resolves some breaking changes that required us to switch some files to ESM. As a result, I had to disable syntax highlighting for type aliases and constants in the API docs, because it would've required us to rework the dgeni setup as well.
1 parent 1bba607 commit ceb6e34

24 files changed

+169
-212
lines changed

.ng-dev/release.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
19
import semver from 'semver';
210
import {ReleaseConfig} from '@angular/ng-dev';
311
import {assertValidUpdateMigrationCollections} from '../tools/release-checks/check-migration-collections.mjs';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"karma-parallel": "^0.3.1",
123123
"karma-sourcemap-loader": "^0.4.0",
124124
"magic-string": "0.30.17",
125-
"marked": "^15.0.12",
125+
"marked": "^16.0.0",
126126
"minimatch": "^10.0.3",
127127
"parse5": "^7.1.2",
128128
"postcss": "^8.4.17",

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/dgeni/docs-package.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {Package} from 'dgeni';
22
import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTypeScriptModules';
33
import {Host} from 'dgeni-packages/typescript/services/ts-host/host';
44
import {TypeFormatFlags} from 'typescript';
5-
import {HighlightNunjucksExtension} from './nunjucks-tags/highlight';
65
import {patchLogService} from './patch-log-service';
76
import {AsyncFunctionsProcessor} from './processors/async-functions';
87
import {categorizer} from './processors/categorizer';
@@ -165,6 +164,4 @@ apiDocsPackage.config(function (templateFinder: any, templateEngine: any) {
165164
variableStart: '{$',
166165
variableEnd: '$}',
167166
};
168-
169-
templateEngine.tags.push(new HighlightNunjucksExtension());
170167
});

tools/dgeni/nunjucks-tags/highlight.ts

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

tools/dgeni/templates/constant.template.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ <h4 id="{$ constant.name $}" class="docs-header-link docs-api-h4 docs-api-consta
1717

1818
<div class="docs-markdown">
1919
<pre class="docs-markdown-pre">
20-
<code class="docs-markdown-code">
21-
{%- highlight "typescript" -%}
22-
const {$ constant.name | safe $}: {$ constant.type | safe $};
23-
{%- end_highlight -%}
24-
</code>
20+
<code class="docs-markdown-code">const {$ constant.name | safe $}: {$ constant.type | safe $};</code>
2521
</pre>
2622
</div>

tools/dgeni/templates/type-alias.template.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ <h4 id="{$ alias.name $}" class="docs-header-link docs-api-h4 docs-api-type-alia
1717

1818
<div class="docs-markdown">
1919
<pre class="docs-markdown-pre">
20-
<code class="docs-markdown-code">
21-
{%- highlight "typescript" -%}
22-
type {$ alias.name | safe $} = {$ alias.typeDefinition | safe $};
23-
{%- end_highlight -%}
24-
</code>
20+
<code class="docs-markdown-code">type {$ alias.name | safe $} = {$ alias.typeDefinition | safe $};</code>
2521
</pre>
2622
</div>

tools/extract-tokens/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"])
55

66
ts_project(
77
name = "extract_tokens_lib",
8-
srcs = glob(["**/*.ts"]),
8+
srcs = glob(["**/*.mts"]),
99
tsconfig = "//tools:tsconfig",
1010
deps = [
1111
"//:node_modules/sass",
@@ -18,5 +18,5 @@ js_binary(
1818
data = [
1919
":extract_tokens_lib",
2020
],
21-
entry_point = ":extract-tokens.js",
21+
entry_point = ":extract-tokens.mjs",
2222
)

tools/extract-tokens/extract-tokens.ts renamed to tools/extract-tokens/extract-tokens.mts

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {readFileSync, writeFileSync} from 'fs';
22
import {pathToFileURL} from 'url';
33
import {relative, join, dirname} from 'path';
44
import {compileString} from 'sass';
5-
import {highlightCodeBlock} from '../highlight-files/highlight-code-block';
5+
import {highlightCodeBlock} from '../highlight-files/highlight-code-block.mjs';
66

77
/** Information extracted for a single token from the theme. */
88
interface ExtractedToken {
@@ -43,40 +43,39 @@ interface ThemeData {
4343
}
4444

4545
// Script that extracts the tokens from a specific Bazel target.
46-
if (require.main === module) {
47-
const [packagePath, outputPath, ...inputFiles] = process.argv.slice(2);
48-
const themeFiles = inputFiles
49-
// Filter out only the files within the package
50-
// since the path also includes dependencies.
51-
.filter(file => file.startsWith(packagePath))
52-
.map(file => {
53-
// Assumption: all theme files start with an underscore since they're
54-
// partials and they end with `-theme`.
55-
// Assumption: the name under which the theme mixin will be available is the
56-
// same as the file name without the underscore and `-theme.scss`.
57-
const match = file.match(/_(.*)-theme\.scss$/);
58-
return match ? {mixinPrefix: match[1], filePath: file} : null;
59-
})
60-
.filter(file => !!file);
61-
62-
if (themeFiles.length === 0) {
63-
throw new Error(`Could not find theme files in ${packagePath}`);
64-
}
6546

66-
const themes: ThemeData[] = [];
47+
const [packagePath, outputPath, ...inputFiles] = process.argv.slice(2);
48+
const themeFiles = inputFiles
49+
// Filter out only the files within the package
50+
// since the path also includes dependencies.
51+
.filter(file => file.startsWith(packagePath))
52+
.map(file => {
53+
// Assumption: all theme files start with an underscore since they're
54+
// partials and they end with `-theme`.
55+
// Assumption: the name under which the theme mixin will be available is the
56+
// same as the file name without the underscore and `-theme.scss`.
57+
const match = file.match(/_(.*)-theme\.scss$/);
58+
return match ? {mixinPrefix: match[1], filePath: file} : null;
59+
})
60+
.filter(file => !!file);
61+
62+
if (themeFiles.length === 0) {
63+
throw new Error(`Could not find theme files in ${packagePath}`);
64+
}
65+
66+
const themes: ThemeData[] = [];
6767

68-
themeFiles.forEach(theme => {
69-
themes.push({
70-
name: theme.mixinPrefix,
71-
// This can be derived from the `name` already, but we want the source
72-
// of truth to be in this repo, instead of whatever page consumes the data.
73-
overridesMixin: `${theme.mixinPrefix}-overrides`,
74-
tokens: extractTokens(theme.filePath),
75-
});
68+
themeFiles.forEach(theme => {
69+
themes.push({
70+
name: theme.mixinPrefix,
71+
// This can be derived from the `name` already, but we want the source
72+
// of truth to be in this repo, instead of whatever page consumes the data.
73+
overridesMixin: `${theme.mixinPrefix}-overrides`,
74+
tokens: extractTokens(theme.filePath),
7675
});
76+
});
7777

78-
writeFileSync(outputPath, JSON.stringify({example: getUsageExample(themes), themes}));
79-
}
78+
writeFileSync(outputPath, JSON.stringify({example: getUsageExample(themes), themes}));
8079

8180
/**
8281
* Extracts the tokens from a theme file.

tools/highlight-files/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
load("//tools:defaults.bzl", "ts_project")
21
load("@aspect_rules_js//js:defs.bzl", "js_binary")
2+
load("//tools:defaults.bzl", "ts_project")
33

44
package(default_visibility = ["//visibility:public"])
55

66
ts_project(
77
name = "sources",
8-
srcs = glob(["**/*.ts"]),
8+
srcs = glob(["**/*.mts"]),
99
tsconfig = "//tools:tsconfig",
1010
deps = [
1111
"//:node_modules/@types/fs-extra",
@@ -20,5 +20,5 @@ js_binary(
2020
data = [
2121
":sources",
2222
],
23-
entry_point = ":highlight-files.js",
23+
entry_point = ":highlight-files.mjs",
2424
)

0 commit comments

Comments
 (0)