Skip to content

Webpack puts jQuery twice in the bundle #340

@lorthirk

Description

@lorthirk

Hi all. I'm trying to use Webpack to bundle an application with Angular-Patternfly. It seems that jQuery is loaded twice because it looks like the angular-patternfly module requires a form of "peer dependency" for patternfly. Here's the node_modules/angular-patternfly/index.js:

require('angular');
require('angular-animate');
require('angular-sanitize');
require('angular-ui-bootstrap');
require('lodash');
require('../patternfly/dist/js/patternfly.min');
require('./dist/angular-patternfly');
module.exports = 'angular-patternfly';

And here's the webpack graph's JSON file (by the way, in order to make Webpack find the correct patternfly module I had to npm i patternfly, which seems kinda weird since angular-patternfly already brings it in as a dependency). You can see the graph uploading that file in the Webpack's analyze tool.

Then, in the node_modules/angular-patternfly/index.js file, I removed the leading ../ from the patternfly entry, so that it would bring in its own dependency, just like the other modules, and indeed it loads jQuery correctly only once (again, here's the graph's JSON file for the Webpack analyse tool).

So, is there any reason why Angular-Patternfly doesn't require its own dependency, but rather a peer one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions