A bad npm pkg
Sometimes you encounter a bad npm package. It’s not bad in terms of functionality - otherwise you might not want to use it. It’s bad in the sense that its setup doesn’t align with npm pkg requirements.
social-share.js to create social share buttons. It works fine using script tags. But it doesn’t when imported/required from node_modules.
In a fine afternoon, I had fun debugging this one. Had the chance to refresh my memories on
node --inspect, webpack loader and bunch of other stuff. Turned out:
social-share.js’s package.json, it has
That files doesn’t exist. It should be
The difference was too small to be spotted from error messages. But how could this bug be written in the first place? It must be that they don’t use it as a npm package.