legacy-knowledge-base
公開されました Jul. 2, 2025

カスタムコードでES6を使用した場合のミニフィケーションの問題

written-by

Laura Li

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

この記事は、カスタムコードでECMAScript 6(ES6)を使用し、ES6コード トランスパイルされていない場合に遭遇するミニフィケーションエラーを記録します。

本番環境では、CSSやJavaScriptのリソースを最小化し、コードを軽量化するために、以下のプロパティを有効にしています。

minifier.enabled=true

Liferay Digital Enterprise 7.0では、Google Closure Compiler (closure-compiler.jar)を使用して、この最小化処理を行っています。 このライブラリのバージョンv20131014には、 、ES6コードがトランスパイルされていない場合、最小化されないという制限があります. 以下のようなよく似たエラーが表示されます。

2018-05-18 13:32:48.754 ERROR [http-nio-7180-exec-3][GoogleJavaScriptMinifier:116] (/o/com.liferay.docs.mvcportlet/js/main.js:3): Parse error. missing ; before statement
2018-05-18 13:32:48.756 ERROR [http-nio-7180-exec-3][GoogleJavaScriptMinifier:116] (/o/com.liferay.docs.mvcportlet/js/main.js:5): Parse error. illegal character
2018-05-18 13:32:48.756 ERROR [http-nio-7180-exec-3][GoogleJavaScriptMinifier:116] (/o/com.liferay.docs.mvcportlet/js/main.js:5): Parse error. missing ) after argument list
2018-05-18 13:32:48.757 ERROR [http-nio-7180-exec-3][GoogleJavaScriptMinifier:116] (/o/com.liferay.docs.mvcportlet/js/main.js:5): Parse error. illegal character
2018-05-18 13:32:48.757 ERROR [http-nio-7180-exec-3][GoogleJavaScriptMinifier:116] (/o/com.liferay.docs.mvcportlet/js/main.js:5): Parse error. syntax error
2018-05-18 13:32:48.758 ERROR [http-nio-7180-exec-3][GoogleJavaScriptMinifier:129] {0} error(s), {1} warning(s)

解像度

コードをトランスパイルしてください。

この方法については、以下の開発者向けチュートリアルを参照してください。

JS Transpiler Gradle Plugin
ES2015 に対応した JavaScript ファイルの準備

追加情報

minifier.enabled=falseでミニ化処理を無効化すれば、エラーは発生しません。 ただし、本番環境での最小化処理を無効にすることはお勧めしません。

did-this-article-resolve-your-issue

legacy-knowledge-base