Commit 38c9a9e1 authored by JC Brand's avatar JC Brand

Rework the way builds are created.

Builds are now themselves UMD modules, so they could be `require`'d like any
other AMD module or they can still be used as old ES5 modules with globals.

Additionally the build is now closured, so that the almond API doesn't pollute
the global context with `define` or `require`. This does however mean that
`require` can no longer be used outside of the build (unless requirej.s is
included directly.
parent b28b011e
......@@ -53,8 +53,8 @@ dist/converse-no-locales-no-otr.min.js
dist/converse-no-otr.js
dist/converse-no-otr.min.js
dist/converse.min.js
dist/converse.nojquery.js
dist/converse.nojquery.min.js
dist/converse-no-jquery.js
dist/converse-no-jquery.min.js
dist/converse-mobile.min.js
css/*.map
......
......@@ -80,7 +80,7 @@ po2json:
.PHONY: release
release:
sed -i s/Version:\ [0-9]\+\.[0-9]\+\.[0-9]\+/Version:\ $(VERSION)/ src/converse.js
sed -i s/Version:\ [0-9]\+\.[0-9]\+\.[0-9]\+/Version:\ $(VERSION)/ src/start.frag
sed -i s/Project-Id-Version:\ Converse\.js\ [0-9]\+\.[0-9]\+\.[0-9]\+/Project-Id-Version:\ Converse.js\ $(VERSION)/ locale/converse.pot
sed -i s/\"version\":\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\":\ \"$(VERSION)\"/ bower.json
sed -i s/\"version\":\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\":\ \"$(VERSION)\"/ package.json
......@@ -148,27 +148,27 @@ BUILDS = dist/converse.js \
dist/converse.min.js \
dist/converse-mobile.js \
dist/converse-mobile.min.js \
dist/converse.nojquery.js \
dist/converse.nojquery.min.js \
dist/converse-no-jquery.js \
dist/converse-no-jquery.min.js \
dist/converse-no-dependencies.min.js \
dist/converse-no-dependencies.js
dist/converse.min.js: src locale node_modules *.js
$(RJS) -o src/build.js
$(RJS) -o src/build.js include=converse out=dist/converse.min.js
dist/converse.js: src locale node_modules *.js
$(RJS) -o src/build.js optimize=none out=dist/converse.js
dist/converse.nojquery.min.js: src locale node_modules *.js
$(RJS) -o src/build-no-jquery.js
dist/converse.nojquery.js: src locale node_modules *.js
$(RJS) -o src/build-no-jquery.js optimize=none out=dist/converse.nojquery.js
$(RJS) -o src/build.js include=converse out=dist/converse.js optimize=none
dist/converse-no-jquery.min.js: src locale node_modules *.js
$(RJS) -o src/build.js include=converse wrap.endFile=end-no-jquery.frag exclude=jquery exclude=jquery-private out=dist/converse-no-jquery.min.js
dist/converse-no-jquery.js: src locale node_modules *.js
$(RJS) -o src/build.js include=converse wrap.endFile=end-no-jquery.frag exclude=jquery exclude=jquery-private out=dist/converse-no-jquery.js optimize=none
dist/converse-no-dependencies.min.js: src locale node_modules *.js
$(RJS) -o src/build-no-dependencies.js
dist/converse-no-dependencies.js: src locale node_modules *.js
$(RJS) -o src/build-no-dependencies.js optimize=none out=dist/converse-no-dependencies.js
dist/converse-mobile.min.js: src locale node_modules *.js
$(RJS) -o src/build-mobile.js
$(RJS) -o src/build.js include=converse-mobile out=dist/converse-mobile.min.js
dist/converse-mobile.js: src locale node_modules *.js
$(RJS) -o src/build-mobile.js optimize=none out=dist/converse-mobile.js
$(RJS) -o src/build.js optimize=none include=converse-mobile out=dist/converse-mobile.js
.PHONY: jsmin
jsmin: $(BUILDS)
......
......@@ -16,6 +16,9 @@
* Templates are no longer stored as attributes on the `_converse` object.
If you need a particular template, use `require` to load it.
- The no-jQuery build has been renamed from `converse.nojquery.js` to
`converse-no-jquery.js` to fit the convention used for other build names.
[jcbrand]
- 100 is the new default [archived_messages_page_size](https://conversejs.org/docs/html/configuration.html#archived-messages-page-size)
[jcbrand]
- Better support for delayed delivery of presence stanzas (XEP-0203). [jcbrand]
......
({
baseUrl: "../",
name: "almond",
out: "../dist/converse-mobile.min.js",
mainConfigFile: '../config.js',
excludeShallow: [
"converse-minimize",
"converse-dragresize"
],
include: ['converse'],
insertRequire: ['converse'],
wrap: {
endFile: ["wrapper-mobile.js"]
},
})
......@@ -39,8 +39,8 @@
"lodash"
],
wrap: {
endFile: ["wrapper-no-jquery.js", "wrapper-no-deps.js"]
startFile: "start.frag",
endFile: "end-no-dependencies.frag"
},
insertRequire: ["converse"],
mainConfigFile: "../config.js"
mainConfigFile: "config.js"
})
({
baseUrl: "../",
name: "almond",
out: "../dist/converse.nojquery.min.js",
include: ['converse'],
exclude: ['jquery', 'jquery-private'],
insertRequire: ['converse'],
mainConfigFile: '../config.js',
wrap: {
endFile: "wrapper-no-jquery.js"
}
})
({
baseUrl: "../",
name: "almond",
out: "../dist/converse.min.js",
mainConfigFile: '../config.js',
include: ['converse'],
insertRequire: ['converse'],
mainConfigFile: 'config.js',
wrap: {
startFile: "start.frag",
endFile: "end.frag"
}
})
......@@ -42,6 +42,8 @@ require.config({
"utils": "src/utils",
// Converse
"converse-mobile": "src/converse-mobile",
"converse-core": "src/converse-core",
"converse-bookmarks": "src/converse-bookmarks",
"converse-chatview": "src/converse-chatview",
......
/*global define */
if (typeof define !== 'undefined') {
// The section below determines which plugins will be included in a build
define([
"converse-core",
// PLEASE NOTE: By default all translations are included.
// You can modify the file src/locales.js to include only those
// translations that you care about.
/* START: Removable components
* --------------------
* Any of the following components may be removed if they're not needed.
*/
"converse-chatview", // Renders standalone chat boxes for single user chat
"converse-controlbox", // The control box
"converse-bookmarks", // XEP-0048 Bookmarks
"converse-mam", // XEP-0313 Message Archive Management
"converse-muc", // XEP-0045 Multi-user chat
"converse-vcard", // XEP-0054 VCard-temp
"converse-otr", // Off-the-record encryption for one-on-one messages
"converse-register", // XEP-0077 In-band registration
"converse-ping", // XEP-0199 XMPP Ping
"converse-notification",// HTML5 Notifications
"converse-headline", // Support for headline messages
/* END: Removable components */
], function (converse) {
var evt;
if (window.CustomEvent) {
evt = new CustomEvent('converse-loaded', {detail: {'converse': converse}});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent('converse-loaded', true, true, {'converse': converse});
}
window.dispatchEvent(evt);
});
}
/* Converse.js
*
* Version: 3.0.0
*/
/*global define */
if (typeof define !== 'undefined') {
// The section below determines which plugins will be included in a build
define([
......@@ -30,10 +25,14 @@ if (typeof define !== 'undefined') {
"converse-dragresize", // Allows chat boxes to be resized by dragging them
"converse-headline", // Support for headline messages
/* END: Removable components */
], function(converse) {
converse.env.jQuery(window).trigger('converse-loaded', converse);
window.converse = converse;
return converse;
], function (converse) {
var evt;
if (window.CustomEvent) {
evt = new CustomEvent('converse-loaded', {detail: {'converse': converse}});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent('converse-loaded', true, true, {'converse': converse});
}
window.dispatchEvent(evt);
});
}
define('jquery', [], function () { return jQuery; });
define('jquery-private', [], function () { return jQuery; });
define('jquery.browser', [], function () { return jQuery; });
define('awesomplete', [], function () { return jQuery; });
define('lodash', [], function () { return _; });
define('moment_with_locales', [], function () { return moment; });
define('strophe', [], function () {
return {
'Strophe': Strophe,
'$build': $build,
'$iq': $iq,
'$msg': $msg,
'$pres': $pres,
'SHA1': SHA1,
'MD5': MD5,
'b64_hmac_sha1': SHA1.b64_hmac_sha1,
'b64_sha1': SHA1.b64_sha1,
'str_hmac_sha1': SHA1.str_hmac_sha1,
'str_sha1': SHA1.str_sha1
};
});
var strophePlugin = function () { return Strophe; };
var emptyFunction = function () { };
define('strophe.disco', ['strophe'], strophePlugin);
define('strophe.ping', ['strophe'], strophePlugin);
define('strophe.rsm', ['strophe'], strophePlugin);
define('strophe.vcard', ['strophe'], strophePlugin);
define('backbone', [], emptyFunction);
define('backbone.browserStorage', ['backbone'], emptyFunction);
define('backbone.overview', ['backbone'], emptyFunction);
define('otr', [], function () { return { 'DSA': DSA, 'OTR': OTR };});
define("locales", [], emptyFunction);
return require('converse');
}));
define('jquery', [], function () { return jQuery; });
define('jquery-private', [], function () { return jQuery; });
return require('converse');
}));
/* jshint ignore:start */
//The modules for your project will be inlined above
//this snippet. Ask almond to synchronously require the
//module value for 'converse' here and return it as the
//value to use for the public API for the built file.
return require('converse');
}));
/* jshint ignore:end */
/** Converse.js
*
* An XMPP chat client that runs in the browser.
*
* Version: 3.0.0
*/
/* jshint ignore:start */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
//Allow using this built library as an AMD module
//in another project. That other project will only
//see this AMD call, not the internal modules in
//the closure below.
define([], factory);
} else {
//Browser globals case.
root.converse = factory();
}
}(this, function () {
//almond, and your modules will be inlined here
/* jshint ignore:end */
/*global jQuery, _, moment, Strophe, $build, $iq, $msg, $pres, SHA1, MD5, DSA, OTR */
define('jquery', [], function () { return jQuery; });
define('jquery.browser', [], function () { return jQuery; });
define('typeahead', [], function () { return jQuery; });
define('lodash', [], function () { return _; });
define('underscore', [], function () { return _; });
define('moment_with_locales', [], function () { return moment; });
define('strophe', [], function () {
return {
'Strophe': Strophe,
'$build': $build,
'$iq': $iq,
'$msg': $msg,
'$pres': $pres,
'SHA1': SHA1,
'MD5': MD5,
'b64_hmac_sha1': SHA1.b64_hmac_sha1,
'b64_sha1': SHA1.b64_sha1,
'str_hmac_sha1': SHA1.str_hmac_sha1,
'str_sha1': SHA1.str_sha1
};
});
var strophePlugin = function () { return Strophe; };
var emptyFunction = function () { };
define('strophe.disco', ['strophe'], strophePlugin);
define('strophe.ping', ['strophe'], strophePlugin);
define('strophe.rsm', ['strophe'], strophePlugin);
define('strophe.vcard', ['strophe'], strophePlugin);
define('backbone', [], emptyFunction);
define('backbone.browserStorage', ['backbone'], emptyFunction);
define('backbone.overview', ['backbone'], emptyFunction);
define('otr', [], function () { return { 'DSA': DSA, 'OTR': OTR };});
define("locales", [], emptyFunction);
define('converse-minimize', [], function () { return; });
define('converse-dragresize', [], function () { return; });
/*global jQuery, _, moment, Strophe, $build, $iq, $msg, $pres, SHA1, MD5, DSA, OTR */
define('jquery.browser', [], function () { return jQuery; });
define('awesomplete', [], function () { return jQuery; });
define('lodash', [], function () { return _; });
define('moment_with_locales', [], function () { return moment; });
define('strophe', [], function () {
return {
'Strophe': Strophe,
'$build': $build,
'$iq': $iq,
'$msg': $msg,
'$pres': $pres,
'SHA1': SHA1,
'MD5': MD5,
'b64_hmac_sha1': SHA1.b64_hmac_sha1,
'b64_sha1': SHA1.b64_sha1,
'str_hmac_sha1': SHA1.str_hmac_sha1,
'str_sha1': SHA1.str_sha1
};
});
var strophePlugin = function () { return Strophe; };
var emptyFunction = function () { };
define('strophe.disco', ['strophe'], strophePlugin);
define('strophe.ping', ['strophe'], strophePlugin);
define('strophe.rsm', ['strophe'], strophePlugin);
define('strophe.vcard', ['strophe'], strophePlugin);
define('backbone', [], emptyFunction);
define('backbone.browserStorage', ['backbone'], emptyFunction);
define('backbone.overview', ['backbone'], emptyFunction);
define('otr', [], function () { return { 'DSA': DSA, 'OTR': OTR };});
define("locales", [], emptyFunction);
/*global jQuery */
define('jquery', [], function () { return jQuery; });
define('jquery-private', [], function () { return jQuery; });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment