
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
rollup-plugin-esbuild-transform
Advanced tools
Use esbuild with Rollup to transform any supported content types.
Use
esbuildwith Rollup to transform any supported content types.
esbuild as a bundler has some problems such as #475 which has still not been fixed since Oct, 2020.
rollup-plugin-esbuild is great but there is no simpler way to use multiple loader with different options, and for some reason it does not provide all available options from esbuild transform API.
npm install -D esbuild rollup-plugin-esbuild-transform
// rollup.config.js
import { join } from 'path'
import esbuild from 'rollup-plugin-esbuild-transform'
export default {
// ...
plugins: [
esbuild([
{
loader: 'json'
},
{
loader: 'tsx',
legalComments: 'eof'
},
{
loader: 'ts',
include: /\.tsx?$/,
tsconfig: join(__dirname, 'tsconfig.json')
},
{
output: true,
minify: true,
target: 'es2015'
}
])
]
}
// index.d.ts
import { TransformOptions as EsbuildTransformOptions } from 'esbuild'
import { FilterPattern } from '@rollup/pluginutils'
import { Plugin } from 'rollup'
export interface TransformOptions extends EsbuildTransformOptions {
tsconfig?: string
}
export interface Options extends TransformOptions {
output?: boolean
include?: FilterPattern
exclude?: FilterPattern
}
declare function esbuildTransform(options?: Options | Options[]): Plugin
export default esbuildTransform
This plugin uses the same options from esbuild transform API.
tsconfig is the path to tsconfig.json file relative to process.cwd(). It will not be used if tsconfigRaw is provided.
output is for indicating whether this transformation should be performed after the chunk (bundle) has been rendered.
include and exclude are picomatch patterns. They can be string | RegExp | Array<string | RegExp>. When supplied they will override the default values.
If output: true, then the options include and exclude will be applied to the chunk's filename from RollupOptions.output.file.
includeDefault to new RegExp(`\\.(?:${loaderExtensions.join('|')})$`) (supports .cjs, .mjs, .cts, .mts), or undefined (match any filename) if output: true.
If a file is matched by more than one pattern (as the example below), the options other than loader will be shallowly merged into and possibly override the previous ones.
// options
[
{
loader: 'tsx',
legalComments: 'eof'
},
{
loader: 'ts',
include: /\.tsx?$/,
tsconfig: join(__dirname, 'tsconfig.json')
}
]
// the final transform options for `index.tsx` will become
{
loader: 'tsx',
legalComments: 'eof',
tsconfig: join(__dirname, 'tsconfig.json')
}
excludeDefault to /node_modules/, or undefined if output: true.
It takes priority over include.
// output: false | undefined
{
format: options.loader === 'json' ? 'esm' : undefined,
sourcefile: id, // the resolved file path
sourcemap: true,
...options
}
// output: true
{
sourcefile: chunk.fileName,
sourcemap: true,
...options
}
MIT License © 2021 Exuanbo
FAQs
Use esbuild with Rollup to transform any supported content types.
The npm package rollup-plugin-esbuild-transform receives a total of 51 weekly downloads. As such, rollup-plugin-esbuild-transform popularity was classified as not popular.
We found that rollup-plugin-esbuild-transform 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.