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 5.0.0+ contains its own typings instead of @types/webpack #49755

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dl748
Copy link
Contributor

@dl748 dl748 commented Nov 24, 2020

Removing webpack typings.

Unfortunately, this seems to cause problems with other typings that rely on it.

I created a draft for review and discussion

@dl748 dl748 marked this pull request as ready for review November 25, 2020 16:18
@dl748 dl748 requested a review from johnnyreilly as a code owner November 25, 2020 16:18
@typescript-bot
Copy link
Contributor

@dl748 Thank you for submitting this PR!

This is a live comment which I will keep updated.

This PR touches some part of DefinitelyTyped infrastructure, so a DT maintainer will need to review it. This is rare — did you mean to do this?

2 packages in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

Status

  • ✅ No merge conflicts
  • ❌ Continuous integration tests have passed
  • ❌ A DT maintainer needs to approve changes which affect DT infrastructure (notNeededPackages.json)

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 49755,
  "author": "dl748",
  "headCommitAbbrOid": "21cef11",
  "headCommitOid": "21cef11c481dd884d3f434c0d3ed0cd0a44a2966",
  "lastPushDate": "2020-11-24T12:59:30.000Z",
  "lastActivityDate": "2020-11-25T16:18:41.000Z",
  "maintainerBlessed": false,
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": null,
      "kind": "edit",
      "files": [
        {
          "path": "notNeededPackages.json",
          "kind": "infrastructure"
        }
      ],
      "owners": [],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    },
    {
      "name": "appcache-webpack-plugin",
      "kind": "edit",
      "files": [
        {
          "path": "types/appcache-webpack-plugin/package.json",
          "kind": "package-meta-ok"
        }
      ],
      "owners": [
        "peterblazejewicz"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "webpack",
      "kind": "delete",
      "files": [
        {
          "path": "types/webpack/OTHER_FILES.txt",
          "kind": "package-meta",
          "suspect": "couldn't fetch contents"
        },
        {
          "path": "types/webpack/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/webpack/next.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/webpack/package.json",
          "kind": "package-meta",
          "suspect": "couldn't fetch contents"
        },
        {
          "path": "types/webpack/test/index.ts",
          "kind": "test"
        },
        {
          "path": "types/webpack/test/next.ts",
          "kind": "test"
        },
        {
          "path": "types/webpack/tsconfig.json",
          "kind": "package-meta",
          "suspect": "couldn't fetch contents"
        },
        {
          "path": "types/webpack/tslint.json",
          "kind": "package-meta",
          "suspect": "couldn't fetch contents"
        },
        {
          "path": "types/webpack/v3/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/webpack/v3/tsconfig.json",
          "kind": "package-meta",
          "suspect": "couldn't fetch contents"
        },
        {
          "path": "types/webpack/v3/tslint.json",
          "kind": "package-meta",
          "suspect": "couldn't fetch contents"
        },
        {
          "path": "types/webpack/v3/webpack-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "tkqubo",
        "bumbleblym",
        "bcherny",
        "tommytroylin",
        "mohsen1",
        "jcreamer898",
        "alan-agius4",
        "dennispg",
        "christophehurpeau",
        "ZSkycat",
        "johnnyreilly",
        "rwaskiewicz",
        "kuehlein",
        "grgur",
        "rubenspgcavalcante",
        "andersk",
        "ofhouse",
        "danielthank",
        "sasurau4",
        "dionshihk",
        "peterblazejewicz",
        "spamshaker"
      ],
      "addedOwners": [],
      "deletedOwners": [
        "tkqubo",
        "bumbleblym",
        "bcherny",
        "tommytroylin",
        "mohsen1",
        "jcreamer898",
        "alan-agius4",
        "dennispg",
        "christophehurpeau",
        "ZSkycat",
        "johnnyreilly",
        "rwaskiewicz",
        "kuehlein",
        "grgur",
        "rubenspgcavalcante",
        "andersk",
        "ofhouse",
        "danielthank",
        "sasurau4",
        "dionshihk",
        "peterblazejewicz",
        "spamshaker"
      ],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [],
  "ciResult": "fail",
  "ciUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/21cef11c481dd884d3f434c0d3ed0cd0a44a2966/checks?check_suite_id=1553303091"
}

@typescript-bot
Copy link
Contributor

🔔 @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
Copy link
Contributor

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

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

@dl748 dl748 marked this pull request as draft November 25, 2020 16:20
@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?

appcache-webpack-plugin/v1.4

Comparison details for appcache-webpack-plugin/1.4 📊
master #49755 diff
Batch compilation
Memory usage (MiB) 76.3 74.5 -2.3%
Type count 11043 10987 -1%
Assignability cache size 1942 1939 0%
Language service
Samples taken 9 9 0%
Identifiers in tests 9 9 0%
getCompletionsAtPosition
    Mean duration (ms) 381.6 391.4 +2.6%
    Mean CV 9.7% 12.2%
    Worst duration (ms) 445.6 461.2 +3.5%
    Worst identifier comment comment
getQuickInfoAtPosition
    Mean duration (ms) 396.7 396.5 0.0%
    Mean CV 9.8% 9.0%
    Worst duration (ms) 426.1 425.5 -0.1%
    Worst identifier fallback network

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

zip-webpack-plugin/v3.0

Comparison details for zip-webpack-plugin/3.0 📊
master #49755 diff
Batch compilation
Memory usage (MiB) 74.5 73.6 -1.2%
Type count 11052 10996 -1%
Assignability cache size 1945 1942 0%
Language service
Samples taken 29 29 0%
Identifiers in tests 29 29 0%
getCompletionsAtPosition
    Mean duration (ms) 370.9 367.0 -1.1%
    Mean CV 10.0% 9.9%
    Worst duration (ms) 433.6 428.1 -1.3%
    Worst identifier fileOptions fileOptions
getQuickInfoAtPosition
    Mean duration (ms) 387.3 387.3 0.0%
    Mean CV 11.5% 12.5%
    Worst duration (ms) 451.8 444.1 -1.7%
    Worst identifier mtime mode

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 Nov 25, 2020
@ofhouse
Copy link
Contributor

ofhouse commented Nov 25, 2020

I think it is by far to early to remove the types from Webpack v4 because the maintainers are still accepting PRs for it.
Wrote my 2 cents on this topic here: #48803 (comment)

@dl748
Copy link
Contributor Author

dl748 commented Nov 29, 2020

AFAIK, thats not how types works. You mark what version of the package has its own typings, in this case 5.0.0+. Versions under 5 would still use @types/webpack

You can see here https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49755/files#diff-a275c2eae7b8f788a52327e76809026ee1bc5ea614393806c8f3cbab07202621
in the notNeededPackages.json file.

@grgur
Copy link
Contributor

grgur commented Dec 1, 2020

Thank you for owning this! This issue is particularly problematic where plugins still require @types/webpack but developers have upgraded to webpack@^5. Having a clear semver separation is going to be fantastic.

@ofhouse
Copy link
Contributor

ofhouse commented Dec 1, 2020

@dl748 What you propose here, is basically deleting the types/webpack directory from this repository. That is how deprecating types in DefinitelyTyped works.
That means:

To clarify here: I am very aware that Webpack v5 comes bundled with it's own types (In fact Webpack v4 package also already contains types for basic things like configuration).
So we will never release a @types/webpack@5.x.x or add types to this package that are related to Webpack 5.

But the release of Webpack 5 does not automatically mean that Webpack 4 is now deprecated.
In fact, the Webpack team is still accepting PRs for Webpack 4, so when something is changed in Webpack 4 we have no chance to bring those changes back to @types/webpack when we deprecate it too early.

To better understand this issue pls have a look at the actual download stats of @types/webpack on npm: We had 4,424,425 downloads (number still growing) in the last week, so there are still a ton of projects out there that rely on Webpack 4.
That's because @types/webpack is not only used by developers who want their webpack config typed. It is mostly used for development of Webpack plugins and loaders.

Currently authors of plugins and loaders are busy to make their stuff compatible for Webpack 5 API but some of them choose the path to support Webpack 4 & 5 at the same time. For them it can be critical to publish new releases of @types/webpack to support their development (E.g. see #48857).

I know the downside of this approach is that developers that are blindly typing npm i --save webpack @types/webpack end up having webpack@^5 and @types/webpack^4 installed. But when they look at the package.json they always see a semver major version mismatch (5.x.x vs 4.x.x) between these two packages which should indicate that they are not compatible.
And hopefully they google it, find this thread and simply uninstall @types/webpack.

@grgur
Copy link
Contributor

grgur commented Dec 2, 2020

@ofhouse All good points.

The issue I personally ran into was with a couple of plugins that used@types/webpack, but the project uses webpack@5. That caused a couple of issues that required skipLibCheck: true, which isn't a great scenario.

Is there a way to support v4 through DefinitelyTyped and v5 via Webpack? I wonder if there's a simple way out without rewriting definitions.

I agree that dropping types from here would be harmful.

@dl748
Copy link
Contributor Author

dl748 commented Dec 4, 2020

@ofhouse All good points.

The issue I personally ran into was with a couple of plugins that used@types/webpack, but the project uses webpack@5. That caused a couple of issues that required skipLibCheck: true, which isn't a great scenario.

Is there a way to support v4 through DefinitelyTyped and v5 via Webpack? I wonder if there's a simple way out without rewriting definitions.

I agree that dropping types from here would be harmful.

I have the reverse issue, can't update plugin typings to 5.0+ because any import { type } from 'webpack' forcefully pulls in @types/webpack instead of webpack@5 types because @types/webpack still exists in the build system.

Thereby, errors of 'webpack doesn't export that member' and manually deleting @types/webpack fixes the issue. It makes it impossible to update any "@types/my-webpack-plugin" to 5.0

sandersn added a commit that referenced this pull request Mar 12, 2021
Webpack and tapable's newest versions ship their own types, but
webpack@4 still has types on Definitely Typed, as do lots of webpack
plugins. All these plugins still target webpack@4; they cannot target
anything higher while webpack still has types on DT.

However, this causes a problem for people who need to use plugins with
the newest webpack. They get webpack@5 types from webpack directly and
webpack@4 types from DT-typed webpack plugins. These types conflict.

After discussion with some other members of the community, I decided to
add `@types/webpack@5` via a passthrough of webpack@5; index.d.ts just
re-exports the entire module of webpack itself.

I had to do the same for tapable to make webpack compile.

This is *not* a completed PR; I'm opening it for discussion purposes.
Weback and tapable pass individually, but none of their dependents do.

Tasks left to do:

- webpack@5's types appear to require Typescript 3.7; dependents need to
  require it to.
- Upgrade all dependents' usage of webpack to 5.
- Or: manually alias webpack to webpack/v4 for dependents that should
  not update to 5.

I know very little about webpack 4 or 5, so I don't know how big a task
upgrading is. And I don't know whether 5 is backward compatible, so
maybe it's a good thing that old plugins don't compile with 5.

Related:

- #49755, a PR to *remove* webpack typings entirely, which seems bad since it
  prevents bugfixes to webpack@4's types.
sandersn added a commit that referenced this pull request Mar 25, 2021
* Webpack+tapable passthrough newest versions

Webpack and tapable's newest versions ship their own types, but
webpack@4 still has types on Definitely Typed, as do lots of webpack
plugins. All these plugins still target webpack@4; they cannot target
anything higher while webpack still has types on DT.

However, this causes a problem for people who need to use plugins with
the newest webpack. They get webpack@5 types from webpack directly and
webpack@4 types from DT-typed webpack plugins. These types conflict.

After discussion with some other members of the community, I decided to
add `@types/webpack@5` via a passthrough of webpack@5; index.d.ts just
re-exports the entire module of webpack itself.

I had to do the same for tapable to make webpack compile.

This is *not* a completed PR; I'm opening it for discussion purposes.
Weback and tapable pass individually, but none of their dependents do.

Tasks left to do:

- webpack@5's types appear to require Typescript 3.7; dependents need to
  require it to.
- Upgrade all dependents' usage of webpack to 5.
- Or: manually alias webpack to webpack/v4 for dependents that should
  not update to 5.

I know very little about webpack 4 or 5, so I don't know how big a task
upgrading is. And I don't know whether 5 is backward compatible, so
maybe it's a good thing that old plugins don't compile with 5.

Related:

- #49755, a PR to *remove* webpack typings entirely, which seems bad since it
  prevents bugfixes to webpack@4's types.

* Switch first plugin to v4 and fix tapable header

And tslint

* redirect to webpack@4,tapable@1 in tsconfigs

* Add explicit typescript version

* update dependents of dependents
Cyberboss added a commit to tgstation/tgstation-server-webpanel that referenced this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Check Config Changes a module config files Critical package Edits Infrastructure Edits multiple packages Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. The CI failed When GH Actions fails
Projects
Status: Needs Author Action
Development

Successfully merging this pull request may close these issues.

4 participants