如何捆绑将在“ new Function()”中调用的脚本

时间:2019-11-30 08:42:16

标签: webpack

假设我们有一个非常简单的脚本:

URL url = new URL("http://www.example.in/Ramesh");
System.out.println(url.getPath().substring(1));

该脚本旨在像这样在// script.js return {foo : "bar"}; 中执行:

new Function()

但是当我将此脚本与webpack捆绑在一起时,res变成const res = new Function(`return {foo : "bar"};`) // res = {foo : "bar"} 。我猜想是因为webpack的输出包含自调用功能。

如何配置webpack使其与undefined一起使用?

1 个答案:

答案 0 :(得分:0)

使用webpack插件是可能的。参见此issue