-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.js, Browserify & UMD support #51
Conversation
- add package.json with build deps and server-side deps - move to commonjs dependencies, don't expose globals - change FileAPIReader to be a property of ID3 instead of global (breaking) - switches closure compiler for browserify & uglify, with --standalone (for UMD compatibility) - add ultra-dumb test to just smoke test server side stuff (run with `npm test`) - update README with node.js & UMD usage instructions - bump patch version since we're introducing a breaking change (FileAPIReader access)
Let me know if you need the author changed |
First of all: Holy shit, this is amazing :O! Thank you so much for doing this! I've been working on the next version of this library, with a slightly new API and architecture, it includes exhaustive tests, browser and node support just like you have in this pr. I've done 1/3 of it but still need to take some time to finish it up. In the meanwhile I hope we can push this in. The things that I'm a bit worried with:
Can you update the license field in package.json to Again, really happy with this! @tim-smart thanks for the offer. Wouldn't this be a breaking change for people already using the current one? |
I wouldn’t be too worried about breaking changes, especially if people are using semver correctly
|
…IReader, sed workarounds for closure + browserify
Hey there, added some changes:
*some notes on closure + browserify: TL:DR; The lib can now be compressed by running Details: At first, I went for the "simple" approach of just adding commonjs compilation to closure compiler, via the experimental flags - however, because I'm doing a conditional require and the dependencies are resolved before dead code is stripped, I couldn't figure out how to trick closure in to ignoring the node.js only code paths. Additionally, switching to closure over browserify entirely means we lose the UMD imports, so this library wouldn't work with AMD or other module loaders, which would be a bit of a shame. I tried a few alternative approaches as well, but ultimately went down the route of some sed precompilation to get things where they needed to be, namely taking a non-minified browserify file and forcing the exports to assign to string keys by doing a simple substitution. This is a bit of a hack, but it was the cleanest I could get it without giving up more than a kilobyte. Once that was in, the closure compiler can run on the browserify output, and we get the best of both worlds in terms of weight and compatibility. One last note is that I set the compiled version to be |
Oh, interesting, I didn't know Malte added experimental support for CommonJS modules. I'm fine with always using the same Let me just test this a bit more during the weekend, I've had issues in the past with some minimizers. Btw, the mp3 file you point to, what is the license? I prefer using a Creative Commons Share Alike (CC BY-SA). |
Just tested and everything looks great. Can you add the compiler.jar to the LICENSE file and a link to the origin of the file? |
I finally had the time to make the changes I wanted and merged this to master, thank you very much for this PR! @tim-smart any chance I can publish to npm's id3 then? |
Awesome! Sorry about the radio silence on my end, got caught up with other projects for a bit! Glad to know this was helpful! |
No worries, this PR is awesome! |
Addresses #16, making this module compatible with node.js & browserify builds:
Changeset:
npm test
) (small progress towards Create test suite #22)make dev
) with sourcemaps and no obfuscationCaveats:
npm install --save jesseditson/JavaScript-ID3-Reader#module_loaders
FileAPIReader
is no longer a global. I updated the examples and made this a minor version bump (I'm assuming you're using semver) to avoid any confusion. Otherwise the API is identical.If this looks good, you can run
npm publish
from the root directory after merging this and it will automatically create theid3-reader
package under your name. Alternatively, it looks like the current id3 package on npm is abandoned, and was originally derived from this project anyway - so I'm sure if you can get a hold of @tim-smart he'd be happy to make you the author ofid3
. If that happens you can just change thename
field inpackage.json
and runnpm publish
.Let me know if there's anything I can fix up on this guy!
Jesse