TypeScript asset manager - assets

I use node.js connect/express.
Does anyone know an assets manager that supports on the fly compilation and minification of TypeScript source code?
Any idea how to call the compiler programmatically?
I've been using connect-assets which is build on top of Snockets. Shouldn't be that hard to implement once I figure how to compile a .ts resource.

From reading through the tsc.js code, it looks like there's a TypeScript.TypeScriptCompiler(outfile, errout, new TypeScript.NullLogger(), this.compilationSettings); function you could hook into. The code is on Codeplex, under an Apache license, and it's modular. Since TypeScript can be compiled to target CommonJS modules, it should be fairly straightforward to hack it into express.

Not a complete answer yet, but I found this project: which exposes the TypeScript compiler.
https://bitbucket.org/nxt/node-typescript-wrapper

Related

Could not find a declaration file for module '#hmscore/react-native-hms-push'

I'm having problems with linking push kit library.
I'm programming in react-native with visual studio code, library '#hmscore/react-native-hms-push' not seem to be imported correctly, the error is 'Could not find a declaration file for module '#hmscore/react-native-hms-push'.
I'm using 5.3.0-301 version.
Checking maps-kit and push-kit seems different si index.ts, is missing in the src directory of push-kit
i have used this guide:
https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/integraternmodule-0000001050157791
have i missed anything?
Thanks
The solution is:
yarn add #types/hmscore__react-native-hms-push
or equivalent in npm.

Definition mx.binding.utils.BindingUtils could not be found similar couple of imports not loading

I got chance to migrate Flex application to Apache Royale, able to run helloworld applications. started migrating Application, getting couple of exceptions. bellow is the one.
we are using the
AdobeSpelling.swc
AlivePDF.swc
Cairngorm.swc
flexmdi.swc
FlexUnit.swc
spcairngorm.swc
these '.swc' libraries.
how can i import these or is any similar libraries in royale compatible files.
i found asconfig.json file - external-library-path - but i am compiling my application with maven pom.xml.
Please help me, basic migrations
Error Log:
Warning: Definition com.model.ModelLocator could not be found.
import com.model.ModelLocator;
Warning: Definition com.util.customComponents.CustomMenuBarEvent could
not be found.
import com.util.customComponents.CustomMenuBarEvent;
There is two path which you can go in case of migrating.
Emulation Components. However there is a chance that some of
the components wasn't added to emulation so you may get exceptions
and this would be the place where you can add them and make pull
requests to Royale. Those components allows you in best case
successfully build your application without changing drastically UI
part, but you may won't see anything on the screen or it may be
messed, cause there wasn't volunteer who could work on displaying
better them.
Another path is to distinguish your pure ActionScript code (no
dependency to Flash) from UI part - pure AS3 code should ported
without any problem - and rewrite UI from scratch using Basic module
or Jewel
All libraries which you have mention have strong dependencies to Flash, so my recommendation is to find JS replacement for them and use it in your porting. There is also PureMVC which is working pretty good with Royale - it's has been tested in several applications already.

Calling *.aar files (android library) in nativescript vue

I already create an .aar (android library) files in android studio and want to call/use it in nativescript-vue project.
I have placed the aar file in "app/App_Resources/Android/libs" folder.
Based on my reading, in typescript the way to call the method in aar files is by calling com.package.MyClass.
My question is , how to call it in .vue files. I have tried to call the method using the same approach but its produce an error :
Module not found: Error: Can't resolve com.package.MyClass
Can someone please help me on this.
Your help is very much appreciated.
You may simply place your AAR file in your App_Resources/Android/libs directory, CLI will pick it up at build time and the native APIs should be available at runtime within your project.
Try a clean build if you see errors, make sure the AAR is picked up. You might be able to verify it from the CLI logs. If you still see issues, make sure the class you are trying to access is public.
I'm not sure it's possible to use the android lib directly in the main project or not. In my way, I create a NS plugin that includes the .aar library, then add this plugin to the main project & use the methods defined in the .aar library without problem.
If you place the .aar library in the main project, you should check if that .aar library is installed by running tns build command & look at console log. If it's installed together with the project, that means you can use the lib method in .vue or any .js files.

How to use browserify standalone option

I'm trying to create a standalone library that can be used as global variable, amd or commonjs module.
But after compiling it with browserify with standalone option, I can't include it in a next build as a compiled library because of the browserify error
Error: Cannot find module './dependency'
How to handle this problem.
All source code that i use can be found here: https://github.com/paveltyavin/double-browserify
Ok, the problem described in this github issue and in this question.
TLDR: use derequire.
Browserify parses compiled code and tries to make bundle everytime it reads function require . Minification (uglify) can be a nice workaround to handle the problem.

Browserify - How to include non-public purchased third party scripts

I am new to browserify and its usage is not completely clear to me although the benefits seem to be compelling.
I have a couple of questions and was hoping someone could clarify.
I've seen blog posts about using browserify-shim in the package.json to include third party libraries like jquery and bootstrap. I've also seen posts where tools like gulp are used generate the bundle file. I can't seem to find a good answer on why browserify-shim is required if tools like gulp are able to automate the process. Can someone please shed some light? Why is browserify-shim even required? I feel the gulp solution is a little cleaner although a little more involved. It won't pollute package.json with browserify specific stuff that is a build thing and therefore goes together with gulp (just my personal opinion)
How does one deal with third party libraries that are not in npm and also not public? For example, we purchase a script from a third party. That script is not any common js, but is a regular js file with some dependencies (example, on jquery and underscore).
Browserify lets you take the world of Node and bundle it up for delivery to a browser. It understands Node modules, which define dependencies via CommonJS require statements.
But what if you have some JS code or library that is not defined as a Node module and does not support CommonJS? Enter browserify-shim. It provides a shim wrapper around any script, like your private third party script, so that it can be defined as and used as a Node module that Browserify understands.
The use of browserify-shim is completely orthogonal to how you execute Browserify. There are basically two options there: A) Use Browserify's command line API or B) Use Browserify's JS API.
Using a build tool, like Gulp, implies the second option, since you'd use Browserify's JS API in your Gulp build script (i.e. gulpfile.js). A lot of people prefer the use of Gulp because it has a good ecosystem of plugins that allow you to do a lot more than just call Browserify (e.g. compile CoffeeScript, compile SASS, run JSHint, etc).
So, to answer your specific questions:
Browserify-shim is only required if you have JS code that is not written as a Node/CommonJS module that you need to bundle via Browserify. To do so, you will need to tell browserify-shim which files to shim as modules (and what dependencies they have) in package.json. Note that this is totally unrelated to Gulp; so you will need it whether you use Gulp or not.
What you describe is the perfect use-case of browserify-shim. Put your third party script(s) in your project, configure the files to be modules in package.json per b-shim's documentation, require them in your code, and execute Browserify to bundle them up with your code. You could also bundle them up separately, put them in their own project, etc - however you want to structure it.
A couple things to note:
You can shim just about any JS library this way.
Shimming a JS library to be a Node module changes global scope to be private scope. Hopefully everything in the library is namespaced so that all of its functionality can be exported as a single module, but if it's not, you might have to modify the shimmed code to explicitly attach things to window (which is easy but not recommended) or split the code up into separate files/modules.
Both Browserify and Gulp use streams in their JS API, but Browserify uses native Node streams while Gulp uses Vinyl streams. Since they don't play well together, you'll probably have to use vinyl-source-stream to adapt Gulp to Browserify (e.g. for renaming files in a Browserify pipeline), or use vinyl-transform to adapt Browserify to Gulp (e.g. wrap a Browserify stream for use in a Gulp pipeline).