
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
@common-web/esbuild
Advanced tools
Using esbuild
to transpile typescript scripts.
Why not use esbuild
directly ?
You can use it directly but for typescript projects you’d need additional setup like
handling resolution of external node_modules
and other options like format
, target
, platform
.
This might be for you if:
cjs
es2015
syntaxThis package comes with all the configuration on esbuild out of the box to get up and running without going through the docs and figuring out what options are needed.
Typical uses:
typescript
you need to transpile to cjs
typescript
you need to transpile to cjs
Requires node >= 12.x
due to yargs
.
Install the pkg:
yarn:
yarn add @common-web/esbuild -D
npm:
npm install @common-web/esbuild --save-dev
// simple build
npx esbuild-ts
// Change path
npx esbuild-ts --entryPoint=./path-to-my-entry --outfile=./path-to-my-outfile
For more options see below Configuration Options
Creating build.js file:
// build.js
const config = require('@common-web/esbuild');
const esbuild = require('esbuild');
const path = require('path');
// Simple
esbuild.build(config.getBaseConfig())
.then(() => {
console.log('Build finished');
});
// Advanced (optional)
esbuild.build(
config.getBaseConfig({
entryPoint: './my-custom-entry-file',
outfile: './my-custom-out-file',
plugins: [myCustomPlugin()],
// By default it imports tsconfig from your root directory
tsconfig: './path-to-my-ts-config',
rootDir: path.join(process.cwd(), '../../'),
target: 'esnext'
})
).then(() => {
console.log('Build finished');
});
Add scripts to package.json:
{
...,
"scripts": {
"build": "node ./build.js"
}
}
Run the build:
yarn build
name | description | defaults | cli configurable | data type |
---|---|---|---|---|
rootDir | working or root directory | current working directory | y | string |
entryPoint | entry path for the build (relative to rootDir) | ./src/index.ts | y | string |
outfile | output path for the build (relative to rootDir) | ./dist/index.js | y | string |
format | format of the build output | 'cjs' | y | string |
platform | platform for the build output | node | y | string |
target | target for the build output | 'es2015' | y | string or string[] |
plugins | additional esbuild plugins | [] | n | array |
tsconfig | path to tsconfig | ./tsconfig.json | y | string |
override | additional override options on esbuild | {} | n | object |
bundle | bundle the files | false | y | bolean |
external | external files to exclude from final bundle | [] | y | string[] |
More options:
esbuild
)
Please review the esbuild documentation for more options and information.
FAQs
Using `esbuild` to transpile typescript scripts.
The npm package @common-web/esbuild receives a total of 25 weekly downloads. As such, @common-web/esbuild popularity was classified as not popular.
We found that @common-web/esbuild demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.