autobind-decorator
Advanced tools
Comparing version 2.3.1 to 2.4.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="2.4.0"></a> | ||
# [2.4.0](https://github.com/andreypopp/autobind-decorator/compare/v2.3.1...v2.4.0) (2018-11-30) | ||
### Features | ||
* **pgk:** use es for modern js, change module field for es5 + esmodule ([771f71b](https://github.com/andreypopp/autobind-decorator/commit/771f71b)) | ||
<a name="2.3.1"></a> | ||
@@ -7,0 +17,0 @@ ## [2.3.1](https://github.com/andreypopp/autobind-decorator/compare/v2.3.0...v2.3.1) (2018-11-17) |
{ | ||
"name": "autobind-decorator", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "Decorator for binding method to an object", | ||
"main": "lib/index.js", | ||
"module": "src/index.js", | ||
"main": "lib/cjs/index.js", | ||
"module": "lib/esm/index.js", | ||
"es": "src/index.js", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"clean": "rm -rf lib", | ||
"build": "babel src --out-dir lib --ignore \"src/__tests__/*.js\"", | ||
"build:es5": "babel src --out-dir lib/cjs --ignore \"src/__tests__/*.js\"", | ||
"build:module": "babel --no-babelrc --config-file ./src/.babelrc.es.js src --out-dir lib/esm --ignore \"src/__tests__/*.js\"", | ||
"build": "npm run build:es5 && npm run build:module", | ||
"prepare": " npm run clean && npm run build", | ||
"lint": "xo", | ||
"test": "npm run lint && jest --coverage", | ||
"test": "jest --coverage", | ||
"release": "standard-version", | ||
"prepublish": "npm run clean && npm run build && npm test" | ||
"prepublishOnly": "npm run lint && npm test" | ||
}, | ||
@@ -32,12 +36,6 @@ "author": "Andrey Popp <8mayday@gmail.com>", | ||
"xo": { | ||
"parser": "babel-eslint", | ||
"globals": [ | ||
"describe", | ||
"test", | ||
"beforeEach", | ||
"afterEach" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": "src/__tests__/*.js", | ||
"parser": "babel-eslint", | ||
"rules": { | ||
@@ -48,3 +46,9 @@ "no-global-assign": "off", | ||
"func-name-matching": "off" | ||
} | ||
}, | ||
"globals": [ | ||
"describe", | ||
"test", | ||
"beforeEach", | ||
"afterEach" | ||
] | ||
} | ||
@@ -51,0 +55,0 @@ ] |
@@ -17,3 +17,3 @@ # autobind decorator | ||
## Installation: | ||
## Installation | ||
@@ -24,3 +24,3 @@ ``` | ||
### Supported platforms: | ||
### Supported platforms | ||
@@ -31,6 +31,10 @@ #### Output | ||
`main` entry is in ES5 | ||
`main`: ES5 | ||
`module` entry is in ES6+ (notably ES modules to enable tree shaking) | ||
`module`: ES5 + ES modules to enable tree shaking | ||
`es`: modern JS | ||
On consuming modern JS, you can transpile the script to your target environment ([@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env) is recommended) to minimise the cost. For more details, please read https://babeljs.io/blog/2018/06/26/on-consuming-and-publishing-es2015+-packages. | ||
#### Dev | ||
@@ -40,22 +44,12 @@ | ||
### Note uglify users: | ||
## Babel 6 users (legacy only) | ||
Starting from v2.2, we added `module` entry in package.json and kept `main` entry as is. `module` entry is for those who wish to use modern JavaScript (notably ES modules to enable tree shaking). If your environment doesn't understand the modern syntax, you can configure your tool to read the ES5 script via the `main` entry. EG: with webpack, you could do | ||
The implementation of the decorator transform is currently on hold as the syntax is not final. If you would like to use this project with Babel 6, you may use [babel-plugin-transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) which implement Babel 5 decorator transform for Babel 6. | ||
```js | ||
resolve: { | ||
mainFields: ['main'] | ||
} | ||
``` | ||
## Babel 7 users | ||
You could also transpile the script to your target environment ([@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env) is recommended). For more details, please read https://babeljs.io/blog/2018/06/26/on-consuming-and-publishing-es2015+-packages. | ||
### Legacy | ||
### Note Babel 6 users: | ||
Babel 7's [`@babel/plugin-proposal-decorators`](https://babeljs.io/docs/en/babel-plugin-proposal-decorators) officially supports the same logic that babel-plugin-transform-decorators-legacy has, but integrates better with Babel 7's other plugins. You can enable this with | ||
The implementation of the decorator transform is currently on hold as the syntax is not final. If you would like to use this project with Babel 6, you may use [babel-plugin-transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) which implement Babel 5 decorator transform for Babel 6. | ||
### Note Babel 7 users: | ||
Babel 7's `@babel/plugin-proposal-decorators` officially supports the same logic that babel-plugin-transform-decorators-legacy has, but integrates better with Babel 7's other plugins. You can enable this with | ||
```json | ||
@@ -72,12 +66,18 @@ { | ||
are newer versions of the decorator specification coming out, and they do not | ||
behave the same way. We are trying to keep this module up-to-date with the latest spec. | ||
behave the same way. | ||
### Note TypeScript users: | ||
### Modern | ||
For now, you'll have to use one of the solutions in https://github.com/nicolo-ribaudo/legacy-decorators-migration-utility. We are trying to keep this module up-to-date with the latest spec. For more details, please read https://babeljs.io/blog/2018/09/17/decorators. | ||
## TypeScript users | ||
This package will work out of the box with TypeScript (no Babel needed) and includes the `.d.ts` typings along with it. | ||
## Examples: | ||
## Examples | ||
### Recommended way to bind a method: | ||
### Recommended way to bind a method | ||
Use `@boundMethod` on a method | ||
```js | ||
@@ -104,3 +104,3 @@ import {boundMethod} from 'autobind-decorator' | ||
### Legacy approaches: | ||
### Discouraged approaches | ||
@@ -128,3 +128,3 @@ Magical `@autobind` that can be used on both classes and methods | ||
// Also usable on the class to bind all methods | ||
// Please see performance if you decide to autobind your class | ||
// Please see performance section below if you decide to autobind your class | ||
@autobind | ||
@@ -134,4 +134,6 @@ class Component { } | ||
Please see performance if you decide to autobind your class: | ||
Use `@boundClass` on a class | ||
Please see performance section below if you decide to autobind your class | ||
```js | ||
@@ -179,2 +181,2 @@ import {boundClass} from 'autobind-decorator' | ||
You might want to look at [Class instance properties](https://tc39.github.io/proposal-class-public-fields/). | ||
- [Class field declarations](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties) - This is also not standard JavaScript yet (Stage 3). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24666
13
510
174
0