Skip to content

Commit

Permalink
Bundle jquery.uls and use language-data as dependency
Browse files Browse the repository at this point in the history
Changes
=======

Introduce rollup based bundler to create single js, css files.
This allows easy usage and no need to include every source code files
explicitly. Fixes issue #326

Add language-data as dependency to the library
Instead of using scripts to clone the language-data repo and then create
our javascript files from it, directly use language-data as dev-dependency.
The final bundle will include language-data. So it is not an external
dependency for bundle.

Approach
========

To avoid any breakage in consumers, no change in jquery plugins were
introduced. No method signature change too. All plugin definitions
moved to src/index.js. index.js also import the language-data
and alias that to $.uls.data.

So, jquery.uls.data.js and jquery.uls.data.utils.js files were deleted.
The scripts to generate this files was also deleted.

All other changes in jquery.uls.*.js is just indendation change
because of the removal of IIFE. The resuling bundle will have IIFE.
IIFE block has to be removed to expose the classes for exporting
as modules.

Examples were updated to refer javascript, css and styles from dist
folder.

Future steps
============

Introduction of build step allows

* To modernize the codebase to new versions of javascript
* To drop jquery dependency and optionally keep the jquery plugins
* Remove grunt based CI system
  • Loading branch information
santhoshtr authored and Abijeet committed Jul 17, 2021
1 parent 1615eea commit c919378
Show file tree
Hide file tree
Showing 22 changed files with 23,230 additions and 13,382 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
src/jquery.uls.data.js
src/jquery.uls.data.js
dist/
node_modules/
13 changes: 12 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@
"wikimedia/client",
"wikimedia/jquery"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"env": {
"es6": true,
"browser": true,
"jquery": true,
"qunit": true,
"node": true
},
"globals": {
"jQuery": "readonly",
"$": "off"
"$": "readonly"
}
}
7 changes: 3 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ module.exports = function ( grunt ) {
},
all: [
'**/*.{js,json,html}',
'!src/jquery.uls.data.js',
'!scripts/jquery.uls.data.template.js',
'!examples/resources/*.min.js',
'!node_modules/**',
'!vendor/**'
'!dist/**'
]
},
stylelint: {
Expand All @@ -27,7 +25,8 @@ module.exports = function ( grunt ) {
},
src: [
'**/*.css',
'!node_modules/**'
'!node_modules/**',
'!dist/**'
]
},
qunit: {
Expand Down
11 changes: 2 additions & 9 deletions examples/index-i18n.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@
<meta charset="utf-8">
<title>Universal Language Selector</title>
<meta name="author" content="Santhosh Thottingal">
<link href="../css/jquery.uls.css" rel="stylesheet">
<link href="../css/jquery.uls.grid.css" rel="stylesheet">
<link href="../css/jquery.uls.lcd.css" rel="stylesheet">
<link href="../styles/jquery.uls.css" rel="stylesheet">
<!-- demo -->
<link href="resources/demo.css" rel="stylesheet">
<!-- Libs -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Source -->
<script src="../src/jquery.uls.data.js"></script>
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script src="resources/jquery.i18n.min.js"></script>
<script src="../jquery.uls.js"></script>
<script>
$( function () {
var i18n = $.i18n();
Expand Down
11 changes: 2 additions & 9 deletions examples/index-mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@
<!-- <link rel="apple-touch-icon" href="/apple-touch-icon.png"> -->
<!-- <meta name="description" content=""> -->
<meta name="author" content="Santhosh Thottingal, Pau Giner">
<link href="../css/jquery.uls.css" rel="stylesheet">
<link href="../css/jquery.uls.grid.css" rel="stylesheet">
<link href="../css/jquery.uls.lcd.css" rel="stylesheet">
<link href="../css/jquery.uls.mobile.css" rel="stylesheet">
<link href="../styles/jquery.uls.css" rel="stylesheet">
<!-- demo -->
<link href="resources/demo.css" rel="stylesheet">
<!-- Libs -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Source -->
<script src="../src/jquery.uls.data.js"></script>
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script src="../jquery.uls.js"></script>
<script>
$( function () {
$( '.uls-trigger' ).uls( {
Expand Down
10 changes: 2 additions & 8 deletions examples/index-narrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@
<meta charset="utf-8">

<title>Universal Language Selector</title>
<link href="../css/jquery.uls.css" rel="stylesheet">
<link href="../css/jquery.uls.grid.css" rel="stylesheet">
<link href="../css/jquery.uls.lcd.css" rel="stylesheet">
<link href="../styles/jquery.uls.css" rel="stylesheet">
<!-- demo -->
<link href="resources/demo.css" rel="stylesheet">
<!-- Libs -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Source -->
<script src="../src/jquery.uls.data.js"></script>
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script src="../jquery.uls.js"></script>
<script>
$( function () {
$( '.uls-trigger' ).uls( {
Expand Down
10 changes: 2 additions & 8 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@
<!-- <link rel="apple-touch-icon" href="/apple-touch-icon.png"> -->
<!-- <meta name="description" content=""> -->
<meta name="author" content="Santhosh Thottingal">
<link href="../css/jquery.uls.css" rel="stylesheet">
<link href="../css/jquery.uls.grid.css" rel="stylesheet">
<link href="../css/jquery.uls.lcd.css" rel="stylesheet">
<link href="../styles/jquery.uls.css" rel="stylesheet">
<!-- demo -->
<link href="resources/demo.css" rel="stylesheet">
<!-- Libs -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Source -->
<script src="../src/jquery.uls.data.js"></script>
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script src="../jquery.uls.js"></script>
<script>
$( function () {
$( '.uls-trigger' ).uls( {
Expand Down
10 changes: 2 additions & 8 deletions examples/limitedLanguageList.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@

<title>Universal Language Selector</title>
<meta name="author" content="Santhosh Thottingal">
<link href="../css/jquery.uls.css" rel="stylesheet">
<link href="../css/jquery.uls.grid.css" rel="stylesheet">
<link href="../css/jquery.uls.lcd.css" rel="stylesheet">
<link href="../styles/jquery.uls.css" rel="stylesheet">
<!-- demo -->
<link href="resources/demo.css" rel="stylesheet">
<!-- Libs -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Source -->
<script src="../src/jquery.uls.data.js"></script>
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script src="../sjquery.uls.js"></script>
<script>
$( function () {
$( '.uls-trigger' ).uls( {
Expand Down
10 changes: 2 additions & 8 deletions examples/test-no-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@
<!-- <link rel="apple-touch-icon" href="/apple-touch-icon.png"> -->
<!-- <meta name="description" content=""> -->
<meta name="author" content="Santhosh Thottingal">
<link href="../css/jquery.uls.css" rel="stylesheet">
<link href="../css/jquery.uls.grid.css" rel="stylesheet">
<link href="../css/jquery.uls.lcd.css" rel="stylesheet">
<link href="../styles/jquery.uls.css" rel="stylesheet">
<!-- demo -->
<link href="resources/demo.css" rel="stylesheet">
<!-- Libs -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Source -->
<script src="../src/jquery.uls.data.js"></script>
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script src="../jquery.uls.js"></script>
<script>
$( function () {
$( '.uls-trigger' ).uls( {
Expand Down
Loading

0 comments on commit c919378

Please sign in to comment.