Example of kotlin project with shared module for js - javascript

Since 1.1 Kotlin has support for compiling code to JS. I want to find example of gradle project how to share some code (for example data-models) between js and jvm platforms. Ideally project should have this structure:
common module (compiles to .js and .class)
backend module (jvm)
frontend module (js, managed by webpack)

Related

Webpack for existing legacy knockout js application

I have a knockout js application. Which is predominantly implemented using the asynchronous module definition (AMD) technique. The application is quite big and its kind of legacy now. Is there any possible way to add webpack to compile all the js and generate a bundle with no changes to existing js codes.
I did install webpack. I gave the main js file which is the entrypoint of the app. Which eventually calls all the sub js using require or dependency('<filename>')function(attrs..) this is ko AMD syntax.
But the webpack didn't generate the required build at all.
https://knockoutjs.com/documentation/amd-loading.html

Package nodejs module as a jar

Most of my projects are built in Java and there was one set of requirement which we created using using NodeJS. Node JS had better options in buiding that utility and that is the reason we went with NodeJS.
Now I want to use that utility in all other java based projects as a dependent jar rather than invoking this Node JS service.
Is it possible to bundle this Node JS module into a jar and add it as a dependency in other java projects?

Qt Creator exclude JavaScript files from compilation process

I have a few JavaScript and HTML files inside the QT Quick Project that I want to exclude from the compilation process, but I want to have these files in the final executable.
When I build the project in release mode, for a few of the minified JavaScript files, QT is giving me errors, so I want to exclude these files from the build. These JS files are used from a web component running inside the QtWebEngine so it is ok if these are not compiled.
Obviously, you are utilizing Qt Quick Compiler with release build which compiles all .qml and .js in your resources. I assume you are using qmake build system because Qt Creator enables quick compiler for qmake based release builds by default but for CMake you need to manually enable it in CMakeLists.txt (at least for now).
For qmake based build you find the answer from the Qt Quick Compiler doc:
If you have .qml or .js files which should not be compiled but just
bundled by the resource system, then you can omit them from the
compilation by specifying the resources files that contain them in the
QTQUICK_COMPILER_SKIPPED_RESOURCES variable in your project file, like
below:
QTQUICK_COMPILER_SKIPPED_RESOURCES += bundle_only.qrc

How to compile multiple JavaScript files in Laravel Mix using different compilation settings for each file

I have an application that provides a downloadable JavaScript integration script for the application API. I would like to be able to compile this integration file using different settings compared to the main application front-end.
webpack.mix.js
// Compile js integration
mix.js('resources/js/integrations/FilterIntegration', 'integrations/filter.js');
// Compile the main application
mix.js('resources/js/layout/Root.js', 'public/js/app.js')
.sass('resources/sass/app.scss', 'public/css')
.extract(['react', 'react-router-dom', 'lodash']);
My problem is that this setup actually applies all the following chained commands to each of the compiled files. This means that my compiled integration file also has to use the vendor.js and manifest.js files that are created for the main application by the extract command and it also includes a sass import statement although obviously the integration has nothing to do with styles as it's simply ment as a JavaScript library.
So my question is the following: How do I set up my Laravel Mix compilation in a way where I can conveniently compile the integration libraries with settings separate from the main application?

How to expose TypeScript modules in NodeJS?

I have a library that I'm building in TypeScript. I'd like to include this library in both TypeScript and JavaScript Node projects. What is the general strategy to do this? Should I compile and have two versions or is there some other strategy I should be using?
I'd like to include this library in both TypeScript and JavaScript Node projects. What is the general strategy to do this?
Compile with the following to get the js output:
--module commonjs --outDir ./dist
This should make your project consumable by JS projects. To make it consumable by TS projects you need to generate a declaration file. This can be done using https://github.com/SitePen/dts-generator See usage for details : https://github.com/SitePen/dts-generator#usage
Note: There is discussion on removing the dts-generator dependency : https://github.com/Microsoft/TypeScript/issues/2338
In most cases I have seen you have a /dist/ folder where the compiled JavaScript is located.
Usually there is also a minified version like yourfilename.min.js - the rest is either outside or in a /src/ folder, so outside you have only the license/readme.md, package.json left and maybe the file for Grunt/Gulp (it is considered polite to - if you use a taskrunner - include a Grunt/Gulp file for compiling the typescript and minify the .js file afterwards, as far as I got it)
If you want to preserve the TypeScript advantages when using it in TypeScript projects, then you obviously have to expose a TypeScript version of the code so the TypeScript compiler can see the TypeScript declarations for your interface.
But, if you want people to be able to use your library in plain Javascript projects (that don't compile TypeScript into JS), then you have to offer a version that has a plain Javascript interface and where the code has already been compiled into plain JS.
So, if you want both of those advantages, then you have to offer two separate versions. The plain JS version can obviously just be a compiled version of the TypeScript (compiled into plain JS).

Categories