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

Oops! An issue occurred during the `ng build` command, indicating a ReferenceError with the message "Buffer is not defined

I'm facing an issue while trying to utilize Buffer in my angular component ts for encoding the Authorization string. Even after attempting npm i @types/node and adding "node" to types field in tsconfig.json, it still doesn't compile with ng buil ...

Setting up project with local library installation in Angular 7 - Project configuration

I am currently working on an Angular application that consists of a core module and a shared module. The structure of my project is as follows: ./repo | projects | core | shared | src (my app) When I build libraries, the output folder is dist ...

Definitions for images in the following format

I am currently utilizing typescript in conjunction with NextJs and next-images. Here is the code snippet: import css from "./style.sass"; import img from './logo.svg'; import Link from 'next/link'; export default () => <Link hre ...

Guide: Populating an MUI Autocomplete TextField using data fetched from Axios

I have created a registration form for pets which includes an MUI Autocomplete component in the text field for selecting the pet type. However, I am facing an issue when trying to pre-fill the Autocomplete component with data from the database while edit ...

React hooks causing dynamic object to be erroneously converted into NaN values

My database retrieves data from a time series, indicating the milliseconds an object spends in various states within an hour. The format of the data is as follows: { id: mejfa24191@$kr, timestamp: 2023-07-25T12:51:24.000Z, // This field is dynamic ...

Easy pagination for angular's in-memory-web-api

Looking for help to implement pagination in Angular-in-memory-web-api. Currently, I have the following setup: import { InMemoryDbService } from 'angular-in-memory-web-api'; export class InMemoryDataService implements InMemoryDbService { ...

How to format dates with month names in various languages using the date pipe

In my HTML code, I have set up the date display like this: <span >{{ item.lastModified | date : 'MMM d, y' }}</span> As a result, the displayed date looks something like Jul 20, 2021. However, when I switch my browser's language ...

Transferring information to an Ionic 5 custom element label

In my ionic 5 app, I have a side menu and tabs. Each page can have different contents for the side menu and the tabs. Instead of duplicating the ion-menu in each page, I created a header component (and one for the tabs) as follows: HEADER COMPONENT: <i ...

Issue with Angular4 ngFor - Unable to locate a distinguishable entity supporting the object '[object Object]' categorized as 'object'

Currently, I'm diving into Angular 4 and actively working on displaying the results of a backend API call. Thankfully, I have successfully retrieved the data but am facing issues with how to showcase it. Below is the component code snippet: import { ...

Exploring the concept of inheritance and nested views within AngularJS

I've encountered a challenge while setting up nested views in AngularJS. Utilizing the ui-router library has been beneficial, but I'm facing issues with separate controllers for each view without proper inheritance between them. This results in h ...

Top method for dynamically generating a recursive treeview from data fetched from an API

I am currently learning Angular 2 and working on creating an expandable tree-view that pulls data from a potentially large third-party API. The underlying structure of the API is structured like this: - Home (id: 1053) - - Rugby League (id: 1054) - - - Su ...

What is the best way to implement a condition within an ngFor loop in Angular?

I am looking to iterate the user list with a condition. <li *ngFor="let user of users" *ngIf="user.age>25"> {{user.name}} </li> I understand that this code is incorrect. However, I would like to achieve something similar. Is there any way ...

Transforming Bootstrap using Typescript styled components

I have been working on customizing the Navbar in my React app using Typescript's styled components. However, I am facing difficulties in restyling the default styles from Bootstrap that I have copied. Here is an example of the React Bootstrap Navbar c ...

Creating regex to detect the presence of Donorbox EmbedForm in a web page

I am working on creating a Regex rule to validate if a value matches a Donorbox Embed Form. This validation is important to confirm that the user input codes are indeed from Donorbox. Here is an example of a Donorbox EmbedForm: <script src="https: ...

Disable Styling and Override Readonly CSS restrictions

What is the correct approach for customizing material design styling when input fields are disabled? Out of the Box Explore Angular Material Input Examples I managed to achieve my objective using the following CSS, but I am concerned if this is a recomm ...

Issues with manipulating state using TypeScript Discriminated Unions"Incompatibility with setState

Imagine having a unique type structure like the one shown below: export type IEntity = ({ entity: IReport setEntity: (report: IReport) => void } | { entity: ITest setEntity: (test: ITest) => void }); Both the entity and setEntity fun ...

An error occurred while trying to set the property 'IS_CHECK' of an object that is undefined

I'm attempting to create a checkbox that, when selected, should also select everything else. I followed the code example provided in this tutorial for angular 2. However, I encountered an error: "ERROR TypeError: Cannot set property 'IS_CHECK&ap ...

Enhancing Angular HighChartsIs it time to rev

There seems to be an issue with the highchart not redrawing itself when dynamically changing plot options. I have integrated Highcharts into my code as shown below: In the HTML: <highcharts-chart [Highcharts]="Highcharts" [options]="opt ...

I have successfully implemented useLazyQuery in a functional component, but now I am looking to integrate it into a class component. Can you provide guidance on how to achieve

Recently, I encountered an issue with my functional component that contains 3 checkboxes and 1 button. I utilized the useLazyQuery hook to ensure that my query was only sent upon clicking the button. However, a major drawback is that my component re-rend ...

In Ionic 4, a special character is showing up before the form tag

I'm facing a bizarre issue with my Ionic 4 app... a strange character is appearing before the form I tried using Google DevTools, but I couldn't identify how this extra character is being injected before the form If anyone has encountered this ...