Skip to content
Permalink
Browse files

Add AMD+CommonJS capabilities to the build script (for modules with l…

…ong unreadable dependency lists)
  • Loading branch information...
timmywil committed Sep 9, 2013
1 parent 38cb6d9 commit 1b3c0c00fa4a9f128e0478e0d010b618517347f4
Showing with 22 additions and 16 deletions.
  1. +8 −0 build/tasks/build.js
  2. +13 −16 src/core.js
  3. +1 −0 src/var/class2type.js
@@ -62,6 +62,14 @@ module.exports = function( grunt ) {
.replace( /define\([^{]*?{/, "" )
.replace( rdefineEnd, "" );

// Remove CommonJS-style require calls
// Keep an ending semicolon
contents = contents
.replace( /\w+ = require\(\s*(")[\w\.\/]+\1\s*\)([,;])/g,
function( all, quote, commaSemicolon ) {
return commaSemicolon === ";" ? ";" : "";
});

// Remove empty definitions
contents = contents
.replace( /define\(\[[^\]]+\]\)[\W\n]+$/, "" );
@@ -1,21 +1,18 @@
define([
"./var/strundefined",
"./var/arr",
"./var/slice",
"./var/concat",
"./var/push",
"./var/indexOf",
// [[Class]] -> type pairs
"./var/class2type",
"./var/toString",
"./var/hasOwn",
"./var/trim",
"./var/rsingleTag",
"./var/support"
], function( strundefined, arr, slice, concat, push, indexOf,
class2type, toString, hasOwn, trim, rsingleTag, support ) {
define(function( require ) {

var
arr = require( "./var/arr" ),
slice = require( "./var/slice" ),
concat = require( "./var/concat" ),
push = require( "./var/push" ),
indexOf = require( "./var/indexOf" ),
class2type = require( "./var/class2type" ),
toString = require( "./var/toString" ),
hasOwn = require( "./var/hasOwn" ),
trim = require( "./var/trim" ),
rsingleTag = require( "./var/rsingleTag" ),
support = require( "./var/support" ),

// A central reference to the root jQuery(document)
rootjQuery,

@@ -1,3 +1,4 @@
define(function() {
// [[Class]] -> type pairs
return {};
});

2 comments on commit 1b3c0c0

@csnover

This comment has been minimized.

Copy link
Member

replied Oct 13, 2013

As mentioned in #jquery-dev CJS-wrapped AMD style is currently spec-optional, not spec-mandatory. This may limit interoperability.

@timmywil

This comment has been minimized.

Copy link
Member Author

replied Oct 13, 2013

As we discussed, I don't have a problem pulling that. It will probably help some use cases anyway, such as support for loaders that don't incorporate CJS-AMD and building with r.js without doing a custom build first.

Please sign in to comment.
You can’t perform that action at this time.