Skip to content

Commit

Permalink
Build: Remove source map from jquery.form.min.js.
Browse files Browse the repository at this point in the history
Minimize jquery.form.js as part of build process to remove the source map reference. 

Modify source map tests to include all JavaScript files rather than testing Backbone and jQuery only.

Props pento.
Fixes #46218.



git-svn-id: https://develop.svn.wordpress.org/trunk@44740 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
peterwilsoncc committed Feb 14, 2019
1 parent e7e42ef commit 3ec3100
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
9 changes: 7 additions & 2 deletions Gruntfile.js
Expand Up @@ -171,7 +171,6 @@ module.exports = function(grunt) {
[ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.js' ],
[ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.min.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.min.js' ],
[ WORKING_DIR + 'wp-includes/js/jquery/jquery.form.js' ]: [ './node_modules/jquery-form/src/jquery.form.js' ],
[ WORKING_DIR + 'wp-includes/js/jquery/jquery.form.min.js' ]: [ './node_modules/jquery-form/dist/jquery.form.min.js' ],
[ WORKING_DIR + 'wp-includes/js/jquery/jquery.js' ]: [ './node_modules/jquery/dist/jquery.min.js' ],
[ WORKING_DIR + 'wp-includes/js/masonry.min.js' ]: [ './node_modules/masonry-layout/dist/masonry.pkgd.min.js' ],
[ WORKING_DIR + 'wp-includes/js/twemoji.js' ]: [ './node_modules/twemoji/2/twemoji.js' ],
Expand Down Expand Up @@ -720,6 +719,10 @@ module.exports = function(grunt) {
src: WORKING_DIR + 'wp-includes/js/imgareaselect/jquery.imgareaselect.js',
dest: WORKING_DIR + 'wp-includes/js/imgareaselect/jquery.imgareaselect.min.js'
},
jqueryform: {
src: WORKING_DIR + 'wp-includes/js/jquery/jquery.form.js',
dest: WORKING_DIR + 'wp-includes/js/jquery/jquery.form.min.js'
},
dynamic: {
expand: true,
cwd: WORKING_DIR,
Expand Down Expand Up @@ -1193,6 +1196,7 @@ module.exports = function(grunt) {
'webpack:prod',
'jshint:corejs',
'uglify:imgareaselect',
'uglify:jqueryform',
'qunit:compiled'
] );

Expand Down Expand Up @@ -1332,7 +1336,8 @@ module.exports = function(grunt) {
'uglify:core',
'uglify:embed',
'uglify:jqueryui',
'uglify:imgareaselect'
'uglify:imgareaselect',
'uglify:jqueryform'
] );

grunt.registerTask( 'build:js', [
Expand Down
15 changes: 0 additions & 15 deletions tests/phpunit/tests/dependencies/backbonejs.php

This file was deleted.

8 changes: 0 additions & 8 deletions tests/phpunit/tests/dependencies/jquery.php
Expand Up @@ -82,14 +82,6 @@ function test_dont_allow_deregister_core_scripts_in_admin() {
set_current_screen( 'front' );
}

/**
* @ticket 24994
*/
function test_exclusion_of_sourcemaps() {
$contents = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) );
$this->assertFalse( strpos( $contents, 'sourceMappingURL' ), 'Presence of sourceMappingURL' );
}

/**
* @ticket 28404
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/phpunit/tests/dependencies/scripts.php
Expand Up @@ -1341,4 +1341,16 @@ public function test_wp_enqueue_code_editor_when_simple_array_will_be_passed() {
array_keys( $wp_enqueue_code_editor['htmlhint'] )
);
}

function test_no_source_mapping() {
$all_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( dirname( ABSPATH ) . '/build/' ) );
$js_files = new RegexIterator( $all_files, '/\.js$/' );
foreach( $js_files as $js_file ) {
$contents = trim( file_get_contents( $js_file ) );

// We allow data: URLs.
$found = preg_match( '/sourceMappingURL=((?!data:).)/', $contents );
$this->assertSame( $found, 0, "sourceMappingURL found in $js_file" );
}
}
}

0 comments on commit 3ec3100

Please sign in to comment.