From 0e57205ea5a80393c5c16629953d94586cbc9f60 Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 00:16:47 -0400 Subject: [PATCH 01/19] Implement naive code splitting Signed-off-by: Marcel Robitaille --- src/router/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 48e7ff47f..b8ebecf4b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -7,11 +7,11 @@ import Vue from "vue" import VueRouter from "vue-router" -import Index from "../components/AppIndex.vue" -import NotFound from "../components/NotFound.vue" -import RecipeView from "../components/RecipeView.vue" -import RecipeEdit from "../components/RecipeEdit.vue" -import Search from "../components/SearchResults.vue" +const Index = () => import(/* webpackPrefetch: true */ "../components/AppIndex.vue") +const NotFound = () => import(/* webpackPrefetch: true */ "../components/NotFound.vue") +const RecipeView = () => import(/* webpackPrefetch: true */ "../components/RecipeView.vue") +const RecipeEdit = () => import(/* webpackPrefetch: true */ "../components/RecipeEdit.vue") +const Search = () => import(/* webpackPrefetch: true */ "../components/SearchResults.vue") Vue.use(VueRouter) From 896a232b5bd677ef2feb6f2fc90eac7d6601d516 Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 00:49:56 -0400 Subject: [PATCH 02/19] Dynamically load moment locales Signed-off-by: Marcel Robitaille --- src/main.js | 4 ++++ webpack.config.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/main.js b/src/main.js index 306ea61ee..8487314db 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,7 @@ // Markdown import VueShowdown from "vue-showdown" +import moment from 'moment' import Vue from "vue" @@ -32,6 +33,9 @@ __webpack_nonce__ = btoa(OC.requestToken) helpers.useRouter(router) +const locale = document.documentElement.getAttribute('data-locale') +import(`moment/locale/${locale}.js`).then(() => moment.locale(locale)) + // A simple function to sanitize HTML tags // eslint-disable-next-line no-param-reassign window.escapeHTML = helpers.escapeHTML diff --git a/webpack.config.js b/webpack.config.js index 2eeea9c77..5a5f5a807 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,6 +29,9 @@ function cookbookConfig (env) { '__webpack_use_dev_server__': env.dev_server || false, 'verboseDebugLogging': isDev && (process.env.VERBOSE || false), }), + // Don't import all locales at once + // Only the needed locale is dynamically loaded later + new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), ], resolve: { 'alias': { From 0207accacb9691ca1bf779b1975f2cae14e4560b Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 01:05:24 -0400 Subject: [PATCH 03/19] Ignore calendar-js Signed-off-by: Marcel Robitaille --- webpack.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack.config.js b/webpack.config.js index 5a5f5a807..2dc724b02 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -32,6 +32,7 @@ function cookbookConfig (env) { // Don't import all locales at once // Only the needed locale is dynamically loaded later new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), + new webpack.IgnorePlugin({ resourceRegExp: /calendar-js/ }), ], resolve: { 'alias': { From f6226cce8e7db0575ad4ddd774c02f5c8427ac35 Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 15:08:20 -0400 Subject: [PATCH 04/19] Ignore DatetimePicker Signed-off-by: Marcel Robitaille --- webpack.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack.config.js b/webpack.config.js index 2dc724b02..6f5619efb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -33,6 +33,7 @@ function cookbookConfig (env) { // Only the needed locale is dynamically loaded later new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), new webpack.IgnorePlugin({ resourceRegExp: /calendar-js/ }), + new webpack.IgnorePlugin({ resourceRegExp: /DatetimePicker/ }), ], resolve: { 'alias': { From 409bde7f20b60123618124a1632a1f9c2e57a728 Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 15:57:00 -0400 Subject: [PATCH 05/19] Fix dynamically loading moment locale `en` is the default and cannot be dynamically loaded Signed-off-by: Marcel Robitaille --- src/main.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 8487314db..6d1badb6a 100644 --- a/src/main.js +++ b/src/main.js @@ -33,8 +33,16 @@ __webpack_nonce__ = btoa(OC.requestToken) helpers.useRouter(router) -const locale = document.documentElement.getAttribute('data-locale') -import(`moment/locale/${locale}.js`).then(() => moment.locale(locale)) +const locale = document.documentElement + .getAttribute("data-locale") + .replace("_", "-") + .toLowerCase() +;// `en` is the default locale and cannot be dynamically imported. Will 404 +// https://github.com/moment/moment/issues/3624 +(locale === "en" + ? Promise.resolve() + : import(`moment/locale/${locale}.js`) +).then(() => moment.locale(locale)) // A simple function to sanitize HTML tags // eslint-disable-next-line no-param-reassign From 7c4aa37660d79e979d34e115ba4e88fe2a923fc8 Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 15:59:01 -0400 Subject: [PATCH 06/19] Only load markdown editor where needed (RecipeView) Signed-off-by: Marcel Robitaille --- src/components/RecipeView.vue | 9 +++++++++ src/main.js | 9 +-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/RecipeView.vue b/src/components/RecipeView.vue index 2b24a7ff9..0665e63cf 100644 --- a/src/components/RecipeView.vue +++ b/src/components/RecipeView.vue @@ -254,7 +254,9 @@ + + From bf70e5568bc87daec93dd3c48ac8cfb9f9e5c41f Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 16:52:37 -0400 Subject: [PATCH 08/19] Remove webpack IgnorePlugins These are not needed with SimpleActionInput Signed-off-by: Marcel Robitaille --- webpack.config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 6f5619efb..5a5f5a807 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -32,8 +32,6 @@ function cookbookConfig (env) { // Don't import all locales at once // Only the needed locale is dynamically loaded later new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), - new webpack.IgnorePlugin({ resourceRegExp: /calendar-js/ }), - new webpack.IgnorePlugin({ resourceRegExp: /DatetimePicker/ }), ], resolve: { 'alias': { From 6126792ccdd802953ec971611744e36e5a5d44cf Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Tue, 26 Jul 2022 16:53:16 -0400 Subject: [PATCH 09/19] Run prettier Signed-off-by: Marcel Robitaille --- src/components/SimpleActionInput.vue | 447 +++++++++++++-------------- src/main.js | 5 +- src/router/index.js | 15 +- 3 files changed, 235 insertions(+), 232 deletions(-) diff --git a/src/components/SimpleActionInput.vue b/src/components/SimpleActionInput.vue index 72767d7b8..25351389f 100644 --- a/src/components/SimpleActionInput.vue +++ b/src/components/SimpleActionInput.vue @@ -34,46 +34,49 @@