Use import in jsx file play framework - scala

I am using Play Framework 2.5 and ReactJS and I would like to be able to use importin my .jsx files but it seems like I am not allowed to do it because it throws an error in the javascript console saying that import is not recognized.
I added the sbt-reactjs to my build.sbt and I see that ReactJS compiles files each time they are changed, however I still have this importerror.
It can be really problematic as my application will grow because the components will become bigger and for example I would like to divide my navbar and to have Nav.jsand NavItem.js and I want to be able to call any component I have created in any *.js file of my application.
I have heard about babel that could transpile my code in pure javascript code but I would like to have more information about it, more precisely, can it works with Play (ie. will the files be transpiled during the assets command ?).
So my question is: Can I use the import with only the libs I have installed or do I have to add something else to my build.sbt ?
Thank you for your time

Well, from searching on the net, there seems there are lot of ways of doing it. I also ran into same problem. The best example I found was to use webpack for building the jsx files. The following git repo has all u need.
https://github.com/nouhoum/play-react-webpack

Related

Platform.io - how to compile just library files, which are used in project

I'm using library ESP8266 audio, which contains lot of files. I'm using just a few of them, but when I want to build my project, platformio tryes to complie ewerything. It's quite issue, because unused filles has dependecies, which are not included in my project (eg. SD card library, file system library...). I can build my code with arduino IDE without any issues, but I'm not able to do the same thing in platformio. I tried to tweak src_filter flag, but it has no effect at all. I'm stucked on this for more than day and I wasn't able to find any relevant informations :/
Thank you for your answers.
Oh, I solved it myself! :D I have set 'lib_ldf_mode' to 'deep' on platformio.ini. It's now acts exactly as I need. It starts in 'src/' folder and then recursively compiles imports and imports of imports and so on.

VS-Code: How to sort imports in specific order to go along with InteliJ

I am working in a team which mostly uses InteliJ. There imports get automatically sorted after the path. So "#namespace" goes first then less nested imports "./" > "../../" and on the same level its alphabetical.
Until now I used the "source.organizeImports" setting from VSCode which sorted the imports for named and default imports. This cant be customized as stated in another SO question and is not listed here: https://code.visualstudio.com/docs/languages/typescript#_organize-imports
I tried the VSC extension vsc-organize-imports but that doesnt have that option either. I would like to avoid to configure and run esLint to fix my import order. Any other suggestions, setting or extension I could try?
In another project I have taken another look into this matter. The only solution is to turn the VSC organize import feature off and let the formatter/linter do the work. As I dont like my linter on autofix and I generally think its the job of the formatter and everyone should have one heres my solution:
In a TS project I used prettier-plugin-organize-imports. This prettier plugin mimicks the formatting order of the organize imports feature, so its basically the same. Very nice, except it has a TS peer dependency.
Therefore a second solution for JS projects:
Use the prettier plugin prettier-plugin-import-sort. This plugin needs you to add an order style of your choice with it. But it supports vanilla JS
As mentioned I have also found rules for eslint with an autofix, but I dont like that solution. The above packages fix the problem if you are using prettier.
You can install a vs-code extension sort-imports to achieve the sorting of imports.

groovy scripts and classloader - content assist in eclipse - what to do?

Goal:
I want to define groovy classes in .groovy files as part of a package, but without ever needing to compile them. Then, I want to define groovy scripts in the same package, import the class definitions from the nearby .groovy files, and execute the script... all without compilation.
Problem,
This appears to be possible using GroovyClassLoader() (and several people have posted how-tos). However, the problem I have that nobody else seems to reference is that this strategy means that content assist will never be able to identify your classes and methods, and your code will be full of underlines, and receive no error checking.
You might say "Thats just a side effect of using such a dynamic feature, how would eclipse be able to know?", but consider the following:
As I was building my project, I was creating the scripts and the classes in the package just like normal a program. When I add my import statements for my custom classes, Eclipse recognizes everything and content assist is happy. However, despite content assist being satisfied, it hits a snag when I try to execute a script because eclipse returns: unable to resolve class (presumably because it's still only a groovy file, and not compiled to a class file).
So, I looked around and it looks like I have to comment out the import statement, and then use groovyclassloader to parse the groovy file instead. However, this has the negative side effect of breaking content assist.
Question: Are my conclusions above all basically correct?
Suggestion: Is there any known way to have content-assist work along-side with GroovyClassLoader? Maybe some way to tell it to ignore failed imports or something?
It turns out this was a problem with the way I had configured my classpath. Once I had my folder structure consistent with the package structure, eclipse found my class files and was able to import the classes.

Is the J2SE com.google.zxing.client.j2se.MatrixToImageWriter still the standard way to write barcodes?

I notice that there are a lot of old tutorials from about 2010 that use
com.google.zxing.client.j2se.MatrixToImageWriter
to write 2D barcodes to files.
Also, I notice a lot of old tutorials specify the use of Android.
I am using Eclipse on Linux Mint, not Android.
Eclipse will happily import the main src tree of java files and show them as available packages. For example, I can get all the packages under zxing/core/src/main/java to show up; I can import classes from those packages and compile them.
However, I can't seem to import the com.google.zxing.client.j2se package when I have the core packages imported, and vice versa.
If there is a way to write BitMatrix objects to files without using
com.google.zxing.client.j2se
that would simplify matters.
Alternatively, if there is some way to get Eclipse to import both sets of packages, that might be an alternative. I have already tried modifying the "filters" under the "properties" tab, on the theory that if I can use two filters, the first can pick up
core/src/main/java
and the second can pick up
/javase/src/main/java/
But that didn't work for me.
Suggestions are welcome. Thanks.
Ran into the same problem with the import. It appears that we both forgot to add the javase.jar into the project. Download it from here, import and you will be able to import MatrixToImageWriter.

NetBeans importing classes package problems

I have created a class in Java that I need to import into NetBeans and use in a GUI. What I have done so far is add the jar file containing the classes to the library in my project. I can look inside the jar file and see the classes I need inside the . I have looked around online and know that the best to way import these classes is to move them to another package that isn't the .
My problem is that I do not know how to do this. I saw that I can create a package in netbeans, but it is gray when it appears and I can't seem to do anything with it. I basically have no idea how to create packages that I can use to import classes If someone could please walk me through step by step I would greatly appreciate it. I have looked at the other posts on this site and other places online, but they seem to skip over somethings I am not sure about. My teacher didn't mention anything about packages either, so I am really in the dark.
You can copy your source files (*.java) in your project's src folder, then use refactoring to change the package.
Right-click your java file, then select Refactor > Move and type your new package name.