Rollup obfuscator plugin not running

I have this config:

import ts from "@rollup/plugin-typescript";
import { uglify } from "rollup-plugin-uglify";
import obfuscator from "rollup-plugin-javascript-obfuscator";

export default {
  input: "src/index.ts",
  output: [
    {
      file: "dist/bundle.js",
      format: "cjs",
    },
    {
      file: "dist/ugly-bundle.js",
      format: "cjs",
      plugins: [uglify()],
    },
    {
      file: "dist/obfuscate-bundle.js",
      format: "cjs",
      plugins: [obfuscator({ compact: true })],
    },
  ],
  plugins: [ts()],
};

And am trying to obfuscate a my files. The problem is, All other plugins work, but obfuscator doesn't. And I have no clue why. I tried removing the {compact} options, but no difference. It just transpiles the code, so the obfuscate-bundle.js is the same as bundle.js. ugly-bundle.js is in one line, and minified.

What am I missing?

I'm using this package: https://github.com/javascript-obfuscator/rollup-plugin-javascript-obfuscator


Solution 1:

This plugin is outdated, rollup change their function names, see this change

The "transformBundle" hook used by plugin javascript-obfuscator is deprecated. The "renderChunk" hook should be used instead.

You should use another plugin: rollup-plugin-obfuscator

yarn add --dev rollup-plugin-obfuscator javascript-obfuscator
# or
npm install --save-dev rollup-plugin-obfuscator javascript-obfuscator

Old answer

And for install I suggest use git repo with custom name:

npm install rollup-plugin-javascript-obfuscator@scarletsky/rollup-plugin-javascript-obfuscator
//or
yarn add rollup-plugin-javascript-obfuscator@scarletsky/rollup-plugin-javascript-obfuscator

In this case you can look on network graph and try find better replacement