The compilation time of Webpack and Angular 2

My compile time is currently at 40 seconds and I'm looking for ways to speed it up.

I attempted setting the isolatedModules flag to true in the configuration but encountered an error:

error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided.

I am using webpack-stream within my Gulp task.

This is my Gulpfile.js task:

gulp.src('./tsScripts/users')
        .pipe(webpack(
            {
                 entry: {
                    "core_users": "./Orchard.Web/Modules/Core/tsScripts/users/users.ts",

                    "resources_product": "./Orchard.Web/Modules/Resources/tsScripts/products/product.ts",
                    "resources_products": "./Orchard.Web/Modules/Resources/tsScripts/products/products.ts",

                    "xrm_contractors": "./Orchard.Web/Modules/Xrm/tsScripts/contractors/contractors.ts",
                    "xrm_contractors_create": "./Orchard.Web/Modules/Xrm/tsScripts/contractors/contractors.create.ts",
                    "xrm_contractors_edit": "./Orchard.Web/Modules/Xrm/tsScripts/contractors/contractors.edit.ts",
                    "xrm_contractors_details": "./Orchard.Web/Modules/Xrm/tsScripts/contractors/contractors.details.ts",

                    "resources_inventory": "./Orchard.Web/Modules/Resources/tsScripts/inventory/inventory.ts",
                    "resources_inventory_create": "./Orchard.Web/Modules/Resources/tsScripts/inventory/inventory.create.ts",
                    "resources_inventory_edit": "./Orchard.Web/Modules/Resources/tsScripts/inventory/inventory.edit.ts",
                    "resources_inventory_details": "./Orchard.Web/Modules/Resources/tsScripts/inventory/inventory.details.ts",

                    "phx_productRegistry": "./Orchard.Web/Modules/phx/tsScripts/productRegistry/productRegistry.ts",
                    "phx_productRegistry_create": "./Orchard.Web/Modules/phx/tsScripts/productRegistry/productRegistry.create.ts",
                    "phx_productRegistry_edit": "./Orchard.Web/Modules/phx/tsScripts/productRegistry/productRegistry.edit.ts",
                    "phx_productRegistry_details": "./Orchard.Web/Modules/phx/tsScripts/productRegistry/productRegistry.details.ts",

                    "vendor": "./Orchard.Web/Modules/Core/tsScripts/vendor.ts",
                    "polyfills": "./Orchard.Web/Modules/Core/tsScripts/polyfills.ts"
                },
                output: {
                    path: __dirname,
                    filename: "./[name].js"
                },
                resolve: {
                    extensions: ['', '.ts', '.js'],
                    unsafeCache: true,
                },
                cache: true,
                devtool: 'eval',
                module: {
                    loaders: [
                        {
                            test: /\.ts/,
                            loaders: ['ts-loader'],
                            exclude: [/\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/],
                            options: {
                                transpileOnly: true
                            }
                        },
                    ]
                },
                plugins: [
                    new wpack.ProvidePlugin({
                        $: "jquery",
                        jQuery: "jquery",
                        "window.jQuery": "jquery",
                    }),
                    new wpack.optimize.CommonsChunkPlugin(
                        {
                            name: "vendor",
                            minChunks: Infinity
                        })
                ]
            }
        ))
        .pipe(gulp.dest('Scripts/main/'));

vendor.ts

///<reference path="./typings/globals/core-js/index.d.ts"/>
///<reference path="./node_modules/@types/jquery/index.d.ts"/>
///<reference path="./node_modules/@types/select2/index.d.ts"/>

import 'zone.js/dist/zone';
import '@angular/common';
import '@angular/compiler';
import '@angular/core';
import '@angular/forms';
import '@angular/http';
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/router';
import 'jquery';
import 'angular2-datatable';
import 'angular2-modal';
import 'rxjs';
import 'datatables'
import 'select2'

Although everything is functioning correctly, the build duration of approximately 40 seconds is too long. I tried making jquery external which improved the time to 1-3 seconds. Maybe making angular2 external could help? Or perhaps I made a mistake causing webpack to search through my entire solution for files. Any assistance would be greatly appreciated.

Answer №1

One helpful method during the development process is utilizing webpack's watch mode, allowing for incremental compilation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps to add annotations to a class descriptor:

Can you help me with the correct way to annotate this piece of code? export class TestCls { static SomeStaticFn(): TestCls { // Do some stuff... // Return the class descriptor for a "fluid usage" of SomeStaticFn return TestCls ...

Tips for implementing debounce functionality in mui Autocomplete

How can I debounce the onInputChange function within the MyAutocomplete component? export interface AutocompleteProps<V extends FieldValues> { onInputChange: UseAutocompleteProps<UserOrEmail, true, false, false>['onInputChange']; } ...

Using Typescript with Angular 2 to Implement Google Sign-In on Websites

Currently, I am in the process of creating a website that utilizes a typical RESTful web service to manage persistence and intricate business logic. To consume this service, I am using Angular 2 with components coded in TypeScript. Instead of developing m ...

Generate random entries from an object based on specific criteria and append them to a fresh object using Typescript

Experimenting with Ionic2 and Typescript has been my recent focus. I have an object that contains various meals, calorie counts, and meal types (such as vegan). This is how the object looks: [ { "id":14093, "name":"Proteinshake mit Wasser ...

Create a fake version of ElementRef and simulate the getBoundingClientRect() function

Looking to simulate ElementRef and access getBoundingClientRect() I experimented with the code below, but it didn't yield the expected results. const mockHostRef = { nativeElement: { getBoundingClientRect: {top: 10, left: 10} } } {pr ...

Stop Angular 2 from loading on Internet Explorer

I'm looking for a way to stop my Angular 2 application from loading on any version of Internet Explorer. I attempted using a script tag in index.html to detect IE, which was successful. However, when trying to redirect the app to a "not compatible pag ...

When null is assigned to a type in Typescript, it does not result in an error being triggered

Could someone enlighten me on why this code is not causing an error? import { Injectable } from '@angular/core'; interface Animal{ name: string; } @Injectable() export class AnimalService { lion: Animal = null; constructor() {} get(){ ...

Encountering difficulties during the migration process from a JavaScript to a TypeScript React Component

I've encountered some challenges with configuring TypeScript in my project. Initially, I developed my application using plain JavaScript. However, eager to learn TypeScript, I decided to convert my JavaScript project into a TypeScript one. To achiev ...

Utilizing functions from external modules in Angular

Recently, I created an es6 module with some exported functions and published it on npm after uploading its transpiled es5 code. Right now, I am in the process of trying to integrate this package into an Angular project that utilizes SystemJS as a module l ...

Dealing with DomSanitizer problem in Angular 2

When using background-image inline for my *ngFor list items, I encountered an issue. In my Component Class, I defined a variable to store a common part of the images' URLs (e.g., ) along with unique parts of the image URLs as this.image (such as qwer ...

Angular2 marker with custom design for Google Maps

We have successfully implemented Angular2 Google Maps () and integrated Styled Google Maps using the following Plunkr: https://plnkr.co/edit/rv6udUOEedMxJejEpIW1 import { Directive } from '@angular/core'; import { GoogleMapsAPIWrapper } from &a ...

Could having a large collection in mongoDB impact the performance of other collections?

As I delve into saving files in my application, there's an ongoing debate on whether to store them in the filesystem or database. After careful consideration, I have decided to save the files in the database. The database system I am using for this p ...

Using NextJs <Script> is only effective after a page has been reloaded

Currently delving into the world of NextJS and encountering an issue with integrating a third-party ebay script onto one of my route pages. The script only seems to appear sporadically upon reloading the page. However, when navigating to the store page via ...

Optimal methods for integrating an Angular application within an AngularJS application

Our extensive AngularJS application was initially developed 3 years ago and continues to receive new feature updates. I am keen on ensuring that these new features are written using the latest version of Angular. Converting the entire codebase is not feasi ...

When using Angular 2's HTTP POST method, it initiates an OPTIONS request

I've come across a peculiar issue with my Angular 2 application. I'm trying to send a JSON via a POST call to my Play Scala API, but it keeps attempting to make an OPTIONS request. Below is the code snippet : LoginService constructor (private ...

The issue with the antd Input component's onChange event not updating state correctly when using a list fetched from an axios get request in a React

Recently delving into React, I've dedicated the past week to honing my skills. My current project involves creating a straightforward application featuring a 'product create' form alongside a product list equipped with a search bar (utilizin ...

Child component not receiving disabled state from Angular 8 FormControl

In my code, there is a unique custom input that I have defined: <nivel-servico-slider formControlName="fornecedor_a"></nivel-servico-slider> This custom input has all the necessary properties as outlined in Angular's guide for c ...

How to identify the maximum value between two keys in Angular2

Currently, I am parsing through a data file containing approximately 500 entries that look like this: const LOCKERS: Locker[] = [ { lockerNumber: 1, room: 'Ladies', size: 'Small'}, { lockerNumber: 2, room: 'Ladies', size: ...

What is the best way to incorporate CSS into this HTML document?

Content has been omitted. It is crucial to review documentation in advance in order to reduce repetitive inquiries. Check out the Webpack v2 documentation. ...

Angular Kendo Grid (version 1.4.1)

I am currently encountering an issue where I want to select the first row in a Kendo Grid. Here is the code snippet that I have implemented: In my Component file: export class SampleComponent{ gridView: GridDataResult; mySelection: number[] = [0]; ...