Skip to content

Commit e50a9c1

Browse files
Add bundle minification practices to copilot instructions (#7963)
- Add bundle minification practices to copilot instructions
1 parent f054cf6 commit e50a9c1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/copilot-instructions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@ This repository contains JavaScript/TypeScript SDKs for integrating with Microso
1212
- Update apiExtractor reports by running `npm run apiExtractor -- --local` from the directory of each changed package.
1313
- Create changefiles by running `npm run beachball:change` from the root of the repo. Include PR number in changelog message.
1414

15+
### Bundle minification practices
16+
17+
To facilitate bundle size minification and tree-shaking, follow these practices when writing code:
18+
19+
- Prefer simple constants over nested ones
20+
<details>
21+
<summary>Example</summary>
22+
23+
```ts
24+
// Prefer this (simple constant):
25+
const STATUS_SUCCESS = "success";
26+
27+
// Over this (nested constant):
28+
const STATUS = {
29+
SUCCESS: "success",
30+
ERROR: "error"
31+
};
32+
```
33+
</details>
34+
- Prefer `const` objects with `as const` or literal types over TypeScript enums
35+
- Prefer standalone functions over classes when possible. If using classes, keep attribute and method names short
36+
- Use `const` for immutable data
37+
- Avoid complex type computations (e.g., deeply nested conditional types, recursive mapped types, or types that require multiple layers of inference). Prefer simple, readable type definitions. When possible, use interfaces or type aliases with straightforward structures, and avoid advanced TypeScript features unless absolutely necessary.
38+
1539
## Repository Structure
1640

1741
- `lib/`: Contains the source code for the MSAL SDKs

0 commit comments

Comments
 (0)