Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
997da311
Commit
997da311
authored
May 22, 2013
by
Michał Gołębiowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #13793. Correct source map generation bugs. Close gh-1275.
parent
a2cd89a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
6 deletions
+50
-6
Gruntfile.js
Gruntfile.js
+50
-6
No files found.
Gruntfile.js
View file @
997da311
...
@@ -111,11 +111,12 @@ module.exports = function( grunt ) {
...
@@ -111,11 +111,12 @@ module.exports = function( grunt ) {
"dist/jquery.pre-min.js"
:
[
"dist/jquery.js"
]
"dist/jquery.pre-min.js"
:
[
"dist/jquery.js"
]
},
},
options
:
{
options
:
{
banner
:
"/*! jQuery v<%= pkg.version %> | "
+
banner
:
"
\n\n\n\n\n\n\n\n\n\n
"
+
// banner line size must be preserved
"/*! jQuery v<%= pkg.version %> | "
+
"(c) 2005, 2013 jQuery Foundation, Inc. | "
+
"(c) 2005, 2013 jQuery Foundation, Inc. | "
+
"jquery.org/license
\n
"
+
"jquery.org/license
\n
"
+
"//@ sourceMappingURL=jquery.min.map
\n
"
+
"//@ sourceMappingURL=jquery.min.map
\n
"
+
"*/"
"*/
\n
"
}
}
}
}
},
},
...
@@ -145,6 +146,17 @@ module.exports = function( grunt ) {
...
@@ -145,6 +146,17 @@ module.exports = function( grunt ) {
}
}
}
}
}
}
},
"post-uglify"
:
{
all
:
{
files
:
{
"dist/jquery.min.map.tmp"
:
[
"dist/jquery.min.map"
],
"dist/jquery.min.js.tmp"
:
[
"dist/jquery.min.js"
]
},
options
:
{
tempFiles
:
[
"dist/jquery.min.map.tmp"
,
"dist/jquery.min.js.tmp"
,
"dist/jquery.pre-min.js"
]
}
}
}
}
});
});
...
@@ -436,7 +448,7 @@ module.exports = function( grunt ) {
...
@@ -436,7 +448,7 @@ module.exports = function( grunt ) {
// Check for stored destination paths
// Check for stored destination paths
// ( set in dist/.destination.json )
// ( set in dist/.destination.json )
stored
=
Object
.
keys
(
grunt
.
config
(
"dst"
)
);
stored
=
Object
.
keys
(
grunt
.
config
(
"dst"
)
);
// Allow command line input as well
// Allow command line input as well
flags
=
Object
.
keys
(
this
.
flags
);
flags
=
Object
.
keys
(
this
.
flags
);
...
@@ -447,7 +459,7 @@ module.exports = function( grunt ) {
...
@@ -447,7 +459,7 @@ module.exports = function( grunt ) {
});
});
// Ensure the dist files are pure ASCII
// Ensure the dist files are pure ASCII
fs
=
require
(
"fs"
);
fs
=
require
(
"fs"
);
nonascii
=
false
;
nonascii
=
false
;
distpaths
.
forEach
(
function
(
filename
)
{
distpaths
.
forEach
(
function
(
filename
)
{
...
@@ -520,7 +532,13 @@ module.exports = function( grunt ) {
...
@@ -520,7 +532,13 @@ module.exports = function( grunt ) {
var
contents
=
grunt
.
file
.
read
(
file
);
var
contents
=
grunt
.
file
.
read
(
file
);
// Strip banners
// Strip banners
return
contents
.
replace
(
/^
\/\*
!
(?:
.|
\n)
*
?\*\/\n?
/gm
,
""
);
return
contents
// Remove the main jQuery banner, it'll be replaced by the new banner anyway.
.
replace
(
/^
\/\*
!
(?:
.|
\n)
*
?\*\/\n?
/g
,
""
)
// Strip other banners preserving line count.
.
replace
(
/^
\/\*
!
(?:
.|
\n)
*
?\*\/\n?
/gm
,
function
(
match
)
{
return
match
.
replace
(
/
[^\n]
/gm
,
""
);
});
}).
join
(
"
\n
"
);
}).
join
(
"
\n
"
);
// Write temp file (with optional banner)
// Write temp file (with optional banner)
...
@@ -528,6 +546,32 @@ module.exports = function( grunt ) {
...
@@ -528,6 +546,32 @@ module.exports = function( grunt ) {
});
});
});
});
// Change the map file to point back to jquery.js instead of jquery.pre-min.js.
// The problem is caused by the pre-uglify task.
// Also, remove temporary files.
grunt
.
registerMultiTask
(
"post-uglify"
,
function
()
{
var
fs
=
require
(
"fs"
);
this
.
files
.
forEach
(
function
(
mapping
)
{
var
mapFileName
=
mapping
.
src
[
0
];
// Rename the file to a temporary name.
fs
.
renameSync
(
mapFileName
,
mapping
.
dest
);
grunt
.
file
.
write
(
mapFileName
,
grunt
.
file
.
read
(
mapping
.
dest
)
// The uglify task erroneously prepends dist/ to file names.
.
replace
(
/"dist
\/
/g
,
"
\"
"
)
// Refer to the source jquery.js, not the temporary jquery.pre-min.js.
.
replace
(
/
\.
pre-min
\.
/g
,
"."
)
// There's already a pragma at the beginning of the file, remove the one at the end.
.
replace
(
/
\/\/
@ sourceMappingURL=jquery
\.
min
\.
map$/g
,
""
));
});
// Remove temporary files.
this
.
options
().
tempFiles
.
forEach
(
function
(
fileName
)
{
fs
.
unlink
(
fileName
);
});
});
// Load grunt tasks from NPM packages
// Load grunt tasks from NPM packages
grunt
.
loadNpmTasks
(
"grunt-compare-size"
);
grunt
.
loadNpmTasks
(
"grunt-compare-size"
);
grunt
.
loadNpmTasks
(
"grunt-git-authors"
);
grunt
.
loadNpmTasks
(
"grunt-git-authors"
);
...
@@ -537,7 +581,7 @@ module.exports = function( grunt ) {
...
@@ -537,7 +581,7 @@ module.exports = function( grunt ) {
grunt
.
loadNpmTasks
(
"grunt-contrib-uglify"
);
grunt
.
loadNpmTasks
(
"grunt-contrib-uglify"
);
// Default grunt
// Default grunt
grunt
.
registerTask
(
"default"
,
[
"update_submodules"
,
"selector"
,
"build:*:*"
,
"jshint"
,
"pre-uglify"
,
"uglify"
,
"dist:*"
,
"compare_size"
]
);
grunt
.
registerTask
(
"default"
,
[
"update_submodules"
,
"selector"
,
"build:*:*"
,
"jshint"
,
"pre-uglify"
,
"uglify"
,
"
post-uglify"
,
"
dist:*"
,
"compare_size"
]
);
// Short list as a high frequency watch task
// Short list as a high frequency watch task
grunt
.
registerTask
(
"dev"
,
[
"selector"
,
"build:*:*"
,
"jshint"
]
);
grunt
.
registerTask
(
"dev"
,
[
"selector"
,
"build:*:*"
,
"jshint"
]
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment