Typescript errors with Webpack 5
See original GitHub issueWebpack 5 (5.0.0-beta.16) does not export Plugin
, which cause type-checking and builds to fail with:
node_modules/nodemon-webpack-plugin/dist/index.d.ts:3:12 - error TS2459: Module '"......./node_modules/webpack/types"' declares 'Plugin' locally, but it is not exported.
3 import { Plugin } from 'webpack';
~~~~~~
node_modules/webpack/types.d.ts:5126:19
5126 declare interface Plugin {
~~~~~~
'Plugin' is declared here.
node_modules/schema-utils/declarations/validate.d.ts:2:34 - error TS2307: Cannot find module 'json-schema'.
2 export type JSONSchema4 = import('json-schema').JSONSchema4;
~~~~~~~~~~~~~
node_modules/webpack/types.d.ts:62:8 - error TS2307: Cannot find module 'estree'.
62 } from "estree";
Related:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:27 (14 by maintainers)
Top Results From Across the Web
Webpack 5 watch not failing on error · Issue #1204 - GitHub
I expect webpack to fail when trying to bundle my files when typescript/ts-loader detects an error. This worked fine so far when I...
Read more >Webpack is not failing on TypeScript error - Stack Overflow
Since I upgraded to version 5, webpack does not fail on a TypeScript error. Here is my scenario: index.ts (entry point):
Read more >TypeScript - webpack
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. In this guide we will learn how to integrate TypeScript with...
Read more >Using webpack with TypeScript - LogRocket Blog
Learn how to use webpack to compile TypeScript to JavaScript and bundle ... LogRocket records console logs, JavaScript errors, stacktraces, ...
Read more >Compiling and bundling TypeScript libraries with Webpack
TypeScript libraries in JavaScript applications. I found that writing library and application code are two pretty different experiences. They serve different ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The typings issue was declared by the WebPack team as a breaking change between v4 and v5.
We have two options:
Second option seems far more reasonable to me.
Will attempt fix in due course.
I’m afraid this has to do with the whole CommonJS/ES6 mismatch, and I’ve documented this in the type definitions:
Basically, you need to choose between CommonJS (
export =
) and ES6 (export default
). If you opt for the latter, than CommonJS scripts will have to import the plugin like this (note.default
):I’ve prioritise the CommonJS export based on a (rather reasonable in my view) assumption that most users don’t have their
webpack.config.js
transpiled.