1.2.0 • Published 1 year ago

esbuild-plugin-reserve-identifiers v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

esbuild-plugin-reserve-identifiers

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly

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'],
    }),
  ],
})
1.2.0

1 year ago

1.1.0

1 year ago