esbuild-plugin-reserve-identifiers
v1.2.0
Published
Just reserve some identifiers in your code.
Downloads
38
Readme
esbuild-plugin-reserve-identifiers
Just reserve some identifiers in your code.
Why ?
When you want to use esbuild
to bundle your code, but you want to keep some identifiers in your code, you can use this plugin to reserve them. esbuild/issues/2338
Then you can set minifyIdentifiers = false
and use other compression tools (such as swc)
Unfortunately, in this case the code output is like this, there is a file path for debugging, like this
var init_chunk_YWDVZGFJ = __esm({
".../chunk-YWDVZGFJ.js": function() {
}
});
Compression tools cannot remove this content.
Usage
import { reserveIdentifiersPlugin } from 'esbuild-plugin-reserve-identifiers';
esbuild.build({
// ...
plugins: [
reserveIdentifiersPlugin({
filter: /\.([tj]sx?|mjs)$/, // default filter
identifiers: ['ga', 't'],
}),
],
})