Skip to content

Commit 3b8fa50

Browse files
authored
Merge branch 'main' into knutkj/traceur-readme-link/1
2 parents cfd3ccf + 2e88855 commit 3b8fa50

37 files changed

+5978
-2733
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ "main", "release-*" ]
6+
pull_request:
7+
branches: [ "main", "release-*" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [10.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Build
26+
run: |
27+
npm install
28+
gulp

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
.vscode/
22
node_modules/
33
test/**/*.js
4-
test/**/*.js.map
4+
test/**/*.js.map
5+
index.d.mts
6+
no-conflict.d.mts
7+
*.js
8+
*.js.map
9+
*.mjs
10+
*.mjs.map

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
.vscode
22
node_modules
33
out
4+
docs
45
spec
56
temp
67
test
78
typings
89
bower.json
910
gulpfile.js
11+
globals.d.ts
1012
Reflect.ts
1113
Reflect.js.map
14+
ReflectLite.ts
15+
ReflectLite.js.map
16+
ReflectNoConflict.ts
17+
ReflectNoConflict.js.map
1218
spec.html
1319
tsconfig.json
1420
tsconfig-release.json

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Metadata Reflection API
22

3+
NOTE: Now that both [Decorators](https://github.com/tc39/proposal-decorators) and
4+
[Decorator Metadata](https://github.com/tc39/proposal-decorator-metadata) have achieved Stage 3 within TC39, the API
5+
proposed below is no longer being considered for standardization. However, this package will continue to support
6+
projects that leverage TypeScript's legacy `--experimentalDecorators` option as some projects may not be able to migrate
7+
to use standard decorators.
8+
39
* [Detailed proposal][metadata-spec]
410

511
## Installation
@@ -8,6 +14,53 @@
814
npm install reflect-metadata
915
```
1016

17+
## Usage
18+
19+
### ES Modules in NodeJS/Browser, TypeScript/Babel, Bundlers
20+
```ts
21+
// - Modifies global `Reflect` object (or defines one in ES5 runtimes).
22+
// - Supports ESM and CommonJS.
23+
// - Contains internal polyfills for `Map`, `Set`, and `WeakMap` for older runtimes.
24+
import "reflect-metadata";
25+
26+
// - Modifies global `Reflect` object (or defines one in ES5 runtimes).
27+
// - Supports ESM and CommonJS.
28+
// - Requires runtime support for `"exports"` in `package.json`.
29+
// - Does not include internal polyfills.
30+
import "reflect-metadata/lite";
31+
```
32+
33+
### CommonJS
34+
```ts
35+
// - Modifies global `Reflect` object (or defines one in ES5 runtimes).
36+
// - Contains internal polyfills for `Map`, `Set`, and `WeakMap` for older runtimes.
37+
require("reflect-metadata");
38+
39+
// - Modifies global `Reflect` object (or defines one in ES5 runtimes).
40+
// - Requires runtime support for `"exports"` in `package.json`.
41+
// - Does not include internal polyfills.
42+
require("reflect-metadata/lite");
43+
```
44+
45+
### In the Browser via `<script>`
46+
**HTML**
47+
```html
48+
<!-- Modifies global `Reflect` object (or defines one in ES5 runtimes). -->
49+
<!-- Contains internal polyfills for `Map`, `Set`, and `WeakMap` for older runtimes. -->
50+
<script src="path/to/reflect-metadata/Reflect.js"></script>
51+
52+
<!-- Modifies global `Reflect` object (or defines one in ES5 runtimes). -->
53+
<!-- Does not include internal polyfills. -->
54+
<script src="path/to/reflect-metadata/ReflectLite.js"></script>
55+
```
56+
57+
**Script**
58+
```js
59+
// - Makes types available in your editor.
60+
/// <reference path="path/to/reflect-metadata/standalone.d.ts" />
61+
62+
```
63+
1164
## Background
1265

1366
* Decorators add the ability to augment a class and its members as the class is defined, through a declarative syntax.

0 commit comments

Comments
 (0)