You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2023/04/20 07:24:08 UTC
[jena] branch main updated: GH-1749: Replacing webpack chunks by Vite rollup
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new 18fa90e762 GH-1749: Replacing webpack chunks by Vite rollup
new be7de89557 Merge pull request #1845 from kinow/vue-vite-dynamic-imports
18fa90e762 is described below
commit 18fa90e762929598d76c58cea4a5bbe7b04e15e6
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Sun Apr 16 19:54:45 2023 +0200
GH-1749: Replacing webpack chunks by Vite rollup
---
jena-fuseki2/jena-fuseki-ui/cypress.config.js | 16 +++++-
jena-fuseki2/jena-fuseki-ui/src/router/index.js | 18 +++---
.../jena-fuseki-ui/tests/e2e/support/index.js | 2 +-
.../tests/e2e/support/vite-preprocessor.js | 64 ++++++++++++++++++++++
jena-fuseki2/jena-fuseki-ui/vite.config.js | 22 ++++++++
5 files changed, 109 insertions(+), 13 deletions(-)
diff --git a/jena-fuseki2/jena-fuseki-ui/cypress.config.js b/jena-fuseki2/jena-fuseki-ui/cypress.config.js
index 82a7e8f6ee..c00726b47d 100644
--- a/jena-fuseki2/jena-fuseki-ui/cypress.config.js
+++ b/jena-fuseki2/jena-fuseki-ui/cypress.config.js
@@ -16,7 +16,8 @@
*/
const { defineConfig } = require('cypress')
-const vitePreprocessor = require('cypress-vite')
+const vitePreprocessor = require('./tests/e2e/support/vite-preprocessor')
+const path = require('path')
module.exports = defineConfig({
video: false,
@@ -30,7 +31,13 @@ module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:' + (process.env.PORT || 8080),
setupNodeEvents (on, config) {
- on('file:preprocessor', vitePreprocessor())
+ // For test coverage
+ require('@cypress/code-coverage/task')(on, config)
+
+ on(
+ 'file:preprocessor',
+ vitePreprocessor(path.resolve(__dirname, 'vite.config.js'))
+ )
return require('./tests/e2e/plugins/index.js')(on, config)
},
specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}',
@@ -39,7 +46,10 @@ module.exports = defineConfig({
videosFolder: 'tests/e2e/videos',
supportFile: 'tests/e2e/support/index.js',
},
-
+ components: {
+ framework: 'vue',
+ bundler: 'vite'
+ },
env: {
codeCoverage: {
exclude: [
diff --git a/jena-fuseki2/jena-fuseki-ui/src/router/index.js b/jena-fuseki2/jena-fuseki-ui/src/router/index.js
index 2143b76323..f77cb38f5b 100644
--- a/jena-fuseki2/jena-fuseki-ui/src/router/index.js
+++ b/jena-fuseki2/jena-fuseki-ui/src/router/index.js
@@ -28,7 +28,7 @@ const routes = [
{
path: '/dataset/:datasetName/query',
name: 'DatasetQuery',
- component: () => import(/* webpackChunkName: "datasetQuery" */ '../views/dataset/Query.vue'),
+ component: () => import('../views/dataset/Query.vue'),
props: true
},
{
@@ -36,46 +36,46 @@ const routes = [
// query parameter, e.g. /#/dataset/abc/query?query=SELECT...
path: '/dataset/:datasetName/query*',
name: 'DatasetQueryParameters',
- component: () => import(/* webpackChunkName: "datasetQuery" */ '../views/dataset/Query.vue'),
+ component: () => import('../views/dataset/Query.vue'),
props: true
},
{
path: '/dataset/:datasetName/upload',
name: 'DatasetUpload',
- component: () => import(/* webpackChunkName: "datasetUpload" */ '../views/dataset/Upload.vue'),
+ component: () => import('../views/dataset/Upload.vue'),
props: true
},
{
path: '/dataset/:datasetName/edit',
name: 'DatasetEdit',
- component: () => import(/* webpackChunkName: "datasetEdit" */ '../views/dataset/Edit.vue'),
+ component: () => import('../views/dataset/Edit.vue'),
props: true
},
{
path: '/dataset/:datasetName/info',
name: 'DatasetInfo',
- component: () => import(/* webpackChunkName: "datasetInfo" */ '../views/dataset/Info.vue'),
+ component: () => import('../views/dataset/Info.vue'),
props: true
},
{
path: '/manage',
name: 'ManageDatasets',
- component: () => import(/* webpackChunkName: "manageDatasets" */ '../views/manage/ExistingDatasets.vue')
+ component: () => import('../views/manage/ExistingDatasets.vue')
},
{
path: '/manage/new',
name: 'NewDataset',
- component: () => import(/* webpackChunkName: "newDataset" */ '../views/manage/NewDataset.vue')
+ component: () => import('../views/manage/NewDataset.vue')
},
{
path: '/manage/tasks',
name: 'Tasks',
- component: () => import(/* webpackChunkName: "tasks" */ '../views/manage/Tasks.vue')
+ component: () => import('../views/manage/Tasks.vue')
},
{
path: '/documentation',
name: 'Help',
- component: () => import(/* webpackChunkName: "documentation" */ '../views/Help.vue')
+ component: () => import('../views/Help.vue')
},
{
path: '/:pathMatch(.*)*',
diff --git a/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/index.js b/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/index.js
index ee3c9b8686..e7ed605d59 100644
--- a/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/index.js
+++ b/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/index.js
@@ -30,7 +30,7 @@
// https://on.cypress.io/configuration
// ***********************************************************
-import '@cypress/code-coverage/support'
+// import '@cypress/code-coverage/support'
// Import commands.js using ES2015 syntax:
import './commands'
diff --git a/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/vite-preprocessor.js b/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/vite-preprocessor.js
new file mode 100644
index 0000000000..b57b436a4b
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-ui/tests/e2e/support/vite-preprocessor.js
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const path = require('path')
+const vite = require('vite')
+
+function vitePreprocessor (userConfigPath) {
+ return async (file) => {
+ const { filePath, outputPath } = file
+ const fileName = path.basename(outputPath)
+ const filenameWithoutExtension = path.basename(
+ outputPath,
+ path.extname(outputPath)
+ )
+
+ const defaultConfig = vite.defineConfig({
+ logLevel: 'warn',
+ define: {
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
+ },
+ build: {
+ emptyOutDir: false,
+ minify: false,
+ outDir: path.dirname(outputPath),
+ sourcemap: true,
+ write: true,
+ rollupOptions: {
+ output: {
+ inlineDynamicImports: false
+ }
+ },
+ lib: {
+ entry: filePath,
+ fileName: () => fileName,
+ formats: ['es'],
+ name: filenameWithoutExtension
+ }
+ }
+ })
+
+ await vite.build({
+ configFile: userConfigPath,
+ ...defaultConfig
+ })
+
+ return outputPath
+ }
+}
+
+module.exports = vitePreprocessor
diff --git a/jena-fuseki2/jena-fuseki-ui/vite.config.js b/jena-fuseki2/jena-fuseki-ui/vite.config.js
index 8e6142bf40..612de16ad8 100644
--- a/jena-fuseki2/jena-fuseki-ui/vite.config.js
+++ b/jena-fuseki2/jena-fuseki-ui/vite.config.js
@@ -52,6 +52,28 @@ export default defineConfig({
outDir: 'target/webapp',
assetsDir: 'static',
sourcemap: 'inline',
+ // https://router.vuejs.org/guide/advanced/lazy-loading.html
+ rollupOptions: {
+ // https://rollupjs.org/guide/en/#outputmanualchunks
+ output: {
+ manualChunks: {
+ queryDataset: [
+ 'src/views/manage/ExistingDatasets.vue',
+ 'src/views/dataset/Query.vue'
+ ],
+ manageDataset: [
+ 'src/views/manage/NewDataset.vue',
+ 'src/views/dataset/Upload.vue',
+ 'src/views/dataset/Edit.vue',
+ 'src/views/dataset/Info.vue'
+ ],
+ other: [
+ 'src/views/manage/Tasks.vue',
+ 'src/views/Help.vue'
+ ]
+ }
+ }
+ }
},
server: {
// Default, can be overridden by `--port 1234` in package.json