bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Asset Pipeline 40x larger file size - 4.3.0 requires and additional 55.81 MB compared to 3.4.7

codeconsole opened this issue · comments

Are all these dependencies necessary in the production jar? If not, what is the best way to exclude them?

Asset Pipeline 4.3.0

+--- com.bertramlabs.plugins:asset-pipeline-grails:4.3.0
    \--- com.bertramlabs.plugins:asset-pipeline-core:4.3.0
         +--- org.graalvm.sdk:graal-sdk:22.0.0.2
         +--- org.graalvm.js:js:22.0.0.2
         |    +--- org.graalvm.regex:regex:22.0.0.2
         |    |    \--- org.graalvm.truffle:truffle-api:22.0.0.2
         |    |         \--- org.graalvm.sdk:graal-sdk:22.0.0.2
         |    +--- org.graalvm.truffle:truffle-api:22.0.0.2 (*)
         |    \--- org.graalvm.sdk:graal-sdk:22.0.0.2
        +--- org.graalvm.js:js-scriptengine:22.0.0.2
         |    \--- org.graalvm.sdk:graal-sdk:22.0.0.2
         \--- org.slf4j:slf4j-api:1.7.28 -> 1.7.36

Asset Pipeline 3.4.7

+--- com.bertramlabs.plugins:asset-pipeline-grails:3.4.7
    \--- com.bertramlabs.plugins:asset-pipeline-core:3.4.7
         \--- org.slf4j:slf4j-api:1.7.28 -> 1.7.36

The problem is in 1d9ac7f

Probably https://github.com/oracle/graaljs should be enough instead of full graal development kit designed for building languages and native compilation. These documents https://www.graalvm.org/latest/reference-manual/js/#interoperability-with-java ans https://www.graalvm.org/latest/reference-manual/js/RunOnJDK/ show different dependencies required to execute js

Also relevant discussing oracle/graal#287

We can consider using rhino which is ~1mb dependency https://github.com/mozilla/rhino or ~2mb https://github.com/openjdk/nashorn

neither rhino nor nashorn are viable on more modern jdks and babel.js will not run within them. graal is necessary. graal-sdk is there for older versions of java runtime (i.e. java8)

@davydotcom if the assets are compiled at build time, why are all these dependencies needed during runtime on a production jar?

+--- com.bertramlabs.plugins:asset-pipeline-grails:4.3.0
|    \--- com.bertramlabs.plugins:asset-pipeline-core:4.3.0
|         +--- org.graalvm.sdk:graal-sdk:22.0.0.2
|         +--- org.graalvm.js:js:22.0.0.2
|         |    +--- org.graalvm.regex:regex:22.0.0.2
|         |    |    \--- org.graalvm.truffle:truffle-api:22.0.0.2
|         |    |         \--- org.graalvm.sdk:graal-sdk:22.0.0.2
|         |    +--- org.graalvm.truffle:truffle-api:22.0.0.2 (*)
|         |    \--- org.graalvm.sdk:graal-sdk:22.0.0.2
|         +--- org.graalvm.js:js-scriptengine:22.0.0.2
|         |    \--- org.graalvm.sdk:graal-sdk:22.0.0.2
|         \--- org.slf4j:slf4j-api:1.7.28 -> 1.7.36

These 2 dependencies add 57M to the final jar.

8.5M	truffle-api-22.0.0.2.jar
 48M	js-22.0.0.2.jar

Here is my workaround which should not be necessary:

configurations {
    //  ...
    runtimeOnly.exclude group: "org.graalvm.js"
    runtimeOnly.exclude group: "org.graalvm.sdk"    
}

Which takes down website.jar from 146M to 86M

@davydotcom I agree with @codeconsole. Full graal SDK should be excluded from runtime, it's unnecessary bloat for grails app runtime

@codeconsole to make grails runnable in dev mode I had to include

bootRun { task ->
    dependencies {
        implementation "org.graalvm.polyglot:polyglot:24.0.2"
        implementation "org.graalvm.polyglot:js:24.0.2"
    }
}

@rlconst i think i fixed this. the gradle plugin was not up to date in the gradle plugin publish. asset-pipeline-gradle:4.5.1 should fix it. This auto injects those dependencies on the bootRunt ask