ts-closure-transform
v0.2.0
Published
Rewrites functions to include a '__closure' property, suitable for function serialization.
Downloads
5,609
Maintainers
Readme
ts-closure-transform
This package defines TypeScript code transformations that enable the serialize-closures
package to serialize functions.
These transformations will rewrite all function definitions to include a special __closure
property. The serializer uses that __closure
property to figure out which variables are captured by the function.
How you inject this transform depends on the webpack loader you're using. For ts-loader
you apply the following:
import { beforeTransform, afterTransform } from 'ts-closure-transform';
// ...
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [beforeTransform()],
after: [afterTransform()]
})
}
// ...
Note that ts-closure-transform
is strictly a dev dependency: there's no need to package it with your application.