Pull in the Sizzle library dynamically using a submodule and make it part of the jQuery build process.

This commit is contained in:
John Resig 2009-10-26 18:23:31 -04:00
parent bbffc99f7c
commit 81f65ce339
6 changed files with 32 additions and 1022 deletions

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "test/qunit"] [submodule "test/qunit"]
path = test/qunit path = test/qunit
url = git://github.com/jquery/qunit.git url = git://github.com/jquery/qunit.git
[submodule "src/sizzle"]
path = src/sizzle
url = git://github.com/jeresig/sizzle.git

View file

@ -2,7 +2,6 @@ SRC_DIR = src
BUILD_DIR = build BUILD_DIR = build
PREFIX = . PREFIX = .
TEST_DIR = ${PREFIX}/test
DIST_DIR = ${PREFIX}/dist DIST_DIR = ${PREFIX}/dist
BASE_FILES = ${SRC_DIR}/core.js\ BASE_FILES = ${SRC_DIR}/core.js\
@ -33,18 +32,24 @@ MINJAR = java -jar ${BUILD_DIR}/yuicompressor-2.4.2.jar
DATE=`git log -1 | grep Date: | sed 's/[^:]*: *//'` DATE=`git log -1 | grep Date: | sed 's/[^:]*: *//'`
all: jquery test min all: jquery min
@@echo "jQuery build complete." @@echo "jQuery build complete."
${DIST_DIR}: ${DIST_DIR}:
@@mkdir -p ${DIST_DIR} @@mkdir -p ${DIST_DIR}
jquery: ${DIST_DIR} ${JQ} init:
@@echo "Grabbing external dependencies..."
@@git submodule init
@@git submodule update
jquery: ${DIST_DIR} selector ${JQ}
${JQ}: ${MODULES} ${JQ}: ${MODULES}
@@echo "Building" ${JQ} @@echo "Building" ${JQ}
@@mkdir -p ${DIST_DIR} @@mkdir -p ${DIST_DIR}
@@cat ${MODULES} | \ @@cat ${MODULES} | \
sed 's/Date:./&'"${DATE}"'/' | \ sed 's/Date:./&'"${DATE}"'/' | \
${VER} > ${JQ}; ${VER} > ${JQ};
@ -52,6 +57,10 @@ ${JQ}: ${MODULES}
@@echo ${JQ} "Built" @@echo ${JQ} "Built"
@@echo @@echo
selector: init
@@echo "Building selector code from Sizzle"
@@sed '/EXPOSE/r src/sizzle-jquery.js' src/sizzle/sizzle.js > src/selector.js
min: ${JQ_MIN} min: ${JQ_MIN}
${JQ_MIN}: ${JQ} ${JQ_MIN}: ${JQ}
@ -63,13 +72,9 @@ ${JQ_MIN}: ${JQ}
@@echo ${JQ_MIN} "Built" @@echo ${JQ_MIN} "Built"
@@echo @@echo
test: ${JQ}
@@echo "Building Test Suite"
@@echo "Test Suite Built"
@@echo
git submodule init
git submodule update
clean: clean:
@@echo "Removing Distribution directory:" ${DIST_DIR} @@echo "Removing Distribution directory:" ${DIST_DIR}
@@rm -rf ${DIST_DIR} @@rm -rf ${DIST_DIR}
@@echo "Removing built copy of Sizzle"
@@rm src/selector.js

12
README
View file

@ -24,11 +24,14 @@ What you need to build your own jQuery:
How to build your own jQuery: How to build your own jQuery:
In the main directory of the distribution (the one that this file is in), type In the main directory of the distribution (the one that this file is in), type
the following to make all versions of jQuery, the documentation, and the test suite: the following to make all versions of jQuery:
make make
Here are each of the individual items that are buildable from the Makefile. Here are each of the individual items that are buildable from the Makefile.
make init
Pull in all the external dependencies (QUnit, Sizzle) for the project.
make jquery make jquery
The standard, uncompressed, jQuery code. The standard, uncompressed, jQuery code.
Makes: ./dist/jquery.js Makes: ./dist/jquery.js
@ -37,10 +40,9 @@ make min
A compressed version of jQuery (made the YUI Minifier). A compressed version of jQuery (made the YUI Minifier).
Makes: ./dist/jquery.min.js Makes: ./dist/jquery.min.js
make test make selector
Makes sure that the QUnit submodule is properly checked out. Builds the selector library for jQuery from Sizzle.
Open this file in your browser: Makes: ./src/selector.js
./test/index.html
Finally, you can remove all the built files using the command: Finally, you can remove all the built files using the command:
make clean make clean

File diff suppressed because it is too large Load diff

1
src/sizzle Submodule

@ -0,0 +1 @@
Subproject commit 3e97c27d19e18c984a29bfea89fcccadf3544fb3

6
src/sizzle-jquery.js Normal file
View file

@ -0,0 +1,6 @@
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.filters;
jQuery.unique = Sizzle.uniqueSort;
return;