Closed AndrewRayCode closed 7 years ago
Temporarily put in NPM under my own namespace https://www.npmjs.com/package/meshline-andrewray
My main problem with publishing to npm is making the library work with require/commonjs/es6 modules/whatever is being used at the moment. Have you done all that work, or just published the library? And if you have, how?
The above published version works correctly with modules (which is why I published it! 😄 ). One way to do it is set three as a peerDependnecy and require() it in the src. You can see the changes I made (note it's all on the "npm" branch):
https://github.com/AndrewRayCode/THREE.MeshLine/blob/npm/src/THREE.MeshLine.js
Basically don't rely on global variables like THREE, and definitely don't modify global variables!
After installing it's easy to require in my project:
import { MeshLine, MeshLineMaterial, } from 'meshline-andrewray';
Right. But then the library can't be used with
You set up a separate build step to build the script version, with three shimmed as global, and make that script available to download. That way both parties (people who want to use it in modern JS builds, and people who want to use script tags) can have their cake and eat it too.
That's what I do with https://github.com/AndrewRayCode/easing-utils for example.
The whole idea of keeping a Githubissues.
So package can work in modern JS builds