Giter Club home page Giter Club logo

Comments (8)

thtliife avatar thtliife commented on May 20, 2024 2
❯ yarn --version
3.1.1

❯ yarn info webpack-dashboard
└─ webpack-dashboard@npm:3.3.6
   ├─ Instances: 1
   ├─ Version: 3.3.6
   │
   ├─ Exported Binaries
   │  └─ webpack-dashboard
   │
   └─ Dependencies
      ├─ chalk@npm:^4.1.1 → npm:4.1.2
      ├─ commander@npm:^8.0.0 → npm:8.3.0
      ├─ cross-spawn@npm:^7.0.3 → npm:7.0.3
      ├─ filesize@npm:^7.0.0 → npm:7.0.0
      ├─ handlebars@npm:^4.1.2 → npm:4.7.7
      ├─ inspectpack@npm:^4.7.1 → npm:4.7.1
      ├─ neo-blessed@npm:^0.2.0 → npm:0.2.0
      ├─ socket.io-client@npm:^4.1.3 → npm:4.4.1
      └─ socket.io@npm:^4.1.3 → npm:4.4.1

❯ yarn info webpack webpack-cli
├─ webpack-cli@npm:4.9.1
│  ├─ Instances: 1
│  ├─ Version: 4.9.1
│  │
│  ├─ Exported Binaries
│  │  └─ webpack-cli
│  │
│  └─ Dependencies
│     ├─ @discoveryjs/json-ext@npm:^0.5.0 → npm:0.5.6
│     ├─ @webpack-cli/configtest@npm:^1.1.0 → npm:1.1.0
│     ├─ @webpack-cli/info@npm:^1.4.0 → npm:1.4.0
│     ├─ @webpack-cli/serve@npm:^1.6.0 → npm:1.6.0
│     ├─ colorette@npm:^2.0.14 → npm:2.0.16
│     ├─ commander@npm:^7.0.0 → npm:7.2.0
│     ├─ execa@npm:^5.0.0 → npm:5.1.1
│     ├─ fastest-levenshtein@npm:^1.0.12 → npm:1.0.12
│     ├─ import-local@npm:^3.0.2 → npm:3.1.0
│     ├─ interpret@npm:^2.2.0 → npm:2.2.0
│     ├─ rechoir@npm:^0.7.0 → npm:0.7.1
│     └─ webpack-merge@npm:^5.7.3 → npm:5.8.0
│
└─ webpack@npm:5.66.0
   ├─ Instances: 1
   ├─ Version: 5.66.0
   │
   ├─ Exported Binaries
   │  └─ webpack
   │
   └─ Dependencies
      ├─ @types/eslint-scope@npm:^3.7.0 → npm:3.7.3
      ├─ @types/estree@npm:^0.0.50 → npm:0.0.50
      ├─ @webassemblyjs/ast@npm:1.11.1 → npm:1.11.1
      ├─ @webassemblyjs/wasm-edit@npm:1.11.1 → npm:1.11.1
      ├─ @webassemblyjs/wasm-parser@npm:1.11.1 → npm:1.11.1
      ├─ acorn-import-assertions@npm:^1.7.6 → npm:1.8.0
      ├─ acorn@npm:^8.4.1 → npm:8.7.0
      ├─ browserslist@npm:^4.14.5 → npm:4.19.1
      ├─ chrome-trace-event@npm:^1.0.2 → npm:1.0.3
      ├─ enhanced-resolve@npm:^5.8.3 → npm:5.8.3
      ├─ es-module-lexer@npm:^0.9.0 → npm:0.9.3
      ├─ eslint-scope@npm:5.1.1 → npm:5.1.1
      ├─ events@npm:^3.2.0 → npm:3.3.0
      ├─ glob-to-regexp@npm:^0.4.1 → npm:0.4.1
      ├─ graceful-fs@npm:^4.2.9 → npm:4.2.9
      ├─ json-parse-better-errors@npm:^1.0.2 → npm:1.0.2
      ├─ loader-runner@npm:^4.2.0 → npm:4.2.0
      ├─ mime-types@npm:^2.1.27 → npm:2.1.34
      ├─ neo-async@npm:^2.6.2 → npm:2.6.2
      ├─ schema-utils@npm:^3.1.0 → npm:3.1.1
      ├─ tapable@npm:^2.1.1 → npm:2.2.1
      ├─ terser-webpack-plugin@npm:^5.1.3 → npm:5.3.0
      ├─ watchpack@npm:^2.3.1 → npm:2.3.1
      └─ webpack-sources@npm:^3.2.2 → npm:3.2.3

Before PR

[webpack-cli] Failed to load '/Users/vito/repos/@thtliife/dashboard-test/webpack.config.ts' config
[webpack-cli] webpack.config.ts:6:29 - error TS7016: Could not find a declaration file for module 'webpack-dashboard/plugin'. '/Users/vito/repos/@thtliife/dashboard-test/.yarn/__virtual__/webpack-dashboard-virtual-2fa1ddb4b9/0/cache/webpack-dashboard-npm-3.3.6-78688c9e79-55b1bbc6eb.zip/node_modules/webpack-dashboard/plugin/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/webpack-dashboard` if it exists or add a new declaration (.d.ts) file containing `declare module 'webpack-dashboard/plugin';`

6 import DashboardPlugin from 'webpack-dashboard/plugin';
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~

After PR

webpack 5.66.0 compiled successfully in 1284 ms
assets by path *.js 1.38 MiB
  asset main.js 1.38 MiB [emitted] (name: main) 1 related asset
  asset main.2936fce54ae83d322c52.hot-update.js 371 bytes [emitted] [immutable] [hmr] (name: main) 1 related asset
asset ../dist/index.html 301 bytes [emitted]
asset main.2936fce54ae83d322c52.hot-update.json 28 bytes [emitted] [immutable] [hmr]
Entrypoint main 1.38 MiB (1.6 MiB) = main.js 1.38 MiB main.2936fce54ae83d322c52.hot-update.js 371 bytes 2 auxiliary assets
cached modules 1.29 MiB [cached] 50 modules
runtime modules 27.6 KiB 16 modules
webpack 5.66.0 compiled successfully in 86 ms

webpack-dashboard

So everything looking good so far mate :)

from webpack-dashboard.

TranquilMarmot avatar TranquilMarmot commented on May 20, 2024 1

I'm running into this as well using Webpack 4.

I think the issue is that the .d.ts file is in the wrong spot...

Doing:

import DashboardPlugin from 'webpack-dashboard/plugin';

I think it might be looking for a file at node-modules/webpack-dashboard/plugin/index.d.ts.

The file at node-modules/webpack-dashboard/index.d.ts is not being picked up by TypeScript.

from webpack-dashboard.

ryan-roemer avatar ryan-roemer commented on May 20, 2024 1

Confirmed both the (1) location issue and (2) the webpack5 changes. I'm working on a fix. (I've had other plugins need updated types for webpack5).

from webpack-dashboard.

ryan-roemer avatar ryan-roemer commented on May 20, 2024 1

Hi folks! Can anyone experiencing TS errors, try out #341 and see how that goes?

If you're getting errors, can you report your version of webpack and webpack-cli? Thanks!

from webpack-dashboard.

thtliife avatar thtliife commented on May 20, 2024 1

Hi folks! Can anyone experiencing TS errors, try out #341 and see how that goes?

If you're getting errors, can you report your version of webpack and webpack-cli? Thanks!

Im happy to check mate :) will report back in a couple mins

from webpack-dashboard.

justnewbee avatar justnewbee commented on May 20, 2024

another issue, after @ts-ignore 'ed the import part

image

from webpack-dashboard.

ryan-roemer avatar ryan-roemer commented on May 20, 2024

Thanks for reporting! Webpack5 might have changed the type.

We'd accept a typedefs PR in https://github.com/FormidableLabs/webpack-dashboard/blob/master/index.d.ts if you have a fix.

from webpack-dashboard.

thtliife avatar thtliife commented on May 20, 2024

I was getting this issue too, using webpack v5.66.0
to solve the declaration file not found error, I just imported the plugin like below:

import DashboardPlugin from 'webpack-dashboard/plugin';
import 'webpack-dashboard';

That then resulted in the following error:

[webpack-cli] Failed to load '/Users/me/repos/project-name/webpack.config.ts' config
[webpack-cli] webpack.config.ts:50:5 - error TS2322: Type 'DashboardPlugin' is not assignable to type '((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance'.
  Property 'apply' is missing in type 'DashboardPlugin' but required in type 'WebpackPluginInstance'.

50     new DashboardPlugin(),
       ~~~~~~~~~~~~~~~~~~~~~

  .yarn/__virtual__/webpack-virtual-a93fe6ae01/0/cache/webpack-npm-5.66.0-752f35c0ab-5a44664a84.zip/node_modules/webpack/types.d.ts:12229:2
    12229  apply: (compiler: Compiler) => void;
           ~~~~~
    'apply' is declared here.

I solved this by manually declaring the type in my webpack.config.ts file as below:

import { Configuration, Compiler } from 'webpack';
// ... other code here

interface Webpack5DashboardPlugin extends DashboardPlugin {
  apply: (compiler: Compiler) => void;
}

const config: Configuration = {
  // ... existing config
  plugins: [
    new DashboardPlugin() as Webpack5DashboardPlugin,
    // ... other plugins
  ],
  // ... rest of config
}

from webpack-dashboard.

Related Issues (20)

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.