package-self
v1.1.1
Published
Bundle and move the current package into node_modules
Downloads
448
Readme
package-self
The common mistake for any library is quite simple, but hard to spot.
As a library creator you are testing you library NOT as a library.
Usually - one will run tests against /src folder. Usually - no one will test how final customer will use and consume your library.
This includes:
- Your package was broken on build
- Typing, you provided, is wrong
- Babel magic wont work
- You forget to write down a new file into your package.json
- .....
Solution
npm install package-self
npm run package-self
This will install a package as local dependency, next you can use in in your test
Before
import myFunction from '../src/index.js'
declare('lets test it!'....)
You should not test yourself in as your self.
After
import myFunction from 'myLibrary'
declare('lets test it!'....)
Not you can test yourself as your final user will use you.
Hint
Not all tests could and should be run using the real
bundle code.
But you shall test your public API using the code, you will ship to a customer, not local sources.
PS
As we test this library.
PPS: Inspired by React tooling bloppost, also some code has origins from that article.
Licence
MIT