google/closure-compiler-js

How to use this project after cloning it?

rondonjon opened this issue · 10 comments

I wanted to try out some changes, so I cloned the project into my github account. Before changing anything inside the cloned project, I updated the package.json of the test project in which I am going to use the compiler:

"google-closure-compiler-js": "github:rondonjon/closure-compiler-js"

The download through npm i worked just as expected, but now I am getting strange errors on the console. Any ideas? Did I miss any additional build instructions??

{ Error: Cannot find module './jscomp.js'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/rondonjon/test/node_modules/google-closure-compiler-js/compile.js:24:16)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/rondonjon/test/node_modules/google-closure-compiler-js/index.js:25:12)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32) code: 'MODULE_NOT_FOUND' }

No, unfortunately that's only causing more errors.

I went into the node_modules/google-closure-compiler-js directory; first time running node build.js there threw an error about ncp being missing; I was able to fix it by running npm i.

Now I am now getting the following from node build.js:

/home/rondonjon/test/node_modules/google-closure-compiler-js/build.js:30
  throw new Error('compiler build failed');
  ^

Error: compiler build failed
    at Object.<anonymous> (/home/rondonjon/test/node_modules/google-closure-compiler-js/build.js:30:9)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

I looked into the script; apparently it wants to run mvn on the command-line, which I don't have installed.

I am still wondering how this github download differs from the package that would be downloaded by npm.

Usually, if additional steps were required for building a package that has been downloaded from source, I would expect to find those in package.json, so that npm would run them automatically after downloading. In this case, I cannot even find a pointer in the README or CONTRIBUTING docs. Feeling lost 😞

We don't check in the built transpiled Java => JavaScript build source as it's (IIRC) about ~2mb. You should fetch the jscomp.js file from NPM or a trusted mirror.

You're right though—the repo doesn't have build instructions. We have them documented internally but I'll add them on this repo. (Sadly, they do involve having Java and Maven installed).

Hello @samthor, thanks for your quick reply.

I have now installed maven, downloaded jscomp through npm (as a module, couldn't find any prebuilt bundles) and created a symbolic link jscomp.js -> node_modules/jscomp/index.js, so that the path can be resolved.

I can now run node compile.js without errors. The script completes rather quickly and without any other ouput, so I am not sure if it really worked.

node build.js is still failing with compiler build failed.

I am trying to get ./build_compiler.js working, as I want to build from source.
I installed Java 9.0.1 and Maven 3.5.2, but the build is failing with

[INFO] --- gwt-maven-plugin:1.0-rc-6:compile (default-compile) @ closure-compiler-gwt ---
[INFO] Compiling module com.google.JsComp
[INFO]    [ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User')
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.920 s
[INFO] Finished at: 2017-11-07T00:33:26Z
[INFO] Final Memory: 15M/50M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:compile (default-compile) on project closure-compiler-gwt: GWT Compiler exited with status 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:compile (default-compile) on project closure-compiler-gwt: GWT Compiler exited with status 1
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: GWT Compiler exited with status 1
    at net.ltgt.gwt.maven.CompileMojo.execute (CompileMojo.java:226)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
/Users/dan/p/closure-compiler-js/build_compiler.js:34
  throw new Error('compiler build failed');

Any ideas as to what’s going wrong?

In general, if you're interested in hacking on the compiler and not just using it, I recommend working from https://github.com/google/closure-compiler which is better supported and documented than this repo.

Hmm. I'm specifically interested in the JS version. As far as I understand the main repo is already a submodule, isn't it?

In particular, I want to expose a flag for JS version (as I described in google/closure-compiler#2690). I imagine this would be done somewhere in the GWT runner but I'd need to compile my changes to JS to actually test if they work. So this is why I'm trying to get the build working in this repository.

Okay cool. Hopefully we'll get the Travis build into a good state soon and then, worst case, you can "test" by just sending the PR and letting Travis test it.

#82
:-)