Giter Site home page Giter Site logo

atlassian-labs / webpack-deduplication-plugin Goto Github PK

View Code? Open in Web Editor NEW
75.0 6.0 4.0 892 KB

Plugin for webpack that de-duplicates transitive dependencies in yarn and webpack-based projects.

License: Apache License 2.0

JavaScript 100.00%
webpack4 webpack-plugin dependencies

webpack-deduplication-plugin's Introduction

Webpack Deduplication Plugin

Plugin for webpack that de-duplicates transitive dependencies in yarn and webpack-based projects.

Usage

Import it from the package

const { WebpackDeduplicationPlugin } = require('webpack-deduplication-plugin');

And add it to your webpack config:

plugins: [
    new WebpackDeduplicationPlugin({
        cacheDir: cacheDirPath,
        rootPath: rootPath,
    }),
]

where:

  • cacheDirPath - absolute path to the directory where the cache of the duplicates will be stored. Cache is based on the content of yarn.lock file and will be updated with every change. If not provided then the duplicates will be re-generated with every run.
  • rootPath - absolute path to the root of the project. If not provided it will be auto-detected by app-root-path plugin

Development

TBD

Contributions

Contributions to Webpack Deduplication Plugin are welcome! Please see CONTRIBUTING.md for details.

License

Copyright (c) 2020 Atlassian and others. Apache 2.0 licensed, see LICENSE file.


With ❤️ from Atlassian

webpack-deduplication-plugin's People

Contributors

adevnadia avatar dependabot[bot] avatar gorakong avatar internetofsteve avatar marcins avatar obweger avatar randing89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

webpack-deduplication-plugin's Issues

Throwing error with Webpack 5

The plugin is throwing following error with Webpack 5

Error: NormalModuleFactory.beforeResolve is no longer a waterfall hook, but a bailing hook instead. Do not return the passed object, but modify it instead. Returning false will ignore the request and results in no module created.

Removing the return in beforeResolve seems to fix the issue. Not sure if it will break Webpack 4.

diff --git a/node_modules/webpack-deduplication-plugin/build/index.js b/node_modules/webpack-deduplication-plugin/build/index.js
index 083955b..9a62d23 100644
--- a/node_modules/webpack-deduplication-plugin/build/index.js
+++ b/node_modules/webpack-deduplication-plugin/build/index.js
@@ -182,7 +182,7 @@ var WebpackDeduplicationPlugin = /*#__PURE__*/function () {
       var dupVals = Object.values(duplicates);
       compiler.hooks.normalModuleFactory.tap('WebpackDeduplicationPlugin', function (nmf) {
         nmf.hooks.beforeResolve.tap('WebpackDeduplicationPlugin', function (result) {
-          return deduplicate(result, dupVals);
+          deduplicate(result, dupVals);
         });
       });
     }

Does not work in Windows

fast-glob dropped support for backslashes as of 3.0. Since webpack-deduplication-plugin requires fast-glob 3.2.2, this prevents the plugin from working correctly in Windows. No package.json files will ever be globbed, and therefore no duplicates can be identified.

I had to fork the plugin code to fix. Either of the fixes will work:

  1. Ensuring globPath is normalized to forward slashes before calling glob.sync
  2. Using glob with code as-is instead of fast-glob (with the corresponding perf hit)

Deduplication plugin deduping wrong and breaking the webpack build

ERROR in /buildeng/bamboo-agent-home/xml-data/build-dir/CONFMICRO-CFCPB10727-BUILDBRANCH/node_modules/@atlassian/ptc-embeddable-directory/dist/components/TeamElement/TeamElement.js
build	18-Nov-2020 00:54:13	(@atlassian/confluence-frontend-server) $ yarn run -s bundle Module not found: Error: Can't resolve '/buildeng/bamboo-agent-home/xml-data/build-dir/CONFMICRO-CFCPB10727-BUILDBRANCH/node_modules/@atlaskit/avatar-group/node_modules/@atlaskit/avatar-group/dist/esm/index.js' in '/buildeng/bamboo-agent-home/xml-data/build-dir/CONFMICRO-CFCPB10727-BUILDBRANCH/node_modules/@atlassian/ptc-embeddable-directory/dist/components/TeamElement'

Grep result for the yarn.lock:

mdejongh|~/Projects/Atlassian/confluence-frontend on atlaskit-branch-deploy-AFP-2529-qa-branch
± grep 'avatar-group' yarn.lock
    "@atlaskit/avatar-group" "^8.0.0"
"@atlaskit/avatar-group@^7.0.1":
  resolved "https://packages.atlassian.com/api/npm/npm-remote/@atlaskit/avatar-group/-/avatar-group-7.0.1.tgz#5fde6f9863b9819631cc2903b5d1a3dab4498c25"
"@atlaskit/avatar-group@^8.0.0", "@atlaskit/avatar-group@^8.0.11":
  resolved "https://packages.atlassian.com/api/npm/npm-remote/@atlaskit/avatar-group/-/avatar-group-8.0.11.tgz#09893376b91386aed05c17b82cfcb5548bf694a9"
    "@atlaskit/avatar-group" "^8.0.0"
    "@atlaskit/avatar-group" "^8.0.0"
    "@atlaskit/avatar-group" "^8.0.0"
    "@atlaskit/avatar-group" "^8.0.0"
    "@atlaskit/avatar-group" "^8.0.0"
    "@atlaskit/avatar-group" "^7.0.1"
mdejongh@C02XP02SJGH7|~/Projects/Atlassian/confluence-frontend on atlaskit-branch-deploy-AFP-2529-qa-branch
±

The majority of the app depends on [email protected] but dependency @atlassian/ptc-embeddable-directory wants avatar-group@^7.0.1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.