question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript Typing

See original GitHub issue

follow up on that with more news: https://github.com/javascript-obfuscator/webpack-obfuscator/issues/58

Expected Behavior

I think we should do some type unions instead of enums for this, or at least export them.

Your Environment

  • Obfuscator version used: I’ve just that in the project -> “webpack-obfuscator”: “^0.18.3”
  • Node version used: 13.3

Stack trace

/Users/devchris/Documents/code/nodejs/project/node_modules/javascript-obfuscator/src/enums/ObfuscationTarget.ts:1
(function (exports, require, module, __filename, __dirname) { export enum ObfuscationTarget {
                                                              ^^^^^^

SyntaxError: Unexpected token 'export'
    at new Script (vm.js:87:7)
    at NativeCompileCache._moduleCompile (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
    at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/devchris/Documents/code/nodejs/project/node_modules/ts-node/src/index.ts:529:44)
    at Module.load (internal/modules/cjs/loader.js:983:32)
    at Function.Module._load (internal/modules/cjs/loader.js:891:14)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/Users/devchris/Documents/code/nodejs/project/packages/main/webpack.config.ts:6:1)
    at Module._compile (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Module.m._compile (/Users/devchris/Documents/code/nodejs/project/node_modules/ts-node/src/index.ts:536:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/devchris/Documents/code/nodejs/project/node_modules/ts-node/src/index.ts:539:12)
    at Module.load (internal/modules/cjs/loader.js:983:32)
    at Function.Module._load (internal/modules/cjs/loader.js:891:14)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at WEBPACK_OPTIONS (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
    at requireConfig (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
    at /Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
    at /Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/cli.js:71:45
    at Object.parse (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/yargs/yargs.js:567:18)
    at /Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/Users/devchris/Documents/code/nodejs/project/packages/main/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:1128:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:983:32)

Minimal working example that will help to reproduce issue

just a webpack.config.ts with these imports:

import { ObfuscationTarget } from "javascript-obfuscator/src/enums/ObfuscationTarget";
import { IdentifierNamesGenerator } from "javascript-obfuscator/src/enums/generators/identifier-names-generators/IdentifierNamesGenerator";

and this in plugins array:

new JavaScriptObfuscator(
      {
        rotateUnicodeArray: true,
        deadCodeInjection: true,
        compact: true,
        selfDefending: true,
        deadCodeInjectionThreshold: 0.1,
        reservedStrings: ["test"],
        target: ObfuscationTarget.Node,
        identifierNamesGenerator:
          IdentifierNamesGenerator.MangledIdentifierNamesGenerator
      },
      []
    )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
sanex3339commented, Jan 3, 2020

Hmm, looks like not fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Type Compatibility - TypeScript
Type compatibility in TypeScript is based on structural subtyping. Structural typing is a way of relating types based solely on their members.
Read more >
Type Annotation in TypeScript - TutorialsTeacher
TypeScript - Type Annotations. TypeScript is a typed language, where we can specify the type of the variables, function parameters and object properties....
Read more >
The definitive guide to typing functions in TypeScript
Learning how to type functions is an integral part of a TypeScript developer's toolbox. Learn how in this comprehensive tutorial.
Read more >
TypeScript's Type System - Gitbook
The type system in TypeScript is designed to be optional so that your JavaScript is TypeScript. · TypeScript does not block JavaScript emit...
Read more >
Understanding type compatibility | Learn TypeScript
TypeScript uses structural typing, which means that variables with different types can be assigned to one another if the types are compatible. Here...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found