如何克服 Maven minify 插件的 "object literals cannot contain duplicate keys in ES5 strict mode" 错误?
How do I overcome "object literals cannot contain duplicate keys in ES5 strict mode" error with Maven minify plugin?
我在 Maven 3.5 中使用 Maven minify 插件。我有以下配置...
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.6</version>
<executions>
<execution>
<id>default-minify</id>
<phase>verify</phase>
<configuration>
<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>
<cssTargetDir>../${project.artifactId}/css</cssTargetDir>
<jsSourceExcludes>
<jsSourceExclude>lib/pdf.js</jsSourceExclude>
<jsSourceExclude>lib/pdf.worker.js</jsSourceExclude>
<jsSourceExclude>ckeditor_4.2/**</jsSourceExclude>
<jsSourceExclude>geogebra/**</jsSourceExclude>
<jsSourceExclude>contextMenu/**</jsSourceExclude>
<jsSourceExclude>wPaint/**</jsSourceExclude>
</jsSourceExcludes>
<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>
<jsTargetDir>../${project.artifactId}/js</jsTargetDir>
<jsEngine>CLOSURE</jsEngine>
<webappTargetDir>${project.build.outputDirectory}</webappTargetDir>
<skipMerge>true</skipMerge>
<nosuffix>true</nosuffix>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
但是,我在以下文件中收到此错误...
SEVERE: panel.js:845: ERROR - with
SIDE_PANEL_BEGIN_CLOSE_EVENT:SIDE_PANEL_BEGIN_CLOSE_EVENT,
^
Nov 27, 2018 2:57:06 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
我的未压缩文件在我的应用程序中一切正常,所以我认为我的配置有误,但我看不到什么。如何更正配置,以便在不影响代码的基础功能的情况下进行优化而不出错?
虽然 Google 的 Closure 编译器(由 minify 插件在后台使用它来优化源代码)默认情况下期望 ECMAScript 6 作为输入语言,但它似乎 运行 额外 diagnostic checks不考虑语言水平
这些诊断检查包括一项针对 ECMAScript 5 严格模式合规性的检查,该检查禁止对象中的重复键。
如中所述,您可以通过添加
在缩小配置中打开此诊断检查
<closureWarningLevels>
<es5Strict>OFF</es5Script>
</closureWarningLevels>
我在 Maven 3.5 中使用 Maven minify 插件。我有以下配置...
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.6</version>
<executions>
<execution>
<id>default-minify</id>
<phase>verify</phase>
<configuration>
<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>
<cssTargetDir>../${project.artifactId}/css</cssTargetDir>
<jsSourceExcludes>
<jsSourceExclude>lib/pdf.js</jsSourceExclude>
<jsSourceExclude>lib/pdf.worker.js</jsSourceExclude>
<jsSourceExclude>ckeditor_4.2/**</jsSourceExclude>
<jsSourceExclude>geogebra/**</jsSourceExclude>
<jsSourceExclude>contextMenu/**</jsSourceExclude>
<jsSourceExclude>wPaint/**</jsSourceExclude>
</jsSourceExcludes>
<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>
<jsTargetDir>../${project.artifactId}/js</jsTargetDir>
<jsEngine>CLOSURE</jsEngine>
<webappTargetDir>${project.build.outputDirectory}</webappTargetDir>
<skipMerge>true</skipMerge>
<nosuffix>true</nosuffix>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
但是,我在以下文件中收到此错误...
SEVERE: panel.js:845: ERROR - with
SIDE_PANEL_BEGIN_CLOSE_EVENT:SIDE_PANEL_BEGIN_CLOSE_EVENT,
^
Nov 27, 2018 2:57:06 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
我的未压缩文件在我的应用程序中一切正常,所以我认为我的配置有误,但我看不到什么。如何更正配置,以便在不影响代码的基础功能的情况下进行优化而不出错?
虽然 Google 的 Closure 编译器(由 minify 插件在后台使用它来优化源代码)默认情况下期望 ECMAScript 6 作为输入语言,但它似乎 运行 额外 diagnostic checks不考虑语言水平
这些诊断检查包括一项针对 ECMAScript 5 严格模式合规性的检查,该检查禁止对象中的重复键。
如
<closureWarningLevels>
<es5Strict>OFF</es5Script>
</closureWarningLevels>