You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "capistrant (via GitHub)" <gi...@apache.org> on 2026/04/14 22:08:44 UTC

[PR] build: Proposal to move from webpack to vite (druid)

capistrant opened a new pull request, #19315:
URL: https://github.com/apache/druid/pull/19315

   <!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. -->
   
   <!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. -->
   
   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for committers:
   https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->
   
   ### Description
   
   <!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. -->
   
   <!-- Describe your patch: what did you change in code? How did you fix the problem? -->
   
   <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: -->
   
   Draft code inspired by a question from @jtuglu1 https://github.com/apache/druid/pull/19312#issuecomment-4246538489. I took it literally and used a claude session to plan and execute this proposed move to Vite. This was very much an exercise born out of curiosity so I am opening this for CI to run and will put in in Draft as I self review it and look for feedback regarding the webpack versus vite discussion. I did do basic testing locally where I had the vite dev server running locally and was making changes and seeing the millisecond response time from change to seeing it in my local. Even so, a larger discussion is warranted and there would likely be follow ups. The plan my session put in place marked multiple things as bridge solutions to minimize the changeset, but would require follow ups to fully leverage vite.
   
   <!--
   In each section, please describe design decisions made, including:
    - Choice of algorithms
    - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources?
    - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns)
    - Method organization and design (how the logic is split between methods, parameters and return types)
    - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
   -->
   
   
   <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
   
   <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
   
   #### Release note
   <!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users. 
   
   If your change doesn't have end user impact, you can skip this section.
   
   For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
   
   -->
   
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `MyFoo`
    * `OurBar`
    * `TheirBaz`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] build: Proposal to move from webpack to vite (druid)

Posted by "capistrant (via GitHub) via commits" <co...@druid.apache.org>.
capistrant closed pull request #19315: build: Proposal to move from webpack to vite
URL: https://github.com/apache/druid/pull/19315


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] build: Proposal to move from webpack to vite (druid)

Posted by "Fly-Style (via GitHub)" <gi...@apache.org>.
Fly-Style commented on PR #19315:
URL: https://github.com/apache/druid/pull/19315#issuecomment-4249881802

   My 50 cents here: vite 8 uses `rolldown`, which reduces build time for tens of percent.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] build: Proposal to move from webpack to vite (druid)

Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19315:
URL: https://github.com/apache/druid/pull/19315#discussion_r3558729463


##########
web-console/package.json:
##########
@@ -141,24 +140,18 @@
     "license-checker": "^25.0.1",
     "playwright-chromium": "^1.24.1",
     "postcss": "^8.4.47",
-    "postcss-loader": "^5.3.0",
     "postcss-preset-env": "^10.0.7",
     "prettier": "^2.5.1",
     "react-shallow-renderer": "^16.15.0",
     "replace": "^1.2.2",
-    "sass": "^1.59.3",
-    "sass-loader": "^13.2.0",
+    "sass": "^1.99.0",
     "snarkdown": "^2.0.0",
-    "style-loader": "^2.0.0",
     "stylelint": "^16.1.0",
     "ts-jest": "^29.2.5",
-    "ts-loader": "^9.5.1",
     "ts-node": "^10.9.2",
     "typescript": "~5.5.4",
-    "webpack": "^5.89.0",
-    "webpack-bundle-analyzer": "^4.10.1",
-    "webpack-cli": "^5.1.4",
-    "webpack-dev-server": "^5.2.2"
+    "vite": "^8.1.4",

Review Comment:
   [P1] Align the declared Node engine with Vite 8
   
   The locked Vite version requires Node `^20.19.0 || >=22.12.0`, while the package still advertises `>=20`; Node 20.0-20.18 users therefore satisfy the project constraint but cannot reliably build or start the console.



##########
web-console/script/build:
##########
@@ -72,9 +72,9 @@ else
 fi
 
 if [ "$BUILD_CONSOLE" = true ]; then
-  echo "Webpacking everything..."
-  NODE_ENV=production ./node_modules/.bin/webpack -c webpack.config.mjs --mode=production
+  echo "Building with Vite..."
+  NODE_ENV=production ./node_modules/.bin/vite build

Review Comment:
   [P2] Keep TypeScript errors fatal during builds
   
   `vite build` transpiles without type-checking, unlike the removed `ts-loader` path. Maven CI runs `test-ci` without `tsc --noEmit`, allowing errors in untested source files to be packaged.



##########
web-console/vite.config.mts:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+import react from '@vitejs/plugin-react';
+import { readFileSync } from 'fs';
+import postcssPresetEnv from 'postcss-preset-env';
+import * as sass from 'sass';
+import { defineConfig } from 'vite';
+import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
+
+const version = JSON.parse(readFileSync('./package.json', 'utf-8')).version;
+
+export default defineConfig(({ mode }) => {
+  let druidUrl = process.env.druid_host || 'localhost';
+  if (!druidUrl.startsWith('http')) {
+    druidUrl = (druidUrl.endsWith(':9088') ? 'https://' : 'http://') + druidUrl;
+  }
+  if (!/:\d+$/.test(druidUrl)) {
+    druidUrl += druidUrl.startsWith('https://') ? ':9088' : ':8888';
+  }
+
+  console.log(`Vite running in ${mode} mode.`);
+
+  return {
+    publicDir: false,
+
+    build: {
+      outDir: 'public',
+      emptyOutDir: true,
+      sourcemap: mode === 'development' ? 'inline' : false,
+      target: 'es2016',
+      cssCodeSplit: false,
+      chunkSizeWarningLimit: Infinity,
+      rollupOptions: {
+        input: 'src/entry.tsx',
+        output: {
+          entryFileNames: `web-console-${version}.js`,
+          codeSplitting: false,
+          assetFileNames: (assetInfo) => {
+            if (/\.(woff2?|ttf|eot)$/.test(assetInfo.name || '')) {
+              return 'fonts/[name][extname]';

Review Comment:
   [P2] Generate font URLs under the served /public path
   
   With Vite's default base, imported Fontsource CSS points to `/fonts/...`, while files are emitted under `public/fonts` and Jetty exposes only `/public/*`; production font requests will return 404.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] build: Proposal to move from webpack to vite (druid)

Posted by "jgoz (via GitHub)" <gi...@apache.org>.
jgoz commented on code in PR #19315:
URL: https://github.com/apache/druid/pull/19315#discussion_r3249894261


##########
web-console/vite.config.mts:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+import react from '@vitejs/plugin-react';
+import { readFileSync } from 'fs';
+import postcssPresetEnv from 'postcss-preset-env';
+import * as sass from 'sass';
+import { defineConfig } from 'vite';
+import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
+
+const version = JSON.parse(readFileSync('./package.json', 'utf-8')).version;
+
+export default defineConfig(({ mode }) => {
+  let druidUrl = process.env.druid_host || 'localhost';
+  if (!druidUrl.startsWith('http')) {
+    druidUrl = (druidUrl.endsWith(':9088') ? 'https://' : 'http://') + druidUrl;
+  }
+  if (!/:\d+$/.test(druidUrl)) {
+    druidUrl += druidUrl.startsWith('https://') ? ':9088' : ':8888';
+  }
+
+  console.log(`Vite running in ${mode} mode.`);
+
+  return {
+    publicDir: false,
+
+    build: {
+      outDir: 'public',
+      emptyOutDir: true,
+      sourcemap: mode === 'development' ? 'inline' : false,
+      target: 'es2016',
+      cssCodeSplit: false,
+      chunkSizeWarningLimit: Infinity,
+      rollupOptions: {
+        input: 'src/entry.tsx',
+        output: {
+          entryFileNames: `web-console-${version}.js`,
+          // @ts-expect-error -- Rolldown option, not in Rollup types

Review Comment:
   This gets reported as unused when I clone locally, so I think the option actually does exist. Should be safe to delete.
   
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org