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

WebpackBuildNotifierPlugin is not a constructor #39

Closed
muuvmuuv opened this issue Apr 15, 2019 · 9 comments
Closed

WebpackBuildNotifierPlugin is not a constructor #39

muuvmuuv opened this issue Apr 15, 2019 · 9 comments

Comments

@muuvmuuv
Copy link

When running webpack with ts-node (webpack.config.ts) I get this error:

      new BuildNotifier({
      ^
TypeError: webpack_build_notifier_1.WebpackBuildNotifierPlugin is not a constructor

In a basic JS node application everything seems fine. Maybe this is because webpack-build-notifier in not a class?

I import it with import { WebpackBuildNotifierPlugin as BuildNotifier } from 'webpack-build-notifier'.

If it is because it is not a class, it would be great if someone would rewrite it to a class.
Here is an example of a good TypeScript written webpack plugin: https://github.com/johnagan/clean-webpack-plugin/blob/master/src/clean-webpack-plugin.ts

@RoccoC
Copy link
Owner

RoccoC commented Apr 16, 2019

Can you try changing the import to:

import BuildNotifier from 'webpack-build-notifier';

@muuvmuuv
Copy link
Author

This was the method I used before, but now it seems like it does not work anymore...

Module '"..../node_modules/webpack-build-notifier/index"' has no default export. ts(1192)

RoccoC added a commit that referenced this issue Apr 16, 2019
@RoccoC
Copy link
Owner

RoccoC commented Apr 16, 2019

Ah, looks like there was no default export in the TS definition. Can you please upgrade to 0.1.32 and try again please?

@muuvmuuv
Copy link
Author

Nope, still getting this error above. You can have a look at my webpack file here: https://github.com/muuvmuuv/vscode-sundial/blob/master/webpack.config.ts.off

RoccoC added a commit that referenced this issue Apr 16, 2019
@RoccoC
Copy link
Owner

RoccoC commented Apr 16, 2019

OK -- found that the TS definition implied that this plugin is exported as a default ES6 export, which isn't the case (it's currently a commonJS module). I corrected the definition, but now you will need to upgrade to version 1.0.0 and change your import to import * as WebpackBuildNotifierPlugin from 'webpack-build-notifier'.

Let me know how it goes!

@muuvmuuv
Copy link
Author

@RoccoC did u pushed the version to NPM? I get no update. np. I will add it manually in my node_modules for testing

@muuvmuuv
Copy link
Author

Yes, copied index.d.ts and index.js content into my node_modules and it worked! Thanks :)

@muuvmuuv
Copy link
Author

Nevermind, I forgot to do npm i webpack-build-notifier@latest..

@RoccoC
Copy link
Owner

RoccoC commented Apr 17, 2019

Glad it worked out! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants