From 5cd2c72e1a3cabbaa9fb9acc64f5aeb61cb8e3bb Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Sat, 17 Dec 2022 23:08:06 +0100 Subject: [PATCH] Use ES2021 imports in our code --- aleksis/core/assets/app.js | 3 ++- aleksis/core/assets/components/SidenavSearch.vue | 4 +++- aleksis/core/assets/components/about/InstalledAppsList.vue | 3 ++- .../assets/components/celery_progress/CeleryProgress.vue | 6 ++++-- .../components/celery_progress/CeleryProgressBottom.vue | 3 ++- .../assets/components/notifications/NotificationItem.vue | 4 +++- .../assets/components/notifications/NotificationList.vue | 3 ++- aleksis/core/management/commands/vite_bundle.py | 2 +- aleksis/core/templates/core/vue_base.html | 2 +- aleksis/core/vite.config.js | 5 +++++ 10 files changed, 25 insertions(+), 10 deletions(-) diff --git a/aleksis/core/assets/app.js b/aleksis/core/assets/app.js index 3fda256d7..8d219967f 100644 --- a/aleksis/core/assets/app.js +++ b/aleksis/core/assets/app.js @@ -84,6 +84,7 @@ import MessageBox from "./components/MessageBox.vue"; import NotificationList from "./components/notifications/NotificationList.vue"; import SidenavSearch from "./components/SidenavSearch.vue"; import CeleryProgressBottom from "./components/celery_progress/CeleryProgressBottom.vue"; +import gqlSystemProperties from "./systemProperties.graphql"; Vue.component(MessageBox.name, MessageBox); // Load MessageBox globally as other components depend on it @@ -118,7 +119,7 @@ const app = new Vue({ }, }), apollo: { - systemProperties: require("./systemProperties.graphql"), + systemProperties: gqlSystemProperties, }, watch: { systemProperties: function (newProperties) { diff --git a/aleksis/core/assets/components/SidenavSearch.vue b/aleksis/core/assets/components/SidenavSearch.vue index 58bf7bf6d..ea044a9b6 100644 --- a/aleksis/core/assets/components/SidenavSearch.vue +++ b/aleksis/core/assets/components/SidenavSearch.vue @@ -1,4 +1,6 @@ <script> +import gqlSearchSnippets from "./searchSnippets.graphql"; + export default { methods: { submit: function () { @@ -22,7 +24,7 @@ export default { <template> <ApolloQuery - :query="require('./searchSnippets.graphql')" + :query="gqlSearchSnippets" :variables="{ q, }" diff --git a/aleksis/core/assets/components/about/InstalledAppsList.vue b/aleksis/core/assets/components/about/InstalledAppsList.vue index 491e3df15..704eedc97 100644 --- a/aleksis/core/assets/components/about/InstalledAppsList.vue +++ b/aleksis/core/assets/components/about/InstalledAppsList.vue @@ -1,5 +1,5 @@ <template> - <ApolloQuery :query="require('./installedApps.graphql')"> + <ApolloQuery :query="gqlInstalledApps"> <template #default="{ result: { error, data }, isLoading }"> <v-row v-if="isLoading"> <v-col @@ -31,6 +31,7 @@ <script> import InstalledAppCard from "./InstalledAppCard.vue"; +import gqlInstalledApps from "./installedApps.graphql"; export default { name: "InstalledAppsList", diff --git a/aleksis/core/assets/components/celery_progress/CeleryProgress.vue b/aleksis/core/assets/components/celery_progress/CeleryProgress.vue index 06b28fc37..86cc12847 100644 --- a/aleksis/core/assets/components/celery_progress/CeleryProgress.vue +++ b/aleksis/core/assets/components/celery_progress/CeleryProgress.vue @@ -86,13 +86,15 @@ <script> import BackButton from "../BackButton.vue"; import MessageBox from "../MessageBox.vue"; +import gqlCeleryProgress from "./celeryProgress.graphql"; +import gqlCeleryProgressFetched from "./celeryProgressFetched.graphql"; export default { name: "CeleryProgress", components: { BackButton, MessageBox }, apollo: { celeryProgressByTaskId: { - query: require("./celeryProgress.graphql"), + query: gqlCeleryProgress, variables() { return { taskId: this.$route.params.taskId, @@ -114,7 +116,7 @@ export default { if (newState === "SUCCESS" || newState === "ERROR") { this.$apollo.queries.celeryProgressByTaskId.stopPolling(); this.$apollo.mutate({ - mutation: require("./celeryProgressFetched.graphql"), + mutation: gqlCeleryProgressFetched, variables: { taskId: this.$route.params.taskId, }, diff --git a/aleksis/core/assets/components/celery_progress/CeleryProgressBottom.vue b/aleksis/core/assets/components/celery_progress/CeleryProgressBottom.vue index 2bb95431c..410e57fda 100644 --- a/aleksis/core/assets/components/celery_progress/CeleryProgressBottom.vue +++ b/aleksis/core/assets/components/celery_progress/CeleryProgressBottom.vue @@ -25,6 +25,7 @@ <script> import TaskListItem from "./TaskListItem.vue"; +import gqlCeleryProgressButton from "./celeryProgressBottom.graphql"; export default { name: "CeleryProgressBottom", @@ -45,7 +46,7 @@ export default { }, apollo: { celeryProgressByUser: { - query: require("./celeryProgressBottom.graphql"), + query: gqlCeleryProgressButton, pollInterval: 1000, }, }, diff --git a/aleksis/core/assets/components/notifications/NotificationItem.vue b/aleksis/core/assets/components/notifications/NotificationItem.vue index 3659f1f27..28ed66f15 100644 --- a/aleksis/core/assets/components/notifications/NotificationItem.vue +++ b/aleksis/core/assets/components/notifications/NotificationItem.vue @@ -1,6 +1,6 @@ <template> <ApolloMutation - :mutation="require('./markNotificationRead.graphql')" + :mutation="gqlmarkNotificationRead" :variables="{ id: this.notification.id }" > <template #default="{ mutate, loading, error }"> @@ -33,6 +33,8 @@ </template> <script> +import gqlMarkNotificationRead from "./markNotificationRead.graphql"; + export default { props: { notification: { diff --git a/aleksis/core/assets/components/notifications/NotificationList.vue b/aleksis/core/assets/components/notifications/NotificationList.vue index 9e057ef7f..20a40dd93 100644 --- a/aleksis/core/assets/components/notifications/NotificationList.vue +++ b/aleksis/core/assets/components/notifications/NotificationList.vue @@ -1,6 +1,6 @@ <template> <ApolloQuery - :query="require('./myNotifications.graphql')" + :query="gqlMyNotifications" :poll-interval="1000" > <template #default="{ result: { error, data }, isLoading }"> @@ -20,6 +20,7 @@ <script> import NotificationItem from "./NotificationItem.vue"; +import gqlMyNotifications from "./myNotifications.graphql"; export default { components: { diff --git a/aleksis/core/management/commands/vite_bundle.py b/aleksis/core/management/commands/vite_bundle.py index 07beab7ea..c230fc2f4 100644 --- a/aleksis/core/management/commands/vite_bundle.py +++ b/aleksis/core/management/commands/vite_bundle.py @@ -36,4 +36,4 @@ class Command(BaseYarnCommand): config_path = os.path.join(settings.BASE_DIR, "aleksis", "core", "vite.config.js") shutil.copy(config_path, settings.NODE_MODULES_ROOT) mode = "development" if settings.DEBUG else "production" - yarn_adapter.call_yarn(["run", "vite", "build", "-m", mode, "-l", "info", "-d"]) + yarn_adapter.call_yarn(["run", "vite", "build", "-m", mode]) diff --git a/aleksis/core/templates/core/vue_base.html b/aleksis/core/templates/core/vue_base.html index f741ef151..bc56f956a 100644 --- a/aleksis/core/templates/core/vue_base.html +++ b/aleksis/core/templates/core/vue_base.html @@ -224,7 +224,7 @@ {{ request.site.preferences.theme__primary|json_script:"primary-color" }} {{ request.site.preferences.theme__secondary|json_script:"secondary-color" }} <script type="text/javascript" src="{% static 'js/search.js' %}"></script> -{% vite_asset 'core' %} +{% vite_asset '../aleksis/core/assets/index.js' %} {% block extra_body %}{% endblock %} </body> </html> diff --git a/aleksis/core/vite.config.js b/aleksis/core/vite.config.js index b290bb1c7..5f1e70183 100644 --- a/aleksis/core/vite.config.js +++ b/aleksis/core/vite.config.js @@ -19,4 +19,9 @@ export default defineConfig({ }, }, plugins: [vue()], + resolve: { + alias: { + "vue": "vue/dist/vue.esm.js", + }, + }, }); -- GitLab