HumanInput icon indicating copy to clipboard operation
HumanInput copied to clipboard

__VERSION__ undefined when import from node_modules

Open lokhmakov opened this issue 8 years ago • 6 comments

  1. Simple import with webpack build return error in subj import HumanInput from 'humaninput' const hi = new HumanInput(window) hi.on('a', () => console.log(12345))
  2. U r using webpack DefinePlugin for defining __VERSION__
  3. main in package.json reference to lib/humaninput-full.js, where no __VERSION__
  4. In dist/humaninput-1.1.12.full.js all is ok

lokhmakov avatar Aug 19 '16 18:08 lokhmakov

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?

liftoff avatar Aug 26 '16 15:08 liftoff

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";

lokhmakov avatar Aug 26 '16 15:08 lokhmakov

Any resolution on this?

import HumanInput from 'humaninput/dist/humaninput-full.min'; isn't ideal.

skoch avatar Jan 04 '17 16:01 skoch

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?

liftoff avatar Aug 20 '17 02:08 liftoff

Any news ?

Septaris avatar May 13 '18 13:05 Septaris

would be interested as well

marwie avatar May 29 '18 13:05 marwie