Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webpack-bundle-analyzer] webpack@5 compatibility #48857

Merged

Conversation

kryops
Copy link
Contributor

@kryops kryops commented Oct 16, 2020

Fixes #48807

This is a bit of a tricky one: webpack@5's own types declare a WebpackPluginInstance interface, while the webpack@4 types / @types/webpack maintained here have an abstract Plugin class, which is used by type definitions for webpack plugins. There are plans to extend webpack@5's own types and maybe add a Plugin alias there (see webpack/webpack#11630 and webpack/webpack#11698), but they are not in yet.

I tried it the other way around and added a WebpackPluginInstance interface to the webpack@4 types defined here, which makes the webpack-bundle-analyzer types compatible with both @types/webpack and webpack@5 at its current state.

Asking the maintainers of @types/webpack (who the Bot will hopefully ping): Do you think this is ok or should we rather wait until webpack aligns their own types with the existing ecosystem?

Same goes with the Stats options, which are currently defined as any in webpack@5: I copied them into the plugin's type definition for now. What should plugin type definitions do with types that webpack@5 currently does not offer or export?

Did other webpack plugin definitions already add webpack@5 compatibility or is this the first attempt?


Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test YOUR_PACKAGE_NAME.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

@typescript-bot typescript-bot added Critical package Edits multiple packages Author is Owner The author of this PR is a listed owner of the package. labels Oct 16, 2020
@typescript-bot typescript-bot added this to Waiting for Code Reviews in New Pull Request Status Board Oct 16, 2020
@typescript-bot
Copy link
Contributor

typescript-bot commented Oct 16, 2020

@kryops Thank you for submitting this PR!

This is a live comment which I will keep updated.

2 packages in this PR

Code Reviews

This PR can be merged once it's reviewed.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ An owner or a DT maintainer needs to approve changes which affect more than one package

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 48857,
  "author": "kryops",
  "owners": [
    "kryops",
    "VladimirGrenaderov",
    "maxbogus",
    "peterblazejewicz",
    "tkqubo",
    "bumbleblym",
    "bcherny",
    "tommytroylin",
    "mohsen1",
    "jcreamer898",
    "alan-agius4",
    "dennispg",
    "christophehurpeau",
    "ZSkycat",
    "johnnyreilly",
    "rwaskiewicz",
    "kuehlein",
    "grgur",
    "rubenspgcavalcante",
    "andersk",
    "ofhouse",
    "danielthank",
    "sasurau4",
    "dionshihk",
    "spamshaker"
  ],
  "dangerLevel": "MultiplePackagesEdited",
  "headCommitAbbrOid": "ceb69de",
  "headCommitOid": "ceb69de4d181b5663f253092c8a1f35f9ef3294d",
  "mergeIsRequested": true,
  "stalenessInDays": 0,
  "lastPushDate": "2020-10-16T17:08:08.000Z",
  "lastCommentDate": "2020-10-20T15:09:29.000Z",
  "maintainerBlessed": true,
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48857/files",
  "hasMergeConflict": false,
  "authorIsOwner": true,
  "isFirstContribution": false,
  "popularityLevel": "Critical",
  "newPackages": [],
  "packages": [
    "webpack-bundle-analyzer",
    "webpack"
  ],
  "files": [
    {
      "path": "types/webpack-bundle-analyzer/index.d.ts",
      "kind": "definition",
      "package": "webpack-bundle-analyzer"
    },
    {
      "path": "types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts",
      "kind": "test",
      "package": "webpack-bundle-analyzer"
    },
    {
      "path": "types/webpack/index.d.ts",
      "kind": "definition",
      "package": "webpack"
    }
  ],
  "hasDismissedReview": false,
  "ciResult": "pass",
  "lastReviewDate": "2020-10-16T18:01:54.000Z",
  "firstApprovalDate": "2020-10-16T18:01:54.000Z",
  "reviewersWithStaleReviews": [],
  "approvalFlags": 2,
  "isChangesRequested": false
}

@typescript-bot
Copy link
Contributor

🔔 @VladimirGrenaderov @maxbogus @peterblazejewicz @tkqubo @bumbleblym @bcherny @tommytroylin @mohsen1 @jcreamer898 @alan-agius4 @dennispg @christophehurpeau @ZSkycat @johnnyreilly @rwaskiewicz @kuehlein @grgur @rubenspgcavalcante @andersk @ofhouse @danielthank @sasurau4 @dionshihk @spamshaker — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Oct 16, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Oct 16, 2020
@typescript-bot
Copy link
Contributor

@kryops The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@kryops
Copy link
Contributor Author

kryops commented Oct 16, 2020

Mentioning other webpack related definition authors to raise awareness so we're not all trying to solve the same problem at the same time. Sorry for the spam, please unsubscribe if this is irrelevant for you:

@AGenson @andersk @AviVahl @bahlo @blaise-io @bumbleblym @ChaosinaCan @danpintara @Danscho @davecardwell @deevus @dsifford @dublicator @e-cloud @flying-sheep @FranklinWhale @garbetjie @Hotell @huan086 @iclanton @inglec-arista @j-f1 @JounQin @JuanJoseGonGi @karol-majewski @katyo @kgroat @maestroh @malj @maxbogus @monsonjeremy @mtraynham @nhardy @odnamrataizem @pd4d10 @peterblazejewicz @pine @playma256 @r3nya @remcohaszing @rynclark @Seally @skovy @tkqubo @use-strict @vajkayrene @VladimirGrenaderov @woitechen

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Oct 16, 2020
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Oct 16, 2020
@danger-public
Copy link

Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files.
The check for missing properties isn't always right, so take this list as advice, not a requirement.

webpack-bundle-analyzer (unpkg)

was missing the following properties:

  1. start

webpack (unpkg)

was missing the following properties:

  1. WebpackOptionsDefaulter
  2. WebpackOptionsApply
  3. NodeEnvironmentPlugin
  4. validate
  5. validateSchema
as well as these 6 other properties...

WebpackOptionsValidationError, dependencies, web, webworker, node, util

Generated by 🚫 dangerJS against ceb69de

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Oct 16, 2020
@ofhouse
Copy link
Contributor

ofhouse commented Oct 16, 2020

Hi, @types/webpack maintainer here,
Since it only adds an additional export here I am completely fine with this addition.

Most of the exported names came from a time (webpack@2.x.x) where there were no types or annotation in the webpack repo itself.
So the authors picked names that made sense to them at the time but they were never renamed when the webpack authors began to annotate the repo itself and gave them other names.
So it's not uncommon to find type names here that are different from the annotations available in webpack itself.

Changing all the names now makes no sense since this typings will be deprecated eventually. But when you find something that makes the upgrade to webpack@5.x.x easier and is a non-breaking change then you are welcome to add them.

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Oct 16, 2020
@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

webpack-bundle-analyzer/v*

Comparison details for webpack-bundle-analyzer/* 📊
master #48857 diff
Batch compilation
Memory usage (MiB) 77.4 78.3 +1.1%
Type count 11042 11063 0%
Assignability cache size 1944 1945 0%
Language service
Samples taken 28 30 +7%
Identifiers in tests 28 30 +7%
getCompletionsAtPosition
    Mean duration (ms) 463.9 466.2 +0.5%
    Mean CV 11.0% 11.1%
    Worst duration (ms) 543.7 561.0 +3.2%
    Worst identifier openAnalyzer excludeAssets
getQuickInfoAtPosition
    Mean duration (ms) 456.2 463.1 +1.5%
    Mean CV 8.7% 9.6% +10.4%
    Worst duration (ms) 536.3 595.7 +11.1%
    Worst identifier generateStatsFile source

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

webpack/v*

Comparison details for webpack/* 📊
master #48857 diff
Batch compilation
Memory usage (MiB) 74.0 82.7 +11.7%
Type count 12445 12450 0%
Assignability cache size 2645 2646 0%
Language service
Samples taken 1588 1588 0%
Identifiers in tests 1588 1588 0%
getCompletionsAtPosition
    Mean duration (ms) 447.3 449.5 +0.5%
    Mean CV 6.0% 5.8%
    Worst duration (ms) 545.2 558.5 +2.4%
    Worst identifier compilation columns
getQuickInfoAtPosition
    Mean duration (ms) 455.5 459.0 +0.8%
    Mean CV 7.6% 7.8% +3.0%
    Worst duration (ms) 577.8 558.4 -3.4%
    Worst identifier module columns

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Oct 16, 2020
@elibarzilay elibarzilay moved this from Needs Maintainer Review to Waiting for Author to Merge in New Pull Request Status Board Oct 20, 2020
@typescript-bot typescript-bot added the Self Merge This PR can now be self-merged by the PR author or an owner label Oct 20, 2020
@kryops
Copy link
Contributor Author

kryops commented Oct 20, 2020

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Oct 20, 2020
@typescript-bot typescript-bot merged commit b41d491 into DefinitelyTyped:master Oct 20, 2020
@typescript-bot
Copy link
Contributor

I just published @types/webpack@4.41.23 to npm.

@typescript-bot
Copy link
Contributor

I just published @types/webpack-bundle-analyzer@3.9.0 to npm.

@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Oct 20, 2020
@peterblazejewicz
Copy link
Member

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author is Owner The author of this PR is a listed owner of the package. Critical package Edits multiple packages Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[@types/webpack-bundle-analyzer] Support for webpack 5
5 participants