webpack-obfuscator icon indicating copy to clipboard operation
webpack-obfuscator copied to clipboard

webpack-obfuscator not working on Firebase deployment

Open bangank36 opened this issue 2 years ago • 1 comments

Expected Behavior

webpack-obfuscator and javacript-obfuscator should be working on Firebase deployment without issue

Current Behavior

My firebase functions are deployed correctly unless I import webpack-obfuscator or javacript-obfuscator Always produce error

Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'webpack-obfuscator'
webpack-obfuscator javacript-obfuscator
sample code image image
error image image

Steps to Reproduce

  • Install webpack-obfuscator
  • Run firebase emulators:start to test the function, it working properly
  • Run firebase deploy the functions can not be deployed

Enviroment

  • Node 14
  • "webpack-obfuscator": "3.5.1",
  • "javascript-obfuscator": "4.0.2"

Reference

I have taken a look at these issues, but either they are outdated or not work

  • https://github.com/javascript-obfuscator/javascript-obfuscator/issues/687
  • https://github.com/javascript-obfuscator/webpack-obfuscator/issues/138
  • https://github.com/javascript-obfuscator/webpack-obfuscator/issues/82#issue-667058896

cc: @sanex3339 since you found a bug in loader ( but it was 3 years ago )

bangank36 avatar Feb 24 '23 13:02 bangank36

Updates Feb, 26 2023

  • While I can not figure out the root cause of this issue. I have come up with a work around by import the webpack-obfuscator on runtime, doing that making the Firebase deployment works seamlessly

Before

const StringReplacePlugin = require("string-replace-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin');
const WebpackObfuscator = require('webpack-obfuscator');

module.exports = function(inputFile, siteId, WebpackObfuscator) { ... }

After

const StringReplacePlugin = require("string-replace-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin');

module.exports = function(inputFile, siteId, WebpackObfuscator) { 
    const WebpackObfuscator = require('webpack-obfuscator');
    ....
}

bangank36 avatar Feb 26 '23 05:02 bangank36