HumanInput
HumanInput copied to clipboard
__VERSION__ undefined when import from node_modules
- Simple import with webpack build return error in subj
import HumanInput from 'humaninput' const hi = new HumanInput(window) hi.on('a', () => console.log(12345))
- U r using webpack DefinePlugin for defining
__VERSION__
- main in package.json reference to lib/humaninput-full.js, where no
__VERSION__
- In dist/humaninput-1.1.12.full.js all is ok
Any suggestions on how to fix this? Also, I'm not sure how to test it either. I thought node used requirejs and didn't support native ES6 modules yet?
1 way (simple and fast)
you can reference in package.json
to dist/humaninput-full.min.js
2 way
Don't use VERSION from package.json (define const by yourself) or dont use VERSION at all in code
3 way (insecure)
Import package.json and use VERSION realtime
4 way (the best)! :)
Reconfigure ur make scripts for Development version to inject VERSION variable as we see in production code:
_this.VERSION = "1.1.12";
Any resolution on this?
import HumanInput from 'humaninput/dist/humaninput-full.min';
isn't ideal.
OK I'm still trying to understand this issue and I'm not sure what I need to change. @lokhmakov provided four ways but that's four things I don't understand. "You can reference in package.json"? What does that mean? Change the main
variable?
Also, the Makefile already injects the version variable... So obviously it's not doing it in the way you suggest.
Can someone just provide a pull request?
Any news ?
would be interested as well