Qt Creator exclude JavaScript files from compilation process - javascript

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

Related

Minify a JavaScript file to the root JS file extension in Visual Studio

Developing .NET web projects, I'm used to using either the bundleconfig.json and/or compilerconfig.json file to bundle and/or minify javascript (and css) files. Is there a way to use either of these methods or some other method to minify a source javascript file (located in a folder outside of wwwroot) to the root .js file extension? I don't want the minified output to be filename.min.js, I want it to be filename.js (but minified).
I know ultimately, I can manually rename the files to accomplish this, but I'd rather it be automated in Visual Studio if possible.
Also, if it helps, I'm currently building this project in .NET 6.
Search for Visual Studio Code Minify plugin on Google. There are many here. For example, https://marketplace.visualstudio.com/items?itemName=MadsKristensen.BundlerMinifier https://marketplace.visualstudio.com/items?itemName=fbdegroot.Minifier.

Recommended way to add Typescript to an existing asp.net 4 Webforms project

I am working on quite an old asp.net 4.0 Webforms project in Visual Studio 2015.
I want to start using TypeScript instead of Javascript for some of the client side code. I have used TypeScript in other projects outside of Visual Studio (e.g. using Visual Studio Code, and the node tools such as npm, gulp etc)
Now, I am trying to see how to use the TypeScript in Visual Studio, and see quite a few conflicting posts, and various versions of TypeScript / VS referred to.
I have added a TypeScript file to VS, and VS reported it now supporting Typescript and added a few lines to the project file. A have also added the VS extension for Typescript (version 2)
I build my project and get the .js and .map files. The files are in CommonJS format so I need to either load these or convert using a some sort of bundling.
This is where I don't know where to go. Also, I have read conflicting reports on how to configure the Typescript (e.g whether or not Visual Studio will use a tsconfig.json file)
In non asp.net projects I have use gulp with the gulp-typescript browserify etc gulp plugins.
Do I do the same thing in my asp.net project, or is there some other way to bundle and convert the JS to browser usable code?
If I use the gulp method, I assume this then means I will now not be using the TS compiler installed via the Visual Studio plugin (so what is the point of this if it emits CommonJS formatted cod that I can't use in the browser?
Thanks in advance for any suggestions here!
Yes, Web forms can do TypeScript and Gulp. Below are some steps:
Configure npm
Configuring Bower
Configure Bootstrap and My CSS with Gulp
Update the Master page
Configure Gulp-Watch
A complete solution can be found here.
For TypeScript ,
Unless you have a .ts file created with "Add New Item" in your project, the option "TypeScriptCompile" on the "Build Action" of the file properties is not available and it raises an exception. After the first file is created, then you find this option and can manually set it to a .ts file.
The option "Typescript file" is not available in the "Add File" options unless you have a .ts file created with "Add New Item" in your project and you are in a "Scripts" folder (if you name differently the folder where you want to add this file, this option wont be available). Of course you can add a .ts file from "Add New Item".
Please read this SO thread Type Script Web Forms

SystemJS - TypeScript loader use cases

I have a question regarding following TypeScript plugin for SystemJS :
https://github.com/frankwallis/plugin-typescript/
Here is its description
A plugin for SystemJS which enables you to System.import TypeScript files directly. The files are compiled in the browser and compilation errors written to the console.
I wonder what would be the use cases of such plugin.
Why would developers import directly ts files and compile them in the browser instead of compiling them during development and import js files ?
Won't it reduce performance and load time to do it in browser ?
Is it supposed to be used only in development environment ?
plugin-typescript author here. In-browser compilation is strictly a development tool, in production you would use systemjs-builder (in combination with plugin-typescript) to create a single file containing all of the transpiled javascript.
Since the plugin was originally developed, a number of new workflows have become available when using typescript & systemjs (typescript single-file transpilation, vscode, systemjs hot-reloading, typescript system.register output, to name a few...) - Which one is right for you will depend on the size of your application, the platform/server you are using, and your own personal preferences.
No one in their right mind would compile/transpile in the browser for production; it's the equivalent of sending a turtle to get your mail because you don't like walking.
This is strictly a development tool for helping TypeScript devs avoid having to constantly compile after every change, with the added benefit of providing features like hot reloading.

Can't compile .d.ts TypeScript files in Visual Studio 2013

I'm trying out TypeScript for the first time and I've downloaded the angularjs.TypeScript.DefinitelyTyped package from nuget but I cannot generate JavaScript files from it.
I've tried deleting the file, creating a new TypeScript file (called angular.ts) and this generates a JavaScript absolutely fine with the exact same code. I could keep this file and do the same with the others but it seems like I should be able to compile these sorts of files.
I've also looked into the Properties of my project and under TypeScript Build I have the following options activated:
ECMAScript version: ECMAScript 5
Compile on Save
Allow implicit 'any' types
Module system: none
Keep comments in JavaScript output
Generate source maps
I don't have any errors when I build my project and all of my other .ts files that I have added all generate JavaScript files without an issue. I've looked to see if this is a known Visual Studio issue but I can't seem to find much about it. Is there a setting for this or should it happen automatically?
Sorry if I misunderstood the question but you cannot compile d.ts files. When you see a d.ts file, you can think of it like a interface for a project that was not written in TypeScript.
For example, I use phaser game engine. So like everyone else, I go and get the phaser.js file. At this point, my TypeScript cannot understand this phaser.js file. So, I go and grab the phaser.d.ts file and it is that which contains the full API of the phaser.js.
So basically, .ts files will always compile to JavaScript, whereas .d.ts are the definition files providing the bridge to using a .js file!
We are using Typescript with Visual Studio in our app, but we also had some problems when trying to coerce VS 2013 to compile TypeScript to JavaScript. We opted out for Grunt plugin and no longer rely on VS. I suggest you do the same. One caveat: don't use watch in typescript Grunt task. It will trigger VS into infinite loop when you will be building your project. Instead when you apply changes to your .ts files, tab switch to command line and run grunt task for ts->js compilation.

Web Essentials, command line utility to bundle script files?

I'd like to start bundling our javascript files. I've found that it's really easy locally using the web essentials plugin, however I need to set up the build server to generate the bundled .js file.
I'd rather not check this generated file into TFS as it will cause conflicts for our developers, and also since it's generated from the source I feel that the server build should generate it.
Is there a command line utility for doing the script bundling outside of visual studio that could be used as part of a build script? My google-fu is failing to find one.
Many thanks,
As long as you wrote it as proper AMD modules, require.js comes with a tool to turn all your files into an optimized bundle.

Categories