]> source.dussan.org Git - jquery.git/commitdiff
Add AMD+CommonJS capabilities to the build script (for modules with long unreadable...
authorTimmy Willison <timmywillisn@gmail.com>
Mon, 9 Sep 2013 13:50:12 +0000 (09:50 -0400)
committerTimmy Willison <timmywillisn@gmail.com>
Mon, 9 Sep 2013 13:50:12 +0000 (09:50 -0400)
build/tasks/build.js
src/core.js
src/var/class2type.js

index 9f4f429ea9215ca3193913a0291e2031c4979dce..3992d284bd4ff45c51fc43cbd0cd23ba808b1d02 100644 (file)
@@ -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]+$/, "" );
index ef5df4f65532e7eccbb549be560dccd486f7de20..c95f6f3863ae0112bc00f04afed9d7368721060f 100644 (file)
@@ -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,
 
index 52f2d38a6b1d9f0add437d39419c863c16454157..e674c3ba651c6ee6a6da0a4457cf705df5157440 100644 (file)
@@ -1,3 +1,4 @@
 define(function() {
+       // [[Class]] -> type pairs
        return {};
 });