Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@anatine/esbuild-decorators
Advanced tools
Esbuild plugin for Nx to handle emitDecoratorMetadata
This is a plugin for esbuild to handle the tsconfig setting "emitDecoratorMetadata": true,
When the decorator flag is set to true
, the build process will inspect each .ts file and upon a decorator, will transpile with Typescript.
Install esbuild and the plugin
npm install -D esbuild
npm install -D @anatine/esbuild-decorators
Set up a build script
import { build } from 'esbuild';
import { esbuildDecorators } from '@anatine/esbuild-decorators'
async function myBuilder(
tsconfig: string,
entryPoints: string[],
outfile: string,
cwd: string = process.cwd()
) {
const buildResult = await build({
platform: 'node',
target: 'node14',
bundle: true,
sourcemap: 'external',
plugins: [
esbuildDecorators({
tsconfig,
cwd,
}),
],
tsconfig,
entryPoints,
outfile,
external: [
// This is likely to be your friend...
],
});
}
Run your builder.
Option | Description |
---|---|
tsconfig | optional : string : The path and filename of the tsconfig.json |
cwd | optional : string : The current working directory |
force | optional : boolean : Will transpile all .ts files to Javascript with tsc |
tsx | optional : boolean : Enable .tsx file support |
There is no doubt that this will affect the performance of esbuild. When emitDecoratorMetadata is set, every file will have to be loaded into this plugin.
This simple plugin hangs on the regex string: /((?<![(\s]\s*['"])@\w[.[\]\w\d]*\s*(?![;])[((?=\s)])/
Potentially esbuild could eventually do this regex search and expose positives via another plugin hook for transpiling.
Issue here: https://github.com/evanw/esbuild/issues/991
Check out the test files and submit any issues or PRs if you see a pattern that should be covered.
Thanks to Thomas Schaaf as this was his shared code that lead me here. Original Source
Thanks to the npm package strip-comments that was stripped down to cover only typescript comments and string removals
FAQs
Esbuild plugin for Nx to handle emitDecoratorMetadata
The npm package @anatine/esbuild-decorators receives a total of 26,823 weekly downloads. As such, @anatine/esbuild-decorators popularity was classified as popular.
We found that @anatine/esbuild-decorators demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.