Add webpack.nodeps.js

Use it to generate dist/converse-no-dependencies.js which we use to
generate the converse.pot file.
This commit is contained in:
JC Brand 2019-08-23 17:09:39 +02:00
parent 12bca2298c
commit cf7d2fb648
6 changed files with 1778 additions and 1741 deletions

View File

@ -21,6 +21,7 @@ SED ?= sed
SPHINXBUILD ?= ./bin/sphinx-build SPHINXBUILD ?= ./bin/sphinx-build
SPHINXOPTS = SPHINXOPTS =
UGLIFYJS ?= node_modules/.bin/uglifyjs UGLIFYJS ?= node_modules/.bin/uglifyjs
XGETTEXT = xgettext
# Internal variables. # Internal variables.
@ -65,10 +66,13 @@ serve_bg: stamp-npm
######################################################################## ########################################################################
## Translation machinery ## Translation machinery
GETTEXT = xgettext --language="JavaScript" --keyword=__ --keyword=___ --from-code=UTF-8 --output=locale/converse.pot dist/converse-no-dependencies.js --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=5.0.1 -c dist/converse-no-dependencies.js: src webpack.common.js webpack.nodeps.js stamp-npm @converse/headless
npm run nodeps
GETTEXT = $(XGETTEXT) --from-code=UTF-8 --language=JavaScript --keyword=__ -keyword=___ --force-po --output=locale/converse.pot --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=5.0.1 dist/converse-no-dependencies.js -c
.PHONY: pot .PHONY: pot
pot: dist/converse-no-dependencies-es2015.js pot: dist/converse-no-dependencies.js
$(GETTEXT) 2>&1 > /dev/null; exit $$?; $(GETTEXT) 2>&1 > /dev/null; exit $$?;
.PHONY: po .PHONY: po
@ -155,18 +159,13 @@ logo/conversejs-filled%.png:: logo/conversejs-filled.svg
$(OXIPNG) $@ $(OXIPNG) $@
BUILDS = src/headless/dist/converse-headless.js \ BUILDS = src/headless/dist/converse-headless.js \
src/headless/dist/converse-headless.min.js \ src/headless/dist/converse-headless.min.js
dist/converse-no-dependencies.js \
dist/converse-no-dependencies-es2015.js
src/headless/dist/converse-headless.js: src webpack.common.js stamp-npm @converse/headless src/headless/dist/converse-headless.js: src webpack.common.js stamp-npm @converse/headless
npm run converse-headless.js npm run converse-headless.js
src/headless/dist/converse-headless.min.js: src webpack.common.js stamp-npm @converse/headless src/headless/dist/converse-headless.min.js: src webpack.common.js stamp-npm @converse/headless
npm run converse-headless.min.js npm run converse-headless.min.js
dist/converse-no-dependencies.js: src webpack.common.js stamp-npm @converse/headless
$(NPX) webpack --mode=development --type=nodeps
dist/converse-no-dependencies-es2015.js: src webpack.common.js stamp-npm @converse/headless
$(NPX) webpack --mode=development --type=nodeps --lang=es2015
@converse/headless: src/headless @converse/headless: src/headless

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@
"clean": "rm -rf node_modules stamp-npm dist *.zip", "clean": "rm -rf node_modules stamp-npm dist *.zip",
"converse-headless.js": "webpack --mode=development --type=headless", "converse-headless.js": "webpack --mode=development --type=headless",
"converse-headless.min.js": "npm run converse-headless.js && webpack --mode=production --type=headless", "converse-headless.min.js": "npm run converse-headless.js && webpack --mode=production --type=headless",
"nodeps": "webpack --config webpack.nodeps.js",
"build": "webpack --config webpack.prod.js", "build": "webpack --config webpack.prod.js",
"lerna": "lerna bootstrap --hoist --ignore-scripts", "lerna": "lerna bootstrap --hoist --ignore-scripts",
"prepare": "npm run lerna && npm run build" "prepare": "npm run lerna && npm run build"

View File

@ -399,23 +399,28 @@ converse.plugins.add('converse-chatview', {
* @method _converse.ChatBoxView#addSpoilerButton * @method _converse.ChatBoxView#addSpoilerButton
*/ */
async addSpoilerButton (options) { async addSpoilerButton (options) {
__('1111')
if (!options.show_spoiler_button || this.model.get('type') === _converse.CHATROOMS_TYPE) { if (!options.show_spoiler_button || this.model.get('type') === _converse.CHATROOMS_TYPE) {
return; return;
} }
__('2222')
const contact_jid = this.model.get('jid'); const contact_jid = this.model.get('jid');
if (this.model.presence.resources.length === 0) { if (this.model.presence.resources.length === 0) {
return; return;
} }
__('3333')
const results = await Promise.all( const results = await Promise.all(
this.model.presence.resources.map( this.model.presence.resources.map(
r => _converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${r.get('name')}`) r => _converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${r.get('name')}`)
) )
); );
__('4444')
const all_resources_support_spolers = results.reduce((acc, val) => (acc && val), true); const all_resources_support_spolers = results.reduce((acc, val) => (acc && val), true);
if (all_resources_support_spolers) { if (all_resources_support_spolers) {
const html = tpl_spoiler_button(this.model.toJSON()); const html = tpl_spoiler_button(this.model.toJSON());
this.el.querySelector('.chat-toolbar').insertAdjacentHTML('afterBegin', html); this.el.querySelector('.chat-toolbar').insertAdjacentHTML('afterBegin', html);
} }
__('hello world')
}, },
insertHeading () { insertHeading () {
@ -434,9 +439,9 @@ converse.plugins.add('converse-chatview', {
getToolbarOptions () { getToolbarOptions () {
let label_toggle_spoiler; let label_toggle_spoiler;
if (this.model.get('composing_spoiler')) { if (this.model.get('composing_spoiler')) {
label_toggle_spoiler = __('Click to write as a normal (non-spoiler) message'); label_toggle_spoiler = __("Click to write as a normal (non-spoiler) message");
} else { } else {
label_toggle_spoiler = __('Click to write your message as a spoiler'); label_toggle_spoiler = __("Click to write your message as a spoiler");
} }
return { return {
'label_clear': __('Clear all messages'), 'label_clear': __('Clear all messages'),
@ -445,7 +450,7 @@ converse.plugins.add('converse-chatview', {
'message_limit': _converse.message_limit, 'message_limit': _converse.message_limit,
'show_call_button': _converse.visible_toolbar_buttons.call, 'show_call_button': _converse.visible_toolbar_buttons.call,
'show_spoiler_button': _converse.visible_toolbar_buttons.spoiler, 'show_spoiler_button': _converse.visible_toolbar_buttons.spoiler,
'tooltip_start_call': __('Start a call'), 'tooltip_start_call': __('Start a call')
} }
}, },

View File

@ -8,7 +8,6 @@
// //
import * as strophe from 'strophe.js/src/core'; import * as strophe from 'strophe.js/src/core';
import Backbone from "backbone"; import Backbone from "backbone";
import Promise from "es6-promise/dist/es6-promise.auto";
import _ from "../lodash.noconflict"; import _ from "../lodash.noconflict";
import sizzle from "sizzle"; import sizzle from "sizzle";

68
webpack.nodeps.js Normal file
View File

@ -0,0 +1,68 @@
/* global module, __dirname */
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const common = require("./webpack.common.js");
const merge = require("webpack-merge");
const path = require('path');
module.exports = merge(common, {
mode: "production",
output: {
filename: 'converse-no-dependencies.js'
},
optimization: {
minimizer: []
},
plugins: [
new MiniCssExtractPlugin({filename: ''})
],
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [
["@babel/preset-env", {
"targets": {
"browsers": ["ie 8"]
}
}]
]
}
}
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
includePaths: [path.resolve(__dirname, 'node_modules/')]
}
}
]
}]
},
externals: [{
"backbone": "backbone",
"backbone.nativeview": "backbone.nativeview",
"backbone.vdomview": "backbone.vdomview",
"backbone.browserStorage": "backbone.browserStorage",
"backbone.overview": "backbone.overview",
"es6-promise": "es6-promise",
"formdata-polyfill": "formdata-polyfill",
"lodash": "lodash",
"lodash.converter": "lodash.converter",
"lodash.noconflict": "lodash.noconflict",
"strophe": "strophe",
"window": "window",
"filesize": "filesize",
"jed": "jed",
"sizzle": "sizzle",
"twemoji": "twemoji",
"urijs": "urijs"
}]
});