pirelenito / git-revision-webpack-plugin

🏗 Webpack plugin that generates VERSION and COMMITHASH files during build
https://www.npmjs.com/package/git-revision-webpack-plugin
MIT License
358 stars 48 forks source link

Unable to load 4.0 using require() #66

Closed bazineta closed 3 years ago

bazineta commented 3 years ago

After upgrading to 4.0, I can no longer load as per the documentation, i.e., require the library, call new Plugin(). Calling new Plugin.default() does work.

The library implementation has an exports.default, so that's not unexpected. I think you'd want a module.exports there instead, given that you're seemingly still going for CJS compatibility here.

mfurniss commented 3 years ago

After updating to 4.0.0 I'm getting this error

TypeError: GitRevisionPlugin is not a constructor

tschmidtb51 commented 3 years ago

@pirelenito: Same problem here.

Prior99 commented 3 years ago

Same problem here.

pirelenito commented 3 years ago

Thanks for the report. I'll probably have some time this week to fix the issue.

In the meantime, sticking to 3.0.6 is recommended as a workaround.

pirelenito commented 3 years ago

I just pushed a patched version v4.0.1 that fixes the issue by tweaking the build files.

As part of releasing v4 I migrated to https://tsdx.io/ and that bug was an unfortunate consequence that I missed.

If someone is familiar with that tool and wants to contribute a permanent fix, I'll happily take PR submissions. ❤️

tschmidtb51 commented 3 years ago

I still see the error message as described in https://github.com/secvisogram/secvisogram/issues/10#issuecomment-831929359. However, the build seems to work.

Edit: Build works on my machine but not in the GitHub Actions: https://github.com/secvisogram/secvisogram/pull/44/checks?check_run_id=2500698867

pirelenito commented 3 years ago

I'm trying a new approach in #67. Can you try a beta build that I prepared @tschmidtb51 ?

"devDependencies": {
  "git-revision-webpack-plugin": "^5.0.0-1"
}

And change your require statement to:

const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
tschmidtb51 commented 3 years ago

I'm trying a new approach in #67. Can you try a beta build that I prepared @tschmidtb51 ?

I did and it worked locally and in GitHub Actions: https://github.com/secvisogram/secvisogram/pull/46

pirelenito commented 3 years ago

Thank you all for your help! Just released v5.0.0 with the confirmed fix. ❤️