javascript-obfuscator / javascript-obfuscator/webpack-obfuscator
process variable is undefined when use DefinePlugin
- Ngôn ngữ chính
- TypeScript
- Star
- 928
- Fork
- 92
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I wrote about this bug in [another issue](https://github.com/javascript-obfuscator/javascript-obfuscator/issues/863), but it is already closed, it would probably be more correct to make a separate issue in a more suitable repository for this.
I made a [minimal example](https://github.com/Katarn/obfuscator-process-bug).
Just run `npm ci && npm run build`. After that, in the `dist` directory, you will see the `main.js` file. Open it in a code editor and you will see something like:
```js
....shift())}}(n),process[r(309)][r(311)]&&console[r(302)](r(311))})();...
```
Of course, the `process` variable is `undefined`. Moreover, it should not be in the code, it should either be replaced with `true` (according to [this line](https://github.com/Katarn/obfuscator-process-bug/blob/master/webpack.config.js#L22)), or, with "smart optimization", the `if (...)` check block should not exist at all, since it will always be executed.
Then you can uncomment these [two lines](https://github.com/Katarn/obfuscator-process-bug/blob/5edcd56c5f2f18b6068e8459f7be075fc9691bb5/webpack.config.js#L14-L15) (not necessarily at the same time, you can uncomment them separately) and see how the code is generated in the `main.js` file.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với webpack.config.js của ví dụ tối thiểu, đặc biệt là cấu hình DefinePlugin quanh các dòng 14-15 và 22, sau đó chạy npm ci && npm run build. Kiểm tra dist/main.js khi các tùy chọn được bật và so sánh xem process có được thay thế hoặc được tối ưu hóa loại bỏ như mong đợi hay không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript, webpack
- Lĩnh vực
- build-system
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100