-
Notifications
You must be signed in to change notification settings - Fork 25
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
Consider to use musical.js as a dependency #99
Comments
Agree to this, it would help for the readability to split the different parts in seperate files. |
Of course, just use browserify or any other bundler like webpack or rollup |
musicaljs itself use this strategy already since my pull request was merged. |
Hi Anton, by the way, I'd love for jquery-turtle.js to also use browserify
David On Tue, Jan 12, 2016 at 4:30 PM, Anton Wilhelm [email protected]
|
I took a closure look at the current implementation and some steps are required to make it work. @timaschew @davidbau |
markus - for example use what instead of jQuery? I was thinking that it would be nice to use browserify to assemble That's because, for educational reasons, I'd like student to have jQuery $ I think this is a common desire, and it looks like there is a package to do David On Sun, Jan 17, 2016 at 5:19 AM, Markus Bordihn [email protected]
|
@davidbau If you only want to use browserify to combine the JavaScripts you could also use the Closure Compiler without the need of having all code "nodejs" compatible. It is also possible to install the Closure Compiler over npm so the setup would be easy. But in the end its your decision if you want to use the nodejs way or an more general way. ;) |
Yes, that's true. I was not sure about that, because this has some impact, but of course this is the the way how to do it.
Of course it's working, see here an online demo: http://requirebin.com/?gist=2378b26f6453d37f4bc6
I'm -1 for that, because tests, especially unit test and even headless browser tests, can't be run then anymore, because they need nodejs. Dealing with dependencies like jquery etc. is sometimes tricky. It depends on what this library (jquery-turtle) should be. Should it be just a library which can't be used standalone? Or are there some standalone use cases? But if you decide to support also AMD or none module system (just use window/global pollution) then you need a bundler and you need to bundle your library in the Universal Module Definition (UMD) style. But keep in mind CommonJS is the de facto standard while ES6 Module System will be implemented by the browsers in the next months/years. AMD is outdated and global pollution is discouraged. If you want provide jquery-turtle as a standalone version as well (for instance to show some examples in a simple HTML page) then you also need to bundle a standalone file. (In that case you don't need any UMD) So in that case you can just provide an additionally standalone file (in most cases in a dist directory, where also a minified file is located) alongside with the CommonJS file.
This is the description of the module:
This is totally the opposite what I wrote above. It doesn't make sense for me. Either let bundle the dependencies by the enduser or provide a standalone and bundle everything. This browserify plugin is needed if you want to do a mix of both and that's the reason why it doesn't make sense for me. |
I created the first step for this. Please check my pull request is fine for everyone ? If it is fine, we could go to the second step and adding musical.js as dependency. |
@timaschew |
@timaschew writes: Should it be just a library which can't be used standalone? Or are there some standalone use cases? There are two important use-cases today: AMD is not as important right now because it is complex and it's going away, and ES6 modules aren't supported by browsers yet (and have a bit of a while to go still). But I think it's important to support the script-src use case. |
I don't understand the two cases completely, I try to guess what you meant. 2 1
So there is a precondition that jquery is available in the global scope. |
Okay, I was wrong, seems to be a valid use case for jquery BTW: I would recommend to use the officially mentioned plugin for shimming modules: https://github.com/substack/browserify-handbook#browserify-shim |
Thanks, already done in #104. |
Yes.
Yes. We agree on the two important use cases. Thanks for clarifying. |
I just saw that the code from musical.js is just copied into this repo https://github.com/PencilCode/jquery-turtle/blob/master/jquery-turtle.js#L3865
Why not use musical.js as a dependecy?
It can be already installed with npm via GitHub endpoint with this command:
npm i PencilCode/musical.js --save
Then just
require('musical.js')
or any other way, but this is the common way to do it.The text was updated successfully, but these errors were encountered: