How to apply obfuscator-loader to ts files with ts-loader

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to apply obfuscator-loader to ts files with ts-loader



I want to compile my typescript into javascript and then run another loader to obfuscate it (take the bundle.js and obfuscate it into another file).



Seems like it should be easy, but when I tried different options, it's just not happnin'. I tried having an entry point for bundle.js, but that doesn't seem to work either. What's the best way to do this?


module.exports = {
mode: "development",
entry:
bundle: "./main.ts",
,
devtool: 'inline-source-map',
module:{
rules: [

test: /.tsx?$/,
include: [ path.resolve(__dirname, ".") ],
use:
loader: 'ts-loader',
loader: 'obfuscator-loader'
,
exclude: /node_modules/




1 Answer
1



Just add the necessary loaders on top of the list:


module.exports = {
mode: "development",
entry:
bundle: "./main.ts",
,
devtool: 'inline-source-map',
module:{
rules: [

test: /.tsx?$/,
include: [ path.resolve(__dirname, ".") ],
use: [
'obfuscator-loader',
'ts-loader',
],
exclude: /node_modules/



Execution order is always from bottom to top. obfuscator -> ts-loader-> other-random-loader





Thanks, but it didn't quite do it for an interesting reason. It appears from this error that the second webpack module is operating before the ts has been fully compiled to js and (I guess) that triggers an error. ERROR in ./main.ts Module build failed (from ./node_modules/ts-loader/index.js): TypeError: this.cacheable is not a function It seems like the simplest solution is to use the ts compiler in package.json instead of the webpack loader. That way, everything WebPack sees will be fully-compiled javascript.
– Network Effects
Aug 7 at 17:14






You are trying to run obfuscator After ts-loader? Which loaders do you want to run, and in which orders? Because your question is not that clear tbh
– PlayMa256
Aug 7 at 17:20






OK. I want to do the following tasks: 1) compile all .ts files into javascript 2) pack .js files (with WebPack). -- into bundle.js 3) run obfuscator on the compiled, packed javascript file.
– Network Effects
Aug 7 at 17:31






@SDAFO that is the order you have to put your loaders. It is going to compile/transpile typescript and run the obfuscator for each typescript file transpiled.
– PlayMa256
Aug 7 at 17:36





When I modify my code to run ts-loader and then obfuscator, it triggers an error: Module build failed (from ./node_modules/ts-loader/index.js): TypeError: this.cacheable is not a function at Object.loader use: [ 'ts-loader', 'obfuscator-loader' ],
– Network Effects
Aug 7 at 17:49







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered