Skip to content

Commit 430dc7e

Browse files
authoredSep 29, 2023
Website perf improvements (microsoft#2507)
Progress in microsoft#2480 ## `Swc-loader` Some minor perf improviement. Using `swc-loader` is much faster at loading the js in the compile stage. This make the timed build nearly 50% faster but it **still gets stuck at** `cache (99%) shutdown IdleFileCachePlugin` for the vast majority of the time. So this is a little win but nearly negligable ## Updateing `typedoc-markdown` This has changed the file structure to group by folder and has basically brought back the perf from before the migration to the new doc format. Not sure why but it works great now.
1 parent ec1da33 commit 430dc7e

File tree

8 files changed

+1866
-2385
lines changed

8 files changed

+1866
-2385
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@typespec/compiler",
5+
"comment": "Remove `decorators` export, import decorators individually",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@typespec/compiler"
10+
}

‎common/config/rush/pnpm-lock.yaml

+1,821-2,371
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/extending-typespec/emitter-metadata-handling.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ However, if your emitter does want to split types as OpenAPI does, then it will
2323

2424
These are the main API involved in handling these features. See the linked API reference documentation for more details.
2525

26-
- [`getRequestVisibility(HttpVerb): Visibility`](../standard-library/http/reference/js-api/index.md#getrequestvisibility) - Use this to determine the visibility implied for data in the request parameters or body. Also note that [`Visibility.Read`](../standard-library/http/reference/js-api/Enumeration.Visibility.md#item) is always applied for response data and therefore there is no corresponding API for the response.
26+
- [`getRequestVisibility(HttpVerb): Visibility`](../standard-library/http/reference/js-api/index.md#getrequestvisibility) - Use this to determine the visibility implied for data in the request parameters or body. Also note that [`Visibility.Read`](../standard-library/http/reference/js-api/enumerations/Visibility.md#item) is always applied for response data and therefore there is no corresponding API for the response.
2727

28-
- [`MetadataInfo`](../standard-library/http/reference/js-api/Interface.MetadataInfo.md) - Create this once for each program using [`createMetadataInfo(Program, MetadataInfoOptions)`](../standard-library/http/reference/js-api/index.md#createmetadatainfo) then use it to reason about metadata and visibility implications with the API below.
28+
- [`MetadataInfo`](../standard-library/http/reference/js-api/interfaces/MetadataInfo.md) - Create this once for each program using [`createMetadataInfo(Program, MetadataInfoOptions)`](../standard-library/http/reference/js-api/index.md#createmetadatainfo) then use it to reason about metadata and visibility implications with the API below.
2929

30-
- [`MetadataInfo.getEffectivePayloadType(Type, Visibility): Type`](../standard-library/http/reference/js-api/Interface.MetadataInfo.md#geteffectivepayloadtype) - Use this recursively on every type that is referenced. When given an anonymous model sourced entirely from a single named model after metadata is moved elsewhere or invisible properties are removed, it will recover the named model. This handles the commonly discussed case of seeing that `op something(...Thing)` receives a `Thing` in its request body, but also many other cases..
30+
- [`MetadataInfo.getEffectivePayloadType(Type, Visibility): Type`](../standard-library/http/reference/js-api/interfaces/MetadataInfo.md#geteffectivepayloadtype) - Use this recursively on every type that is referenced. When given an anonymous model sourced entirely from a single named model after metadata is moved elsewhere or invisible properties are removed, it will recover the named model. This handles the commonly discussed case of seeing that `op something(...Thing)` receives a `Thing` in its request body, but also many other cases..
3131

32-
- [`MetadataInfo.isTransformed(Model, Visibility)`](../standard-library/http/reference/js-api/Interface.MetadataInfo.md#istransformed) - Use this to check if a type undergoes any changes in shape due to visibility or metadata. If not, this can allow for simplifications in emit.
32+
- [`MetadataInfo.isTransformed(Model, Visibility)`](../standard-library/http/reference/js-api/interfaces/MetadataInfo.md#istransformed) - Use this to check if a type undergoes any changes in shape due to visibility or metadata. If not, this can allow for simplifications in emit.
3333

34-
- [`MetadataInfo.isPayloadProperty(ModelProperty, Visibility): boolean`](../standard-library/http/reference/js-api/Interface.MetadataInfo.md#ispayloadproperty) - Use this to check if a property is transmitted as an object property in the payload and is not invisible or metadata sent elsewhere.
34+
- [`MetadataInfo.isPayloadProperty(ModelProperty, Visibility): boolean`](../standard-library/http/reference/js-api/interfaces/MetadataInfo.md#ispayloadproperty) - Use this to check if a property is transmitted as an object property in the payload and is not invisible or metadata sent elsewhere.
3535

36-
- [`MetadataInfo.isOptional(ModelProperty, Visibility): boolean`](../standard-library/http/reference/js-api/Interface.MetadataInfo.md#isoptional) - Use this to determine if a property is optional for the given visibility. This will differ from `ModelProperty.isOptional` when the Visibility is Update in which case the property is always considered optional.
36+
- [`MetadataInfo.isOptional(ModelProperty, Visibility): boolean`](../standard-library/http/reference/js-api/interfaces/MetadataInfo.md#isoptional) - Use this to determine if a property is optional for the given visibility. This will differ from `ModelProperty.isOptional` when the Visibility is Update in which case the property is always considered optional.
3737

38-
- [`Visibility.Item`](../standard-library/http/reference/js-api/Enumeration.Visibility#item) - Add this flag when recursing into an array. This moves all metadata into the payload, which can be useful in scenarios like batching API calls.
38+
- [`Visibility.Item`](../standard-library/http/reference/js-api/enumerations/Visibility.md#item) - Add this flag when recursing into an array. This moves all metadata into the payload, which can be useful in scenarios like batching API calls.

‎packages/compiler/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export { ResolveCompilerOptionsOptions, resolveCompilerOptions } from "./config/index.js";
22
export * from "./core/index.js";
33
export * from "./lib/decorators.js";
4-
export * as decorators from "./lib/decorators.js";
54
export * from "./server/index.js";
65
import * as formatter from "./formatter/index.js";
76
export const TypeSpecPrettierPlugin = formatter;

‎packages/tspd/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"mocha": "~10.2.0",
7474
"source-map-support": "~0.5.21",
7575
"rimraf": "~5.0.1",
76-
"typedoc-plugin-markdown": "~4.0.0-next.20",
76+
"typedoc-plugin-markdown": "~4.0.0-next.22",
7777
"typedoc": "~0.25.1",
7878
"typescript": "~5.2.2"
7979
}

‎packages/tspd/src/ref-doc/api-docs.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ export async function generateJsApiDocs(libraryPath: string, outputDir: string)
77
const markdownPluginOptions: Partial<PluginOptions> = {
88
entryFileName: "index.md",
99
propertiesFormat: "table",
10+
parametersFormat: "table",
1011
enumMembersFormat: "table",
1112
typeDeclarationFormat: "table",
1213
hidePageTitle: true,
1314
hideBreadcrumbs: true,
1415
titleTemplate: "{name}",
1516
hideInPageTOC: true,
1617
hidePageHeader: true,
17-
18-
tocFormat: "list",
19-
flattenOutputFiles: true,
20-
identifiersAsCodeBlocks: true,
18+
useCodeBlocks: true,
2119
};
2220

2321
const app = await Application.bootstrapWithPlugins({

‎packages/website/docusaurus.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,28 @@ const config = {
8585
],
8686
staticDirectories: [resolve(__dirname, "./node_modules/@typespec/spec/dist")],
8787

88+
webpack: {
89+
jsLoader: (isServer) => ({
90+
loader: require.resolve("swc-loader"),
91+
options: {
92+
jsc: {
93+
parser: {
94+
syntax: "typescript",
95+
tsx: true,
96+
},
97+
target: "es2019",
98+
transform: {
99+
react: {
100+
runtime: "automatic",
101+
},
102+
},
103+
},
104+
module: {
105+
type: isServer ? "commonjs" : "es6",
106+
},
107+
},
108+
}),
109+
},
88110
themeConfig:
89111
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
90112
({

‎packages/website/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"react-dom": "^17.0.2"
3333
},
3434
"devDependencies": {
35+
"@swc/core": "^1.3.62",
3536
"@typespec/compiler": "workspace:~0.48.1",
3637
"@typespec/tspd": "workspace:~0.46.0",
3738
"@typespec/spec": "workspace:*",
@@ -54,7 +55,8 @@
5455
"@typespec/eslint-config-typespec": "workspace:~0.48.0",
5556
"eslint": "^8.49.0",
5657
"rimraf": "~5.0.1",
57-
"dotenv": "~16.3.1"
58+
"dotenv": "~16.3.1",
59+
"swc-loader": "^0.2.3"
5860
},
5961
"browserslist": {
6062
"production": [

0 commit comments

Comments
 (0)