What is the purpose behind webpack compiling global.js?

As I dive into the world of webpack, my initial build unearthed an unexpected default file in the output (index 1):

build.js  222 kB       0  [emitted]  main
   [1] (webpack)/buildin/global.js 509 bytes {0} [built]
   [2] ./source/scripts/main.js 105 bytes {0} [built]
    + 4 hidden modules

What is the purpose of this file being included? I can't seem to identify any dependencies in my codebase that would justify the significant amount of code present in my build.js file. Originally anticipating just a few lines of code in the output, I was surprised to find approximately 8000 lines.

Upon further observation, I noticed that some other projects do not exhibit this file in the output. Is it truly indispensable? Surprisingly, I couldn't locate any reference to it in the documentation.

My webpack.config.js file for context:

'use strict';

module.exports = {
    entry: './source/scripts/main.js',
    output: {
        path: __dirname + '/dist',
        filename: 'build.js'
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/
            }
        ]
    }
}

Answer №1

I encountered a similar issue where I discovered that I mistakenly imported a file from the node_modules directory.

Here's the situation in typescript:

import Util from 'Util';

should have actually been:

import Util from './Util';

The first import statement fetched 'Util' from node_modules instead of my local file. Despite having 'exclude: /node_modules/' in my tsconfig file, the issue persisted. It might be helpful for webpack to issue a warning when importing excluded items.

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

Tips for Properly Positioning Floating Pop-Up Messages Using CSS and jQuery

I was experimenting with adding a button that triggers a popup message to my website. I followed a coding tutorial using jQuery and CSS, which looks like this: Javascript : !function (v) { v.fn.floatingWhatsApp = function (e) {...} }(jQuery); CSS : .fl ...

The module build for vuejs/eslint-plugin-vue failed due to a missing 'eslint' module

I am encountering an issue while trying to run my nuxt app. Whenever I execute npm run dev, I receive the following error message: Module build failed (from ./node_modules/eslint-loader/dist/cjs.js): Error: Cannot find module 'eslint'. Despite at ...

What exactly comprises an HTTP Parameter Pollution attack within the context of Node.js and Express.js?

I came across this information on https://www.npmjs.com/package/hpp According to the source, "Express populates http request parameters with the same name in an array. An attacker can manipulate request parameters to exploit this vulnerability." I am cur ...

Utilizing Angular routing in HTML5 mode within a Node.js environment

While I've come across other solutions to this problem, they all seem to have drawbacks. One option leads to a redirect, which could be disastrous for my front-end application that relies on Mixpanel. A double-load of Mixpanel results in a Maximum Ca ...

Unable to locate the value of the query string

I need help finding the query string value for the URL www.example.com/product?id=23 This is the code I am using: let myApp = angular.module('myApp', []); myApp.controller('test', ['$scope', '$location', '$ ...

What is the best way to transfer data from a custom method and use it in another method within my constructor function in Javascript?

As I pondered a suitable example, I devised a constructor function centered around precious metals. This function accepts the type of metal and its weight as parameters. Within this constructor, there are two methods: one to verify if the precious metal (g ...

Issue with JSONP request in jQuery/AJAX

I am currently attempting to make a request to a different site, which requires authentication through a cookie. Oddly enough, when I try making the call like this : $.getJSON(url + '?', function(data){ alert(data); }); The HTTP headers do ...

Ways to retrieve the locale parameter from the URL in Next Js

For my Next Js application, I've successfully implemented multi language support using the next-i18next module. Everything is working smoothly. Below is the code for my NabBar component: const NavBar = ({...props}) => { const router = useRouter( ...

Passing Object Data from Child to Parent Component in React and Leveraging its Functionality

After performing a date calculation, I stored the values of year, month, and day in an object. Now, my goal is to send this object to the parent component App.js, and then pass that data to another child component named Modal.js as a prop. I want to displa ...

Obtain a unique HTML ID dynamically with Selenium and VBA

I am currently working on automating a web form using Selenium and VBA. The form includes a search box that generates an autogenerated list when a value is entered. While I can successfully input a value into the search box and trigger the javascript to cr ...

Encountering errors preventing the utilization of helpers in fancybox2-rails gem

I've been struggling to implement fancybox2 in my RoR app. I've attempted using the gem and manually adding the files to my assets directory, but I'm having issues with the helpers. Currently, the thumb images generated by the helper are no ...

Arrange the columns in Angular Material Table in various directions

Is there a way to sort all columns in an Angular material table by descending order, while keeping the active column sorted in ascending order? I have been trying to achieve this using the code below: @ViewChild(MatSort) sort: MatSort; <table matSort ...

Ways to update the DOM following modifications to a data attribute

I'm currently working on a small CMS system that handles translations for static pages in multiple languages. The system refreshes and loads translations dynamically, but I've encountered some bugs that are proving difficult to resolve. One issue ...

What is the interaction between Vue's v-model and the update:modelValue directive, and how can we customize the default behavior to prevent it from

Could someone provide an explanation of the usage of v-model with :modelValue and update:modelValue? What happens when both are used together? In the code snippet below, a component is shown: <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/3. ...

Coat the div with a uniform shade of pure white

I need assistance on applying a solid white background color to hide the text behind it. For better understanding, I have attached a screenshot as a reference. https://i.stack.imgur.com/f8Qd9.png The issue arises when I click on the dropdown in the heade ...

Returning to the previous state in AngularJS when unchecking a checkbox

I'm a beginner when it comes to using angularjs HTML File: <div class='col-md-2 searchdisplay-col1' ng-controller="amenitiesController" style="margin-top:20px"> <h4>Amenities</h4> <label ng-repeat="facilityName ...

Tips for utilizing jQuery to identify an image that is being hovered on?

Concept My goal is to create an effect where a user hovers over an image and a transparent overlay div appears on top of it. This overlay div starts with a height of 0px and should increase to half of the image height upon hover. The hover functionality ...

Tips for passing a function and an object to a functional component in React

I am struggling with TypeScript and React, so please provide clear instructions. Thank you in advance for your help! My current challenge involves passing both a function and an object to a component. Let's take a look at my component called WordIte ...

What is the best way to incorporate variables into the useState hook in React?

I want to create multiple useState hooks based on the length of the userInputs array. The naming convention should be userInput0, userInput1, userInput2,...userInputN. However, using "const [userInput+index.toString(), setUserInput] = useState('' ...

Javascript code requires server to have default text field values

Based on the choice made by a user, a text field box will either remain concealed or revealed: $("#aForm").on("change", function() { if ($(this).val() == "a") $("#textField").hide(); else $("#textField").show(); }); The issue arises when the ...