js-confuser
js-confuser copied to clipboard
Uncaught SyntaxError: Cannot use 'import.meta' outside a module
Config:
{
target: 'browser',
preset: undefined,
pack: true,
}
Code:
console.log(import.meta.url)
Expected behavior
prints module url to console
Actual behavior
syntax error because pack: true makes the code be outside a module
Pack does not support full module features yet.
For now store import.meta into global variable, and modify the obfuscated output:
// Input.js
console.log(importMeta.url);
// Output.js
var importMeta = import.meta; // <- Add this manually
Function("rZK8Uq","return console[\"log\"](rZK8Uq[\"KRBtQm\"][\"url\"]);")({get"KRBtQm"(){return importMeta}});