Can I use Babel to support transforming custom JSX? - esbuild

I was wondering if the Esbuild Golang specific library has a way to provide a Babel transformer? I have a custom JSX transform I'd like to apply.

Related

Can I use gsap, parallax.js in angular7

I'm new to angular Im planning to create a website with parallax.js and gsap tweenmax effects with angular7. I want to know where do I get some reference regarding with this
Angular works with most JavaScript libraries. An example on parallax.js in particular can be found here. The post uses parallax.js with angular 5, on angular 7 the angular-cli.json was renamed and remodelled to angular.json but the rest should be the same. For tweenmax, a tutorial can be found here.
You will notice, the process to include a third party library is always the same or pretty similiar:
Install the library through npm
Include the library either through the angular.json script section or through import in your project (depends on the packaging)

Importing files under the src directory from a dart library

Effective dart says
"DON’T import libraries that are inside the src directory of another package."
reason being it breaks abstraction and could potentially break your app if the library was to change its underlying implementation.
They do not provide an alternative or a solution.
Im currently working on a dart package that my app depends on.
What would be the correct way to import the models or classes from it instead of importing it directly from package src folder?
As previously mentioned in the comments, you can define which classes you can expose from your package. You're correct that it's recommended to avoid exposing more API than intended - it's also mentioned in the docs. To do this, you can define the exposed classes:
export 'src/your_file.dart' show ExposedClass hide HiddenClass;

How to generate Dart code from json structure

The code_build (https://pub.dartlang.org/packages/code_builde) package provides a solution to generate classes and constructors, field and methods for that class.
My ultimate goal is to generate Flutter (https://flutter.io) Widgets based on the json structure given, but I don't know how to do this with the code_build or another package.
So help would be appreciated!
The general way to write something which outputs Dart code is to wrap up the functionality in a Builder and to perform the code generation with build_runner
At a high level you'd write a Builder that:
Has buildExtensions of {".json": [".dart"]}.
Reads in the buildStep.inputId asset and parses the json.
Uses code_builder to build up a String and then write it to the output asset.
Then you'd configure the builder in build.yaml. And either apply it manually to your package, or if you'd like to publish it as a utility it can apply to dependencies.
Your package would have a dev_dependency on build_runner and then you can execute builds with flutter packages run build_runner build.
There are more docs at https://github.com/dart-lang/build/tree/master/docs
You can see an example of a package which does something similar - starts with yaml files and outputs Dart files using code_builder at https://github.com/natebosch/message_builder
There is now an online tool which will generate the Dart classes from a JSON payload if you're only looking to structure your model classes. It won't do it dynamically at runtime, but it's super helpful when you're first building your program.
https://javiercbk.github.io/json_to_dart/

Can I access metadata annotations of a type or parameter in flutter?

Or is that capability lost with the loss of the reflect package?
What I'm curious about is can I use annotations in my own flutter app? Or is that a feature only available in dart, but not flutter?
Annotations can only be used for static analysis in Flutter.
For example the analyzer that generates hints and warnings in your IDE, code generation tools like built_value, built_redux, json_serializable, and other packages that use https://github.com/dart-lang/build make use of this.
There is no way to get metadata information at runtime without dart:mirrors.
There is work in progress to make the reflectable package work with code generation. This might work with Flutter eventually to generate code that allows to access predefined metadata at runtime.
See also https://github.com/dart-lang/reflectable/tree/use_build
Yes, of course you can use metadata annotations in flutter. Flutter has a meta-library, which you can look into to know about available annotations that can be used with flutter.
Hope this helped!

Combining different dart files when executed by JS

I'm building up some Dart code that I would like to use in an app where it is essentially a library to the javascript. I'm wondering how I can specify which Dart files I'd like in the project to be part of the library. For example, theres Foo.dart and Bar.dart. How can I have the created product include both Foo.dart and Bar.dart in one file? I'm also concerned about tree shaking since none of the classes are instantiated in Dart.
There's also a Baz.dart, and I would like to have a different build for compiling Foo.dart and Baz.dart into a single file (though this is less important, as I can accomplish this would separate projects and some symlinking).
Thanks!
This use case (build a JavaScript library with Dart) isn't supported yet.
The reworked js-interop package is supposed to allow to do that but I don't know about it's current state.

Resources