cincheo / jsweet-quickstart

A template project to start with JSweet Java to TypeScript transpiler.
Apache License 2.0
17 stars 9 forks source link

Added <bundle>true</bundle> to pom.xml which avoids circular dependen… #6

Closed keithphw closed 4 years ago

keithphw commented 4 years ago

Just a minor edit where I added 'bundle:true' to the pom.xml file and made a corresponding edit to the index.html file which avoids circular dependency errors: "TypeError: Super expression must either be null or a function, not undefined". The fix to this problem is to bundle files as mentioned here: https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de Of course in this simple Quickstart example where there are so few javascript files and no circular dependency problems, it's unnecessary. But if new users use this quickstart as a working template to convert their own project from Java to Javascript, it's best that we include the best default options to make their experience as painless as possible. When I ran into this circular dependency problem I was close to giving up on JSweet since I had no idea why it didn't work. I happened upon this fix and persevered and am now very happy with JSweet. So I would like to contribute this minor edit. Thank you for the great work on JSweet! PS: This is my first pull request on Github ever. Apologies if I made an error. I tested it and it ran fine so hopefully it's all good.

lgrignon commented 4 years ago

Hey @keithphw, thanks for your PR. I think bundle true is not the solution. JSweet should not fail on circular dependency.

@renaudpawlak I think something similar was fixed on develop branch, am I right?

keithphw commented 4 years ago

When I used the 2.something version I experienced a circular dependency fail related problem that was fixed when I made bundle true. The problem with that error is that it's not clear why it's happening from a java developer's perspective when the java project compiles without such error. What's the harm in enabling bundle:true to minimise the potential for such problems? I'm sorry I don't have a test case to provide that shows the error popping up.

lgrignon commented 4 years ago

@keithphw The current quickstart project is using JSweet 3. Did you hit this problem with the latest quickstart?

keithphw commented 4 years ago

Hi lgrignon, I'm using JSweet 3.0.0-RC2 and my current project doesn't run unless bundle:true is set. Unfortunately I cannot share my current project. When bundle:false is set, there is an error thrown: "TypeError: somePackage.LogicLoop is not a constructor." So the JSweet3 release does not fix the problem, unless I'm doing something wrong. Do you normally run your projects with bundle:false and they work fine? The original article that was linked to states that the problem is best solved by bundling files: https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de EDIT: I never hit the problem with the quickstart project since it is very simple and has only one file with no dependencies. However, when first converting my own Java project to JSweet, I ran into this problem that was only fixed by bundle:true. With bundle:false, my project does not run.

lgrignon commented 4 years ago

A lot of bugs has been fixed in 3.0.0-RC5 if you want to give it a shot! Warning: groupId is org.jsweet.v3 for almost all artifacts now (please see pom.xml & build.gradle here: https://github.com/cincheo/jsweet-examples)

lgrignon commented 4 years ago

I close this one, please reopen on https://github.com/cincheo/jsweet if bug is still there :)