2
0
Эх сурвалжийг харах

Use webpack for module bundling

JC Brand 7 жил өмнө
parent
commit
6dc9e8edf1

+ 1 - 1
.babelrc

@@ -2,7 +2,7 @@
   "presets": [
     ["@babel/preset-env", {
       "targets": {
-		"browsers": ["last 2 versions", "safari >= 10", "IE >= 11"]
+        "browsers": ["last 2 versions", "safari >= 10", "IE >= 11"]
       }
     }]
   ]

+ 2 - 1
Makefile

@@ -15,6 +15,7 @@ OXIPNG          ?= oxipng
 PAPER		   	=
 PO2JSON		 	?= ./node_modules/.bin/po2json
 RJS			 	?= ./node_modules/.bin/r.js
+WEBPACK 		?= ./node_modules/.bin/npx
 SASS			?= ./.bundle/bin/sass
 SED				?= sed
 SPHINXBUILD	 	?= ./bin/sphinx-build
@@ -155,7 +156,7 @@ watch: dev
 
 .PHONY: watchjs
 watchjs: dev
-	$(BABEL) --source-maps --watch=./src --out-dir=./builds
+	./node_modules/.bin/npx  webpack --mode=development  --watch
 
 transpile: dev src
 	$(BABEL) --source-maps --out-dir=./builds ./src

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 1
dist/converse.js


+ 2 - 2
index.html

@@ -20,8 +20,8 @@
     <!-- *********************************************************************** -->
 
     <![if gte IE 11]>
-        <link type="text/css" rel="stylesheet" media="screen" href="https://cdn.conversejs.org/css/converse.min.css" />
-        <script src="https://cdn.conversejs.org/dist/converse.min.js"></script>
+        <link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
+        <script src="dist/converse.js"></script>
     <![endif]>
 </head>
 

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 555 - 337
package-lock.json


+ 8 - 11
package.json

@@ -29,11 +29,11 @@
     "browser": "*"
   },
   "devDependencies": {
-    "@babel/cli": "^7.0.0-beta.35",
-    "@babel/core": "^7.0.0-beta.35",
-    "@babel/preset-env": "^7.0.0-beta.35",
-    "almond": "~0.3.3",
+    "@babel/cli": "^7.0.0-beta.48",
+    "@babel/core": "^7.0.0-beta.48",
+    "@babel/preset-env": "^7.0.0-beta.48",
     "awesomplete-avoid-xss": "^1.1.2",
+    "babel-loader": "^8.0.0-beta.3",
     "backbone": "1.3.3",
     "backbone.browserStorage": "0.0.3",
     "backbone.nativeview": "^0.3.3",
@@ -57,28 +57,25 @@
     "jsdoc": "^3.5.5",
     "jshint": "^2.9.4",
     "lodash": "4.17.4",
-    "lodash-template-loader": "^2.0.0",
+    "lodash-template-webpack-loader": "jcbrand/lodash-template-webpack-loader",
     "moment": "~> 2.19.3 ",
+    "npm": "^5.7.1",
     "otr": "0.2.16",
     "pluggable.js": "2.0.0",
     "po2json": "^0.4.4",
-    "requirejs": "2.3.5",
     "run-headless-chromium": "^0.1.1",
     "sinon": "^2.1.0",
     "sizzle": "^2.3.3",
     "snabbdom": "0.7.1",
-    "snyk": "^1.21.2",
     "strophe.js": "1.2.14",
     "strophejs-plugin-ping": "0.0.1",
     "strophejs-plugin-register": "0.0.1",
     "strophejs-plugin-rsm": "0.0.1",
-    "text": "requirejs/text#2.0.15",
     "uglify-es": "^3.0.24",
     "urijs": "^1.19.1",
     "wait-until-promise": "^1.0.0",
+    "webpack": "^4.0.1",
+    "webpack-cli": "^2.1.4",
     "xss": "^0.3.3"
-  },
-  "dependencies": {
-    "npm": "^5.7.1"
   }
 }

+ 4 - 4
src/converse-bookmarks.js

@@ -12,10 +12,10 @@
 (function (root, factory) {
     define(["converse-core",
             "converse-muc",
-            "tpl!chatroom_bookmark_form",
-            "tpl!chatroom_bookmark_toggle",
-            "tpl!bookmark",
-            "tpl!bookmarks_list"
+            "templates/chatroom_bookmark_form.html",
+            "templates/chatroom_bookmark_toggle.html",
+            "templates/bookmark.html",
+            "templates/bookmarks_list.html"
         ],
         factory);
 }(this, function (

+ 1 - 1
src/converse-chatboxes.js

@@ -9,7 +9,7 @@
         "converse-core",
         "emojione",
         "filesize",
-        "tpl!chatboxes",
+        "templates/chatboxes.html",
         "backbone.overview",
         "form-utils"
     ], factory);

+ 16 - 17
src/converse-chatview.js

@@ -5,26 +5,25 @@
 // Licensed under the Mozilla Public License (MPLv2)
 
 (function (root, factory) {
-    define([
-            "converse-core",
+    define(["converse-core",
             "bootstrap",
             "emojione",
             "xss",
-            "tpl!action",
-            "tpl!chatbox",
-            "tpl!chatbox_head",
-            "tpl!chatbox_message_form",
-            "tpl!emojis",
-            "tpl!error_message",
-            "tpl!help_message",
-            "tpl!info",
-            "tpl!new_day",
-            "tpl!user_details_modal",
-            "tpl!toolbar_fileupload",
-            "tpl!spinner",
-            "tpl!spoiler_button",
-            "tpl!status_message",
-            "tpl!toolbar",
+            "templates/action.html",
+            "templates/chatbox.html",
+            "templates/chatbox_head.html",
+            "templates/chatbox_message_form.html",
+            "templates/emojis.html",
+            "templates/error_message.html",
+            "templates/help_message.html",
+            "templates/info.html",
+            "templates/new_day.html",
+            "templates/user_details_modal.html",
+            "templates/toolbar_fileupload.html",
+            "templates/spinner.html",
+            "templates/spoiler_button.html",
+            "templates/status_message.html",
+            "templates/toolbar.html",
             "converse-modal",
             "converse-chatboxes",
             "converse-message-view"

+ 4 - 4
src/converse-controlbox.js

@@ -10,10 +10,10 @@
     define(["converse-core",
             "bootstrap",
             "lodash.fp",
-            "tpl!converse_brand_heading",
-            "tpl!controlbox",
-            "tpl!controlbox_toggle",
-            "tpl!login_panel",
+            "templates/converse_brand_heading.html",
+            "templates/controlbox.html",
+            "templates/controlbox_toggle.html",
+            "templates/login_panel.html",
             "converse-chatview",
             "converse-rosterview",
             "converse-profile"

+ 1 - 1
src/converse-dragresize.js

@@ -8,7 +8,7 @@
 
 (function (root, factory) {
     define(["converse-core",
-            "tpl!dragresize",
+            "templates/dragresize.html",
             "converse-chatview",
             "converse-controlbox"
     ], factory);

+ 1 - 1
src/converse-fullscreen.js

@@ -8,7 +8,7 @@
 
 (function (root, factory) {
     define(["converse-core",
-            "tpl!inverse_brand_heading",
+            "templates/inverse_brand_heading.html",
             "converse-chatview",
             "converse-controlbox",
             "converse-muc",

+ 1 - 1
src/converse-headline.js

@@ -9,7 +9,7 @@
 (function (root, factory) {
     define([
             "converse-core",
-            "tpl!chatbox",
+            "templates/chatbox.html",
             "converse-chatview",
     ], factory);
 }(this, function (converse, tpl_chatbox) {

+ 6 - 6
src/converse-message-view.js

@@ -10,12 +10,12 @@
         "xss",
         "emojione",
         "filesize",
-        "tpl!action",
-        "tpl!csn",
-        "tpl!file_progress",
-        "tpl!info",
-        "tpl!message",
-        "tpl!spoiler_message"
+        "templates/action.html",
+        "templates/csn.html",
+        "templates/file_progress.html",
+        "templates/info.html",
+        "templates/message.html",
+        "templates/spoiler_message.html"
     ], factory);
 }(this, function (
         converse,

+ 4 - 4
src/converse-minimize.js

@@ -8,10 +8,10 @@
 
 (function (root, factory) {
     define(["converse-core",
-            "tpl!chatbox_minimize",
-            "tpl!toggle_chats",
-            "tpl!trimmed_chat",
-            "tpl!chats_panel",
+            "templates/chatbox_minimize.html",
+            "templates/toggle_chats.html",
+            "templates/trimmed_chat.html",
+            "templates/chats_panel.html",
             "converse-chatview"
     ], factory);
 }(this, function (

+ 1 - 1
src/converse-modal.js

@@ -8,7 +8,7 @@
     if (typeof define === 'function' && define.amd) {
         define([
             "converse-core",
-            "tpl!alert_modal",
+            "templates/alert_modal.html",
             "bootstrap",
             "backbone.vdomview"
         ], factory);

+ 20 - 20
src/converse-muc-views.js

@@ -8,26 +8,26 @@
     define([
         "converse-core",
         "muc-utils",
-        "tpl!add_chatroom_modal",
-        "tpl!chatarea",
-        "tpl!chatroom",
-        "tpl!chatroom_disconnect",
-        "tpl!chatroom_features",
-        "tpl!chatroom_form",
-        "tpl!chatroom_head",
-        "tpl!chatroom_invite",
-        "tpl!chatroom_nickname_form",
-        "tpl!chatroom_password_form",
-        "tpl!chatroom_sidebar",
-        "tpl!chatroom_toolbar",
-        "tpl!info",
-        "tpl!list_chatrooms_modal",
-        "tpl!occupant",
-        "tpl!room_description",
-        "tpl!room_item",
-        "tpl!room_panel",
-        "tpl!rooms_results",
-        "tpl!spinner",
+        "templates/add_chatroom_modal.html",
+        "templates/chatarea.html",
+        "templates/chatroom.html",
+        "templates/chatroom_disconnect.html",
+        "templates/chatroom_features.html",
+        "templates/chatroom_form.html",
+        "templates/chatroom_head.html",
+        "templates/chatroom_invite.html",
+        "templates/chatroom_nickname_form.html",
+        "templates/chatroom_password_form.html",
+        "templates/chatroom_sidebar.html",
+        "templates/chatroom_toolbar.html",
+        "templates/info.html",
+        "templates/list_chatrooms_modal.html",
+        "templates/occupant.html",
+        "templates/room_description.html",
+        "templates/room_item.html",
+        "templates/room_panel.html",
+        "templates/rooms_results.html",
+        "templates/spinner.html",
         "awesomplete",
         "converse-modal"
     ], factory);

+ 5 - 5
src/converse-profile.js

@@ -9,11 +9,11 @@
 (function (root, factory) {
     define(["converse-core",
             "bootstrap",
-            "tpl!alert",
-            "tpl!chat_status_modal",
-            "tpl!profile_modal",
-            "tpl!profile_view",
-            "tpl!status_option",
+            "templates/alert.html",
+            "templates/chat_status_modal.html",
+            "templates/profile_modal.html",
+            "templates/profile_view.html",
+            "templates/status_option.html",
             "converse-vcard",
             "converse-modal"
     ], factory);

+ 7 - 7
src/converse-register.js

@@ -12,13 +12,13 @@
 (function (root, factory) {
     define(["form-utils",
             "converse-core",
-            "tpl!form_username",
-            "tpl!register_link",
-            "tpl!register_panel",
-            "tpl!registration_form",
-            "tpl!registration_request",
-            "tpl!form_input",
-            "tpl!spinner",
+            "templates/form_username.html",
+            "templates/register_link.html",
+            "templates/register_panel.html",
+            "templates/registration_form.html",
+            "templates/registration_request.html",
+            "templates/form_input.html",
+            "templates/spinner.html",
             "converse-controlbox"
     ], factory);
 }(this, function (

+ 2 - 2
src/converse-roomslist.js

@@ -13,8 +13,8 @@
     define(["utils",
             "converse-core",
             "converse-muc",
-            "tpl!rooms_list",
-            "tpl!rooms_list_item"
+            "templates/rooms_list.html",
+            "templates/rooms_list_item.html"
         ], factory);
 }(this, function (utils, converse, muc, tpl_rooms_list, tpl_rooms_list_item) {
     const { Backbone, Promise, Strophe, b64_sha1, sizzle, _ } = converse.env;

+ 8 - 8
src/converse-rosterview.js

@@ -6,14 +6,14 @@
 
 (function (root, factory) {
     define(["converse-core",
-            "tpl!add_contact_modal",
-            "tpl!group_header",
-            "tpl!pending_contact",
-            "tpl!requesting_contact",
-            "tpl!roster",
-            "tpl!roster_filter",
-            "tpl!roster_item",
-            "tpl!search_contact",
+            "templates/add_contact_modal.html",
+            "templates/group_header.html",
+            "templates/pending_contact.html",
+            "templates/requesting_contact.html",
+            "templates/roster.html",
+            "templates/roster_filter.html",
+            "templates/roster_item.html",
+            "templates/search_contact.html",
             "awesomplete",
             "converse-chatboxes",
             "converse-modal"

+ 1 - 1
src/converse-vcard.js

@@ -5,7 +5,7 @@
 // Licensed under the Mozilla Public License (MPLv2)
 
 (function (root, factory) {
-    define(["converse-core", "crypto", "tpl!vcard"], factory);
+    define(["converse-core", "crypto", "templates/vcard.html"], factory);
 }(this, function (converse, CryptoJS, tpl_vcard) {
     "use strict";
     const { Backbone, Promise, Strophe, SHA1, _, $iq, $build, b64_sha1, moment, sizzle } = converse.env;

+ 0 - 1
src/converse.js

@@ -21,7 +21,6 @@ if (typeof define !== 'undefined') {
         "converse-muc-views",
         "converse-muc-views",       // Views related to MUC
         "converse-notification",    // HTML5 Notifications
-        "converse-otr",             // Off-the-record encryption for one-on-one messages
         "converse-ping",            // XEP-0199 XMPP Ping
         "converse-roster",
         "converse-register",        // XEP-0077 In-band registration

+ 0 - 13
src/lodash.noconflict.js

@@ -1,17 +1,4 @@
 /*global define */
 define(['lodash'], function (_) {
-    if (!_.isUndefined(require) && !_.isUndefined(require.s)) {
-        /* XXX: This is a hack to make sure that the compiled templates have
-         * access to the _ object.
-         *
-         * Otherwise we sometimes get errors like this:
-         *
-         *    TypeError: Cannot read property 'escape' of undefined
-         *     at eval (./src/templates/chatroom_sidebar.html:6)
-         */
-        var lodashLoader = require.s.contexts._.config.lodashLoader;
-        lodashLoader.templateSettings.imports = { '_': _ };
-        require.config({'lodashLoader': lodashLoader});
-    }
     return _.noConflict();
 });

+ 4 - 4
src/utils/core.js

@@ -16,10 +16,10 @@
             "backbone",
             "strophe",
             "uri",
-            "tpl!audio",
-            "tpl!file",
-            "tpl!image",
-            "tpl!video"
+            "templates/audio.html",
+            "templates/file.html",
+            "templates/image.html",
+            "templates/video.html"
         ], factory);
     } else {
         // Used by the mockups

+ 9 - 9
src/utils/form.js

@@ -12,15 +12,15 @@
         "sizzle",
         "lodash.noconflict",
         "utils",
-        "tpl!field",
-        "tpl!select_option",
-        "tpl!form_select",
-        "tpl!form_textarea",
-        "tpl!form_checkbox",
-        "tpl!form_username",
-        "tpl!form_input",
-        "tpl!form_captcha",
-        "tpl!form_url",
+        "templates/field.html",
+        "templates/select_option.html",
+        "templates/form_select.html",
+        "templates/form_textarea.html",
+        "templates/form_checkbox.html",
+        "templates/form_username.html",
+        "templates/form_input.html",
+        "templates/form_captcha.html",
+        "templates/form_url.html",
     ], factory);
 }(this, function (
         sizzle,

+ 134 - 0
webpack.config.js

@@ -0,0 +1,134 @@
+/*global path, __dirname, module */
+'use strict'
+const path = require('path');
+
+const config = {
+    entry: path.resolve(__dirname, 'src/converse.js'),
+    externals: [{
+        "window": "window"
+    }],
+    output: {
+        path: path.resolve(__dirname, 'dist'),
+        filename: 'converse.js'
+    },
+    devtool: 'source-map',
+    module: {
+        rules: [{
+            test: /\.html$/,
+            exclude: /node_modules/,
+            use: [{
+                loader: 'lodash-template-webpack-loader',
+                options: {
+                    "escape": /\{\{\{([\s\S]+?)\}\}\}/g,
+                    "evaluate": /\{\[([\s\S]+?)\]\}/g,
+                    "interpolate": /\{\{([\s\S]+?)\}\}/g,
+                    // By default, template places the values from your data in the
+                    // local scope via the with statement. However, you can specify
+                    // a single variable name with the variable setting. This can
+                    // significantly improve the speed at which a template is able
+                    // to render.
+                    "variable": 'o',
+                    "prependFilenameComment": __dirname
+                }
+            }]
+        }, {
+            test: /\.js$/,
+            exclude: /(node_modules|spec|mockup)/,
+            use: {
+                loader: 'babel-loader',
+                options: {
+                    presets: [
+                        ["@babel/preset-env", {
+                            "targets": {
+                                "browsers": [">1%", "not ie 11", "not op_mini all"]
+                            }
+                        }]
+                    ]
+                }
+            }
+        }],
+    },
+    resolve: {
+        modules: [
+            'node_modules',
+            path.resolve(__dirname, "src"),
+        ],
+        alias: {
+            "IPv6":                     path.resolve(__dirname, "node_modules/urijs/src/IPv6"),
+            "SecondLevelDomains":       path.resolve(__dirname, "node_modules/urijs/src/SecondLevelDomains"),
+            "awesomplete":              path.resolve(__dirname, "node_modules/awesomplete-avoid-xss/awesomplete"),
+            "backbone":                 path.resolve(__dirname, "node_modules/backbone/backbone"),
+            "backbone.browserStorage":  path.resolve(__dirname, "node_modules/backbone.browserStorage/backbone.browserStorage"),
+            "backbone.nativeview":      path.resolve(__dirname, "node_modules/backbone.nativeview/backbone.nativeview"),
+            "backbone.noconflict":      path.resolve(__dirname, "src/backbone.noconflict"),
+            "backbone.orderedlistview": path.resolve(__dirname, "node_modules/backbone.overview/dist/backbone.orderedlistview"),
+            "backbone.overview":        path.resolve(__dirname, "node_modules/backbone.overview/dist/backbone.overview"),
+            "backbone.vdomview":        path.resolve(__dirname, "node_modules/backbone.vdomview/dist/backbone.vdomview"),
+            "bootstrap":                path.resolve(__dirname, "node_modules/bootstrap.native/dist/bootstrap-native-v4"),
+            "crypto":                   path.resolve(__dirname, "node_modules/otr/build/dep/crypto"),
+            "emojione":                 path.resolve(__dirname, "node_modules/emojione/lib/js/emojione"),
+            "es6-promise":              path.resolve(__dirname, "node_modules/es6-promise/dist/es6-promise.auto"),
+            "filesize":                 path.resolve(__dirname, "node_modules/filesize/lib/filesize"),
+            "form-utils":               path.resolve(__dirname, "src/utils/form"),
+            "i18n":                     path.resolve(__dirname, "src/i18n"),
+            "jed":                      path.resolve(__dirname, "node_modules/jed/jed"),
+            "jquery":                   path.resolve(__dirname, "src/jquery-stub"),
+            "lodash":                   path.resolve(__dirname, "node_modules/lodash/lodash"),
+            "lodash.converter":         path.resolve(__dirname, "3rdparty/lodash.fp"),
+            "lodash.fp":                path.resolve(__dirname, "src/lodash.fp"),
+            "lodash.noconflict":        path.resolve(__dirname, "src/lodash.noconflict"),
+            "message-utils":            path.resolve(__dirname, "src/utils/message"),
+            "muc-utils":                path.resolve(__dirname, "src/utils/muc"),
+            "pluggable":                path.resolve(__dirname, "node_modules/pluggable.js/dist/pluggable"),
+            "polyfill":                 path.resolve(__dirname, "src/polyfill"),
+            "punycode":                 path.resolve(__dirname, "node_modules/urijs/src/punycode"),
+            "sizzle":                   path.resolve(__dirname, "node_modules/sizzle/dist/sizzle"),
+            "snabbdom":                 path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom"),
+            "snabbdom-attributes":      path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-attributes"),
+            "snabbdom-class":           path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-class"),
+            "snabbdom-dataset":         path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-dataset"),
+            "snabbdom-eventlisteners":  path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-eventlisteners"),
+            "snabbdom-props":           path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-props"),
+            "snabbdom-style":           path.resolve(__dirname, "node_modules/snabbdom/dist/snabbdom-style"),
+            "strophe":                  path.resolve(__dirname, "node_modules/strophe.js/strophe"),
+            "strophe.ping":             path.resolve(__dirname, "node_modules/strophejs-plugin-ping/strophe.ping"),
+            "strophe.rsm":              path.resolve(__dirname, "node_modules/strophejs-plugin-rsm/strophe.rsm"),
+            "tovnode":                  path.resolve(__dirname, "node_modules/snabbdom/dist/tovnode"),
+            "underscore":               path.resolve(__dirname, "src/underscore-shim"),
+            "uri":                      path.resolve(__dirname, "node_modules/urijs/src/URI"),
+            "utils":                    path.resolve(__dirname, "src/utils/core"),
+            "vdom-parser":              path.resolve(__dirname, "node_modules/vdom-parser/dist"),
+            "xss":                      path.resolve(__dirname, "node_modules/xss/dist/xss"),
+            "xss.noconflict":           path.resolve(__dirname, "node_modules/xss.noconflict"),
+
+            "converse-bookmarks":       path.resolve(__dirname, "src/converse-bookmarks"),
+            "converse-chatboxes":       path.resolve(__dirname, "src/converse-chatboxes"),
+            "converse-caps":            path.resolve(__dirname, "src/converse-caps"),
+            "converse-chatview":        path.resolve(__dirname, "src/converse-chatview"),
+            "converse-controlbox":      path.resolve(__dirname, "src/converse-controlbox"),
+            "converse-core":            path.resolve(__dirname, "src/converse-core"),
+            "converse-disco":           path.resolve(__dirname, "src/converse-disco"),
+            "converse-dragresize":      path.resolve(__dirname, "src/converse-dragresize"),
+            "converse-embedded":        path.resolve(__dirname, "src/converse-embedded"),
+            "converse-fullscreen":      path.resolve(__dirname, "src/converse-fullscreen"),
+            "converse-headline":        path.resolve(__dirname, "src/converse-headline"),
+            "converse-mam":             path.resolve(__dirname, "src/converse-mam"),
+            "converse-message-view":    path.resolve(__dirname, "src/converse-message-view"),
+            "converse-minimize":        path.resolve(__dirname, "src/converse-minimize"),
+            "converse-modal":           path.resolve(__dirname, "src/converse-modal"),
+            "converse-muc":             path.resolve(__dirname, "src/converse-muc"),
+            "converse-muc-views":       path.resolve(__dirname, "src/converse-muc-views"),
+            "converse-notification":    path.resolve(__dirname, "src/converse-notification"),
+            "converse-ping":            path.resolve(__dirname, "src/converse-ping"),
+            "converse-profile":         path.resolve(__dirname, "src/converse-profile"),
+            "converse-register":        path.resolve(__dirname, "src/converse-register"),
+            "converse-roomslist":       path.resolve(__dirname, "src/converse-roomslist"),
+            "converse-roster":          path.resolve(__dirname, "src/converse-roster"),
+            "converse-rosterview":      path.resolve(__dirname, "src/converse-rosterview"),
+            "converse-singleton":       path.resolve(__dirname, "src/converse-singleton"),
+            "converse-vcard":           path.resolve(__dirname, "src/converse-vcard")
+        }
+    }
+}
+
+module.exports = config;

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно