Does a babel dependency have to be in your babel config file in order to be applied? - babeljs

This might be obvious but I can't find a definitive answer and want to be sure. I inherited a project which has the following babel dependencies in its package.json:
babel/core
babel/preset-env
babel/runtime
babel-preset-react-native
babel-plugin-module-resolver
None of them are referenced anywhere except for package-lock.json. Does this mean they aren't being used? I have a babelrc config file with module:metro-react-native-babel-preset and #babel/preset-typescript as presets for a React Native project, and I know I am using babel.
Do the former dependencies need to be in babelrc in order to be applied and so in the current state are useless? Or are they doing things in the background, like as a dependency of another package? But then why would I need to include them in my package.json? Thank you!

Related

How do I use doxygen with vcpkg/cmake?

I want to use doxygen with my project to generate documentation.
All "normal" dependencies of my project are managed by vcpkg and I was hoping that I can use doxygen this way as well, although it is not a lib that I link against, but a tool that I process my files with.
There seems to be some need for this, as this issue seems to be posted and some solution is merged.
When I dig further I found that there is a function called vcpkg_find_acquire_program that can specifically be called with doxygen argument. However, all examples are using portfile.cmake which my project does not have.
In my project I use:
vcpkg.json that acts as a manifest file. I specify the project name, version, dependencies. But I cannot put doxygen in the dependency list, because there is no doxygen portfile
CMakeLists.txt where I can specify that I require doxygen, but cmake won't manage downloading/installing it for me. It's vcpkg's job.
CMakeSettings.json where I specify build configurations
...and that is about it in terms of project configuration. So, where should I put that vcpkg_find_acquire_program? Or is there a different way?

Customize babel configuration in project created using create-react-app

I want to use a babel plugin (babel-plugin-module-resolver) in a project created using create-react-app.
I know how to change babel configuration using npm run eject, but I would like to avoid it.
I was going to use react-app-rewired but I heard that there is the possibility to configure babel without ejecting and without additional libraries.
(if possible), how can I do it?

How to create a babel plugin for internal use

How do we use a babel plugin that is not already accepted in a babel repository? I had trouble finding this answer reading through the babel plugin documentation.
We are interested in writing a babel plugin for for...in loops to address a bug in ios9 (ios9 Safari miscalculating sum). Although we would be happy to contribute it to the babel community, I was also wondering if it doesn't get accepted or isn't ready for general consumption, how to start using and testing it locally.
It's possible to make use of custom babel plugins that you can host on git.
You can refer to https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md for learning how you can develop and test your babel plugin locally.
Once you have developed the plugin, you can add a dependency for it in your project's package.json file.
Note that if you plan to make the plugin repository private, you'd have to create a personal access token (for Github) to allow npm to fetch repository contents. In that case, the example entry in your package.json file would be as follows:
"babel-plugin-transform-for-of-loop": "git+https://{token}:x-oauth-basic#github.com/username/babel-plugin-transform-for-of-loop"
Whatever package name that you pick for your plugin, you will need to add a reference for it in the .babelrc file. For this example, it would be as follows:
{
...
"plugins": [
"babel-plugin-transform-for-of-loop"
]
}
With that done, you should simply run npm install and your plugin would become active for your project.

How to isolate libraries in an unmanaged dependency .jar file so they don't conflict with others

I need to add a .jar as an unmanaged dependency to an sbt Scala project (it is the java-stellar-sdk). Everything works well as long as I don't run sbt test. There seems to be a Mockito version in the .jar file that conflicts with the one I am using in the project. I get a lot of errors that certain Mockito matchers are not found but everything works fine without the .jar in the lib folder.
Is there a way to tell sbt that it should ignore certain libraries in the .jar or that managed dependencies take precedence? I also found this related question but obviously it didn't help me.
An alternative workaround would also help a lot. Is it possible to isolate the libraries in the jar in a way that allows me to just make a certain package visible to the outside?
Update: The .jar contains Mockito 2 but my project uses Mockito 1, so this is a very simple and obvious conflict, that I can solve by upgrading to Mockito 2 (which I tried and it works). However, the question remains: Is there another reasonable way to isolate the Mockito dependency in the .jar to not interfere with my project in case I can't or don't want to resolve the conflict buy switching to a newer version of the library in question. Maybe altering the .jar to rename the conflicting packages? I don't know. Something like that.
I know that this is a very general question that has likely been discussed somewhere else in depth. However, I didn't find anything that really satisfied me. Links to relevant discussions of the topic are of course appreciated as well.
I can think of 3 ways for you to do it (ordered from simple to difficult):
delete mockito 2 manually from the jar file.
Since the jar is just a zip file, you can extract it, delete all the conflicting files, and pack it again.
compile that jar from source by yourself, and set mockito as a test dependency (as it should be). If you do that, consider opening a PR with your change, to fix the problem for the community
Shade the mockito files in the jar.
shading is the process of renaming all files in a jar file by certain rules. you can either use jarjarlinks or with sbt assembly plugin. see this answer to get you started with sbt assembly: https://stackoverflow.com/a/47974750/245024
You should be able to arrange for your Mockito 1 classes to appear before the Mockito 2 classes on the classpath. That will cause your classes to win any conflicts.

Multi-project .sbt build definition format breaks plugins

According to the sbt documentation:
The current recommendation is to use Multi-project .sbt build definition.
When I try to implement this as per the documentation's example, sbt no longer recognizes the sbt-assembly and sbteclipse plugins I added in:
./project/assembly.sbt
./project/plugins.sbt
It does work when I revert to a bare .sbt build definition.
I'm assuming the explanation is something to do with scoping, or some additional lines I need in my build.sbt file.
Does anyone have the explanation? I don't think this is in the documentation. At least not anywhere that I can find it. If I'm wrong, please point me to the relevant section. Thanks!