Wakaru is the Javascript decompiler for modern frontend. It brings back the original code from a bundled and transpiled source.
- ๐ช๐ฆ Unpacks bundled JavaScript into separated modules from webpack and browserify.
- โ๏ธ๐ Unminifies transpiled code from Terser, Babel, SWC, and TypeScript.
- โจ๐ Detects and restores downgraded syntaxes (even with helpers!). See the list.
- ๐งช๐ก๏ธ All cases are protected by tests. All code is written in TypeScript.
See live demo for detailed examples.
Converts transpiled code back to its readable form and restores downgraded syntaxes.
Supports the following transpilers:
- Terser
- Babel
- SWC
- TypeScript
Read the documentation for more information.
Converts bundled JavaScript into separated modules
Supports the following bundlers:
- webpack
- browserify
Test the tool and see it in action at Playground.
By default, the CLI will run in interactive mode and guide you through the process.
You can also pass options to skip some steps in the interactive mode.
npx @wakaru/cli
# or
pnpm dlx @wakaru/cli
Run npx @wakaru/cli --help
to see the full list of options.
Option | Default | Description |
---|---|---|
--output |
"out" |
Output directory |
--force |
false |
Force overwrite output directory |
--concurrency |
1 |
Specific the number of concurrent tasks |
--perf |
false |
Show performance metrics |
--perf-output |
Performance metrics output directory |
--concurrency
can be used to speed up the process. But please aware that the process might OOM if the input file is too large.
If you want to run the CLI in non-interactive mode, you can specify the feature by passing the feature name as the first argument.
unpacker
and unminify
will run only the corresponding feature.
all
will run both unpacker
and unminify
sequentially.
npx @wakaru/cli all <files...> [options]
npx @wakaru/cli unpacker <files...> [options]
npx @wakaru/cli unminify <files...> [options]
These options are only available in all
mode.
Option | Default | Description |
---|---|---|
--unpacker-output |
"out/unpack" |
Override unpacker output directory |
--unminify-output |
"out/unminify" |
Override unminify output directory |
When running a single feature (either unpacker
or unminify
), the CLI will only uses the path specified in the --output
option. This means that, unlike in the all
mode where subdirectories (out/unpack
and out/unminify
) are automatically created within the output directory, in single feature mode, the output files are placed directly in the specified --output
directory without any additional subdirectories.
npm install @wakaru/unpacker @wakaru/unminify
# or
pnpm install @wakaru/unpacker @wakaru/unminify
# or
yarn add @wakaru/unpacker @wakaru/unminify
Click to expand
import { unpack } from '@wakaru/unpacker';
const { modules, moduleIdMapping } = await unpack(sourceCode);
for (const mod of modules) {
const filename = moduleIdMapping[mod.id] ?? `module-${mod.id}.js`;
fs.writeFileSync(outputPath, mod.code, 'utf-8');
}
import { runDefaultTransformationRules, runTransformationRules } from '@wakaru/unminify';
const file = {
source: '...', // source code
path: '...', // path to the file, used for advanced usecases. Can be empty.
}
// This function will apply all rules that are enabled by default.
const { code } = await runDefaultTransformationRules(file);
// You can also specify the rules to apply. Order matters.
const rules = [
'un-esm',
...
]
const { code } = await runTransformationRules(file, rules);
You can check all the rules at /unminify/src/transformations/index.ts.
Please aware that this project is still in early development. The API might change in the future.
And the bundle size of these packages are huge. It might be reduced in the future. Use with caution on the browser (Yes, like the playground, it can run on the browser โจ).
Usage of wakaru
for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program.