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
Bundle option produces empty .js file? #58
Comments
I have made some tests and I found out that the Eclipse plugin is quite unstable and sometimes has erratic behavior when using the bundle option (well the Eclipse plugin is still at version 0.9.3).... So I would advise the following:
Sorry for the bug. I will look into it ASAP and will make an Eclipse plugin update. I'll post you when ready. |
My answer may be irrelevant but isn't there a verbose option in the Eclipse plugin in order to look into more detailed output? |
You can check out the error log: Window > show view > error log. |
I am trying to follow the Getting Started guidelines, but not really making any progress. Some caveats: I am a complete maven newbie. We work on Windows (7) machines. I cloned the quickstart project and copied the files into a new folder called learn-jsweet. I renamed the project in the pom.xml and .project files. Imported the project into Eclipse. Right clicked on pom.xml and chose "Run as...", "Maven generate-sources". I copied in the section from the Use modules and bundle your programs for the WEB section of the Getting Started page. I re-run "Maven generate-sources" and it reports success, but the output appears unchanged from before. I add in the model class as in my original report, and change the
Examining the output I see that it generates the Part.js file and the QuickStart.js file references com.acme.model.Part but it does not actually create a bundle anywhere that I can see. Which steps am I missing? I haven't even gotten to including a candie yet, which is where it broke with the Eclipse plugin :-(. Thanks for your help so far. |
Be careful with the Use modules and bundle your programs for the WEB section of the Getting Started because it launches the JSweet transpiler with the command-line launcher. So you have to be careful because the configuration may be different (in terms of output dirs) from the quickstart. This could explain why you don't see any change in the output. Actually, to bundle your program from the quickstart project, I think that you should just add to the JSweet maven plugin configuration:
Please post your new |
Update: I have fixed the http://www.jsweet.org/getting-started/ You can rely on the given Note that the old version of the getting started section was generating all files in the |
Thanks a lot for your quick support. Following the updated Getting Started guide my basic bundling example now works. However, adding the jquery candie results in exactly the same behaviour I was seeing with the Eclipse plugin. Here is my
My
My
The output from
The I have not put a If that is not the problem, what is? |
There seems to be a deeper problem here. Bundling is done with browserify and it is probably failing silently... I have tried on a project using exactly what you provided and it works for me. I have a So, I am not sure of what can happen. It could be a browserify issue on your system. In order to try to understand what is wrong with your installation, could you please try/provide the following:
Thank you in advance and sorry for the inconvenience (it really does work for me... it is really the worst sort of problems)... :( |
Thanks for your help. I have now got it working. Looking at the output of the maven trace with the verbose option enabled showed that browserify could not find the jquery module. So I used Can I suggest you update the Getting Started Candies section to make a note about this? I am closing this now since it is fixed. |
Cool. I am glad it worked for you. This is helping a lot. There is an actual issue here because JSweet is supposed to install all the required libs to work (magically) using npm (node package manager). That's how JSweet installs browserify. However, apparently, on contrary to Maven, npm does not install dependencies automatically :( Most people, including me, did not see the issue because most people have tried the examples before (examples use jQuery, which triggers its installation). So the good news is that it is fixable. That's why I am reopening the issue. I will fix it and close it when done. Thanks again! |
Follow-up: it seems that I was wrong... npm should install also all dependencies when installing a package. So I am not sure of what happened but I have read on the Internet that in some contexts, the installation of dependencies fails. I am still investigating... |
Just a couple of questions for my understanding:
|
Yes, the jquery candy. That's an excellent question :) If you look at the
In practice, this external module corresponds to the npm package, so that at the end of the transpilation, when the module option is on (and only then), all the used modules are installed with Note that this process is still incomplete because the version number should be added in the |
Do I need to have done an |
Nope. As said in the docs, you only need npm installed. JSweet takes care of all the rest. Your question tells me that you still have issues? |
I have not yet tried adding another candy as a dependency. I just suggested that to see if that would help you replicate the problem. |
At the moment, it is hard for me to guess what happened. What you could try is the following if you have some time:
Let me know the outcome of this... it could help. |
So, I did as you asked:
Here is the section from the Maven trace showing the problems:
I see two problems there:
I hope this helps. |
So, when you build the project once again, it does not install jquery anymore, but it still fails right? Another idea... maybe it is Just in case, what are you versions of Thanks a lot for your help. |
I removed the two directories you mentioned an re-ran the build. The Maven trace shows that it installs When I said I installed
This, obviously, created a |
This is really mysterious... I tried to do Anyway, the only difference I see is that you are installing your modules with So, and that will be our very last try, I suggest that you upgrade to the snapshot version of JSweet to get my fix. You need to use the Make sure that when you build the given version of the transpiler is Then remove all the npm modules ( BTW, FYI, you can check out the installed modules by running |
I changed the plugin in the
And I see that it uses
But the end result is still the same:
Thanks for all your time on this, I was also happy to give you mine to help make the project better. It looks really cool and good luck with it. For the moment our team has decided to pursue TypeScript directly instead of JSweet. We may look back into the project in future. |
Just to clarify, this issue is unrelated to our reasons for pursuing something other than JSweet. This issue was an annoyance perhaps, but we had a workaround for it (manually installing JavaScript dependencies). |
Well, thank you also a lot for your time. It was kind of frustrating not being able to make it work, but your problem with the bundle is probably really node-specific (maybe even OS-specific). If I come across that bug again, I'll know where to start, so I think it was not a total waste of time... But you are right, it is not a blocking issue (neither a key feature), and I would have hoped to spend more time on interesting JSweet features rather than accessory ones. So, I am very curious about the reasons of your choice. Is it just because JSweet is so small and young compared to TypeScript? Or is there a deeper reason? To me, JSweet is reversible to TypeScript any time because the generated TypeScript code is very usable (if you turn off the sourceMap option of course). So I really think that choosing JSweet is not a risky choice and in a way, it is almost like choosing TypeScript (and the final choice can be made after). But there are probably things that I don't see here. If you want to give me more specific reasons, please don't hesitate to email me privately (my email is visible on Github I think). In any case, good luck for your new project and please re-consider using JSweet in the future :) |
Oh. By the way, I forgot. If you are using TypeScript on the front, and Java on the back, you may want to consider using JSweet to automatically transform your Java beans into TypeScript interface. This is an under progress feature (see #69). You will not get refactoring, but you will get type checking and the JSweet transpiler is pretty light and easy to integrate in a Maven or Gradle build. |
From version 1.1.0, JSweet will not produce bundles through Browserify, but will use a quite elaborated way to directly bundle the generated code (file permutations, lazy initialization of statics). So, JSweet will include an effective way to produce bundles without relying on external tools. Of course, it will still be possible to use external tools if you want to. This "bug" is now irrelevant. |
We are evaluating JSweet for use as a development platform for web apps. We are relatively new to Javascript, but have strong Java experience.
Using the Eclipse plugin I followed the "from a blank project" quick start and produced a working example. I then added a model class and enabled the bundle option to produce a single combined Javascript class. All very good.
Next I added the jquery (1.10.2) "candie" to the project and attempted to use it from my sample code. When I did that the produced bundle-helloworld.js file is completely empty. But there are no error messages.
All of the intermediate files look correct and are generated.
Why is no error message produced?
How do I go about fixing the problem?
Where exactly should I place the jquery.js file?
Here is my main class:
Here is my model class:
Here is the index.html:
Finally, here is the pom.xml:
The text was updated successfully, but these errors were encountered: