Skip to content

Commit 6ef3aed

Browse files
authored
Merge pull request #144 from rbuckton/lite-mode
Add /lite and /no-conflict exports
2 parents f16259f + 7391602 commit 6ef3aed

33 files changed

+5667
-2523
lines changed

.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)