Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency goog.dom.TagName is unknown! #2

Open
T-Skinner opened this issue Jun 26, 2020 · 10 comments
Open

Dependency goog.dom.TagName is unknown! #2

T-Skinner opened this issue Jun 26, 2020 · 10 comments

Comments

@T-Skinner
Copy link

Why am I getting this?

> Task :run FAILED
Exception in thread "main" java.lang.AssertionError: Dependency goog.dom.TagName is unknown!
        at eu.cqse.SelectionPass.calculateTransitiveClosure(SelectionPass.java:23)
        at eu.cqse.SelectionPass.process(SelectionPass.java:13)
        at eu.cqse.Es6ModuleMasterConverter.convert(Es6ModuleMasterConverter.java:154)
        at eu.cqse.Es6ModuleMasterConverter.main(Es6ModuleMasterConverter.java:44)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

@Dan1ve
Copy link
Collaborator

Dan1ve commented Jun 26, 2020

Hi @thomasskinner ,

the converter first collects all the exported namespaces in the input files, and then verifies that every dependency can actually be resolved.
In your case, it seems that goog.dom.Tagname has not been declared using goog.provide or goog.module anywhere.
Could that be the case?

@T-Skinner
Copy link
Author

T-Skinner commented Jun 26, 2020

I don't even feed it any files though. I just do gradlew run like the readme says @Dan1ve

@T-Skinner
Copy link
Author

Perhaps I should mention I'm using MacOS @DreierF @Dan1ve

@DreierF
Copy link
Owner

DreierF commented Jun 29, 2020

MacOS should mit be the problem. I also run the converter on Mac OS. Did the clone of the closure library fork work? You should have a submodule named closure-library which contains the source code of the closure library inside your working copy of the converter. Is this the case?

@T-Skinner
Copy link
Author

T-Skinner commented Jun 29, 2020

MacOS should mit be the problem. I also run the converter on Mac OS. Did the clone of the closure library fork work? You should have a submodule named closure-library which contains the source code of the closure library inside your working copy of the converter. Is this the case?

There is a closure-library folder at the root which is empty. Why is it empty? I did a yarn install like the readme said. I tried symlinking the folder with my closure-library clone like this, but got an error.

closure-es6-converter on  master [✘] is 📦 v20200101.0 via ⬢ v14.3.0
➜ ln -s /Users/ts76/Dev/closure-library/closure closure-library

closure-es6-converter on  master is 📦 v20200101.0 via ⬢ v14.3.0
➜ cd es6-module-converter && ./gradlew run

> Task :run FAILED
Exception in thread "main" java.lang.IllegalArgumentException
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:127)
        at eu.cqse.AliasedElement.<init>(AliasedElement.java:11)
        at eu.cqse.ReaderPass.extractExportsOfGoogModule(ReaderPass.java:149)
        at eu.cqse.ReaderPass.getProvidedNamespaces(ReaderPass.java:125)
        at eu.cqse.ReaderPass.processJsFile(ReaderPass.java:50)
        at eu.cqse.FileUtils.processRelevantJsFiles(FileUtils.java:27)
        at eu.cqse.ReaderPass.process(ReaderPass.java:39)
        at eu.cqse.Es6ModuleMasterConverter.convert(Es6ModuleMasterConverter.java:151)
        at eu.cqse.Es6ModuleMasterConverter.main(Es6ModuleMasterConverter.java:44)

@DreierF
Copy link
Owner

DreierF commented Jun 29, 2020

The folder should point to exactly this commit https://github.com/cqse/closure-library/tree/minimal_fixes_on_20191111

@T-Skinner
Copy link
Author

@DreierF That fixed it, thank you.

Do you have any tips on how to get this working for my code base?

@DreierF
Copy link
Owner

DreierF commented Jun 29, 2020

I don't even know what you're exactly trying to do. My guess would be (as this converter was only tweaked to convert the closure library) you will need to debug and fix some more edge cases depending on the style of your codebase to make it work.

@Dan1ve
Copy link
Collaborator

Dan1ve commented Jul 1, 2020

@thomasskinner

What we did for our own codebase was to have some additional steps in Es6ModuleMasterConverter.java, so that the root path to our JS code was included in the conversion. Thus, all paths to the Closure library were "relativized" to e.g. import { XYZ} from '../ts-closure-library/goog/string/string' after the converter was finished.

However, this only worked because our code used goog.module everywhere already, so your mileage may vary here.
If you try something like this, ensure that you can revert changes to your own code if necessary (-> clean workspace).

@joswhite
Copy link

joswhite commented Dec 4, 2020

I was able to successfully convert my project's codebase & the portion of the Closure library it used to ES6 (total over 100K LOC) using closure-es6-converter. It took a few hundred hours, but was well worth it. Some of the steps included:

  • running a jscodeshift mod I created to add all missing goog.require statements in the code
  • clang-formatting the code per Google's styles since closure-es6-converter uses regex to find things & expects certain formatting
  • adding missing semicolons to the code using eslint
  • adding global objects used by the code to the reserved words in ConvertingPass.java to prevent variable shadowing
  • adding some of the namespaces to the import exceptions in ConvertingPass.java to get them to be imported with proper syntax
  • post-conversion: removing circular dependencies from the code & the Google Closure library (hint: "soft" dependencies can be removed using ./foo.Foo syntax
  • If you'd like more info, you can contact me by opening an issue on my fork of this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants