Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Modernizr just published a beta builder (all client-side), seeing this in a module would be awesome.
http://modernizr.github.com/Modernizr/2.0-beta/
BTW
Why not integrate Modernizr into the module?
Comments
Comment #1
tamasd CreditAttribution: tamasd commentedHow could it be useful for the module? Do you have a use case?
I can't integrate it because of the Drupal.org's CVS repository policy (hosting 3rd party code is strictly prohibited).
Comment #2
LewisNyman CreditAttribution: LewisNyman commentedI think it would be a great idea to integrate the V2 download builder in to Drupal. Other modules could use this as an API to hook in support for HTML5 features.
We are allowed to host third party code in the d.o CVS. You could say that Drupal is build off third party code. The only requirement is that it is GPL licensed.
Moderizr is licenced under the MIT licence. This allows you to re-licence the work as anything we want. Including GPL.
Comment #3
LewisNyman CreditAttribution: LewisNyman commentedI have done some digging and I've found the Modular Build Script JS file here:
http://www.modernizr.com/i/js/builderapp.js
Comment #4
ruplI can see how this would be useful, but it will take quite a bit of work to reproduce this functionality within Drupal's UI, especially because it's client-side and would download to the user's computer instead of the server where it's needed.
If anything, I think it would be more useful to integrate with the command-line builder and write a drush command that builds what a site currently needs, as defined by invoking
hook_modernizr_info()
. Right now the 7.x-3.x branch can ask a Drupal installation what Modernizr tests it needs to include in the build, and link the user to the exact build page. See #1288248-3: [Meta] Develop a Modernizr API for other Drupal modules for more info.This would still be quite a task, because there's no web service that provides command-line builds, so someone would need to set that up. I'm not particularly interested in funding such a service, because the first person to set it up would inevitably be supporting the greater web community, not just Drupal. I asked the Modernizr team if/when they would set such a service up, and the bandwidth cost was essentially the only thing stopping them from doing it.
Comment #5
ruplAfter some preliminary testing, it seems that the code in the Modernizr repo is working very well, albeit a bit out of date. Modernizr stable has been bumped to 2.5.3 but the CLI outputs 2.0.6 builds. I'm trying to figure out how much work it will be to get the builder back in sync with the master branch.
Now that I have this piece working, it won't be difficult to write a drush command that can integrate. Hooray!
There will not be an external service to compliment this feature of the module, but I will provide some instructions to assist with setup on dev environments. It will rely on node.js and npm.
Comment #6
LewisNyman CreditAttribution: LewisNyman commentedHere's an alternative approach, what if the module included all the Modernizr functions inside their own files? Then the builder function becomes as simple as drupal_add_js? Drupal handles the aggregation so it doesn't need to be all in one file.
Comment #7
ruplThat's a very interesting idea, Lewis!
For now I don't think I'll attempt to implement it until Modernizr has a modular builder included with the JS library. For now, I'd say it's much more efficient to rely on the tool that's already available, rather than re-engineering from scratch.
As far as drupal_add_js() goes, I would want to avoid aggregating Modernizr along with other Drupal JS. It's supposed to be small so that it downloads quickly and executes ASAP. Grouping it with other JS will slow it down considerably.
Comment #8
ruplBoom! I checked in a first pass at the drush command to generate custom builds. There is much to improve upon, but it definitely works. Here are instructions as of June 4, 2012. Note: for this section, the words 'node' and 'module' are referring to node.js/npm terms, NOT Drupal terms.
Node.js and npm
First, install node.js and npm (it's not too bad).
Second, clone the Modernizr repository somewhere, checkout
customizr
branch, and go inside the customizr directory:You have to do a little bit of work to get the npm module installed. Edit package.json and change the versions of commander, uglify, and node itself to have greater than or equals signs (
>=
) in front of the version numbers. Here's the package.json that allowed me to install the module:Finally, install the node.js module:
Hooray! You now have a command line tool called 'modernizr' at your disposal.
Drush
The drush command will eventually execute the node.js builder from PHP, but for now it outputs a set of arguments for the modernizr command. Right now it can handle four arguments: extras, tests, groups, and not. Read docs on the command-line builder.
Todos
Add 'type' to the module API, so that tests, extras, and other types of args can be separated to make the drush command more flexible.Update: code is checked in. See example above.Known issues
printshiv
toiepp
in order to test.Comment #9
klonosInteresting stuff! ...perhaps it belongs to (or even deserves) its own submodule(?).
Comment #10
ruplUltimately this will be a simple drush command, so I'd be weary of splitting it out into its own submodule.
As I add more features I'll be mindful of the core module's size, and if some component grows too big I will consider splitting it into a submodule.
Comment #11
ruplAfter another failed attempt to update the CLI builder this feature is postponed until Modernizr 3 is released. I've spoken to the Modernizr team and v3 will be completely modular, making derivative tools like the CLI builder easier to keep current as they update the main lib. At that time, we'll have drush integration ready.
Comment #12
klonosThanx for the update ;)
Comment #13
ruplInteresting development for Modernizr 2: https://github.com/doctyper/grunt-modernizr
It's a grunt tool that scrapes your files for Modernizr classes and assembles a custom build based on the findings. We can integrate with this in the exact same way as I posted in #1030822-8: Modernizr 2 custom builder (client-side for admin UI) because it takes the same basic set of flags. No new code on the Drupal side but I wanted to point out this new integration option.
Comment #14
ruplClosing this issue as I do not want to integrate the client-side builder, but will work toward providing grunt-modernizr integration in #2239291: Integrate with grunt-modernizr