webpack-obfuscator
webpack-obfuscator copied to clipboard
webpack-obfuscator not working on Firebase deployment
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 | ![]() |
![]() |
| error | ![]() |
![]() |
Steps to Reproduce
- Install
webpack-obfuscator - Run
firebase emulators:startto test the function, it working properly - Run
firebase deploythe 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 )
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-obfuscatoron 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');
....
}



