Skip to content

Conversation

ViliusS
Copy link
Contributor

@ViliusS ViliusS commented Jul 22, 2025

This should fix an issue reported on the mailing list, where Monaco Editor resources are loaded from CDN and thus blocked by CSP policy.

It uses the same mechanics as described in https://github.com/suren-atoyan/monaco-react?tab=readme-ov-file#use-monaco-editor-as-an-npm-package

I'm leaving this as draft as I could not test it fully due to this build failure (it was the same before my changes):
Module not found: Error: Can't resolve 'artemis-console-plugin/styles' in 'C:\Users\myuser\git\activemq-artemis-console\artemis-console-extension\artemis-extension\app\src'
Looks like artemis-console-plugin/styles is not public.

@GChuf
Copy link
Contributor

GChuf commented Jul 22, 2025

Did you try removing and cloning the repository again, and then running yarn install? there were some major changes to project structure a while ago.

Running yarn build produces this with your patch:

C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension>yarn build
[artemis-console-plugin]: Process started
[artemis-console-plugin]: CLI Building entry: src/index.ts
[artemis-console-plugin]: CLI Using tsconfig: tsconfig.json
[artemis-console-plugin]: CLI tsup v8.4.0
[artemis-console-plugin]: CLI Using tsup config: C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\packages\artemis-console-plugin\tsup.config.ts
[artemis-console-plugin]: CLI Target: esnext
[artemis-console-plugin]: CLI Cleaning output folder
[artemis-console-plugin]: CJS Build start
[artemis-console-plugin]: DTS Build start
[artemis-console-plugin]: X [ERROR] No matching export in "../../node_modules/@monaco-editor/react/dist/index.mjs" for import "monacoLoader"
[artemis-console-plugin]:
[artemis-console-plugin]:     src/messages/SendMessage.tsx:20:9:
[artemis-console-plugin]:       20 │ import { monacoLoader } from '@monaco-editor/react'
[artemis-console-plugin]:          ╵          ~~~~~~~~~~~~
[artemis-console-plugin]:
[artemis-console-plugin]: CJS Build failed
[artemis-console-plugin]: Error: Build failed with 1 error:
[artemis-console-plugin]: src/messages/SendMessage.tsx:20:9: ERROR: No matching export in "../../node_modules/@monaco-editor/react/dist/index.mjs" for import "monacoLoader"
[artemis-console-plugin]:     at failureErrorWithLog (C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:1477:15)
[artemis-console-plugin]:     at C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:946:25
[artemis-console-plugin]:     at runOnEndCallbacks (C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:1317:45)
[artemis-console-plugin]:     at buildResponseToResult (C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:944:7)
[artemis-console-plugin]:     at C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:971:16
[artemis-console-plugin]:     at responseCallbacks.<computed> (C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:623:9)
[artemis-console-plugin]:     at handleIncomingPacket (C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:678:12)
[artemis-console-plugin]:     at Socket.readFromStdout (C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\esbuild\lib\main.js:601:7)
[artemis-console-plugin]:     at Socket.emit (node:events:518:28)
[artemis-console-plugin]:     at addChunk (node:internal/streams/readable:561:12)
[artemis-console-plugin]: Unknown input options: onLog. Allowed options: acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, maxParallelFileReads, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch
[artemis-console-plugin]: DTS ⚡️ Build success in 6133ms
[artemis-console-plugin]: DTS dist\index.d.ts 105.00 B
[artemis-console-plugin]: Process exited (exit code 1), completed in 7s 290ms
The command failed in workspace artemis-console-plugin@workspace:packages/artemis-console-plugin with exit code 1
The command failed for workspaces that are depended upon by other workspaces; can't satisfy the dependency graph
Failed with errors in 7s 299ms

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 22, 2025

OK, I managed to build artemis-console-plugin but I've stumbled on another issue with webpack (maybe my NPM/Node.js version is not compatible). While I fix that, can you try with latest commit? I've fixed the issue you are seeing.

@GChuf
Copy link
Contributor

GChuf commented Jul 22, 2025

Tested, I also see some errors reported by webpack:

[artemis-console-app]: C:\git\activemq-artemis-console\artemis-console-extension\artemis-extension\node_modules\webpack\lib\stats\DefaultStatsPrinterPlugin.js:1424
[artemis-console-app]:                          (match, content) => match.replace(content, format(content))
[artemis-console-app]:                                                    ^
[artemis-console-app]:
[artemis-console-app]: RangeError: Invalid string length

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 23, 2025

Well... I give up.

My change compiles when running locally on development webpack configuration, but I'm unable to test it because I don't have working Artemis instance locally.
If I try to compile it using production webpack configuration to produce WAR something goes wrong, however I cannot see what exactly because webpack breaks with the error @GChuf you are seeing. Webpack probably tries to parse the error message but it is too large to fit into String.

I will leave this for a better day or a more knowledgeable JavaScript expert.

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 23, 2025

Looks like it was fixed in Hawtio-Next https://github.com/hawtio/hawtio-next/pull/1187/files by I have no idea why it doesn't work in Artemis Console. The closest I get to an actual error is:

[artemis-console-app]: ERROR in ../packages/artemis-console-plugin/dist/index.d.ts 1:9
[artemis-console-app]: Module parse failed: Export 'artemis' is not defined (1:9)
[artemis-console-app]: File was processed with these loaders:
[artemis-console-app]:  * ../node_modules/swc-loader/src/index.js
[artemis-console-app]: You may need an additional loader to handle the result of these loaders.
[artemis-console-app]: > export { artemis };

@GChuf
Copy link
Contributor

GChuf commented Jul 24, 2025

@ViliusS That's a nice catch - but I don't think the code that you linked from hawtio makes it into artemis - we have our "own" SendMessage.tsx. I'm thinking webpack config in artemis might be problematic?
That aside, I was looking at the error again yesterday and I didn't get anywhere. I think it might be worth considering dropping monaco altogether and just use some react components instead ...

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 25, 2025

I spend another 10 hours and reorganized dependencies according to https://github.com/hawtio/hawtio-next/blob/main/app/README.md . This fixed a build error.
Sadly Monaco editor is still included from CDN. There is something fundamentally wrong with webpack configuration:

  1. When it creates optimized chunks the monaco chunk is created correctly, however real UI never uses it. PatternFly chunk are used instead, and these other chunks have @monaco-editor/loader pulled in.
  2. Unless PatternFly peerDependencies are specified they is pulled in from @hawtio/react, increases index.js considerably and breaks the build. This is fixed in @hawtio/react 1.10.0, but I cannot get it to work with Artemis console.

@ViliusS ViliusS marked this pull request as ready for review July 26, 2025 10:17
@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 26, 2025

I think I fixed it. Had to completely wipe out node_modules. The only minor issue I didn't found solution for is that Monaco worker files are put into root HTML folder and are not minimized.
On the other hand, dev dependencies are not pulled in to JS bundles now, so they are much smaller and there are less of them.

@GChuf
Copy link
Contributor

GChuf commented Jul 26, 2025

I can confirm that sending msg through frontend works (in yarn start mode at least, so development build)

The resulting js bundle for patternfly is smaller, and the monaco js files ARE minified for production builds - for example, html.worker.js is 1074KB.
Both static/js and static/css folders are smaller now. Comparing production "build" folders for branch main and this branch:

main: 22.4MB, 50 files
vilius/ARTEMIS-5569: 21.4MB, 53 files
(looks great to me)

p.s. I have some issues on login screen on both branches though, but it seems the errors are not always the same ...
Right now I got "Unknown promise rejection reason". I solved it by tabbing through the fields and clicking enter on login ...
Not sure whats going on here. Can you confirm if you're seeing the same stuff or not?

image

@GChuf
Copy link
Contributor

GChuf commented Jul 26, 2025

p.s. node_modules folder in this branch is 477MB / 72k files instead of 649MB/195k files in main!

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 27, 2025

p.s. I have some issues on login screen on both branches though, but it seems the errors are not always the same ... Right now I got "Unknown promise rejection reason". I solved it by tabbing through the fields and clicking enter on login ... Not sure whats going on here. Can you confirm if you're seeing the same stuff or not?

image

I cannot test development build as I don't have Jolokia locally. At least the default 'developer' login works without issues.
Login screen on production build works without issues though.

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 27, 2025

For what's it worth, I think the errors you are seeing on login screen might be solved in new @hawtio/react. It had a lot of changes recently to optimize things hawtio/hawtio-next@c6e660a#diff-65012a7114fbad2db9def7ae26c6efc7c511251eeac1ca775a092d4748b46f19 . I have Artemis console with @hawtio/react 1.10.0 working now with just these bootstraping changes:
image
But as it is not really related to Monaco, I don't want to add even more changes to this PR.

@GChuf
Copy link
Contributor

GChuf commented Jul 29, 2025

I think it's best to bump @hawtio/react when new version of hawtio console comes out, and sync the version with the console.
For this PR, I think it might be good to squash commits into 2 (bundle the ones that relate to dependencies, and the ones that relate to code changes).
@grgrzybek @andytaylor can you take a look?

@grgrzybek
Copy link
Contributor

Hello - we've already released @hawtio/react 1.10.0 with big changes to:

I have a branch https://github.com/grgrzybek/activemq-artemis-console/commits/ggrzybek-console-fixes which I'm going to use as PR, but give me a day - I need to fix something elsewhere and I'll get back to this one.

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 29, 2025

@grgrzybek thank you. Great to see it moving forward! Just make sure Monaco files are loaded locally instead of CDN. For some reason Monaco configuration from @hawtio/react is not pulled into Artemis console so we need to duplicate webpack configuration for this.

Also, while looking at JS bundles I found that Monaco (and probably some other) JS code is still duplicated in other.js and hawtio.js in Artemis Console (search for string "https://cdn."), but this code is never used. That's probably an issue for another day.

@GChuf
Copy link
Contributor

GChuf commented Jul 29, 2025

These changes can perhaps be merged together - a quick look at differences in yarn.lock file tells me that there's a lot more changes in vilius' branch (and like mentioned, sending messages works + bundles/node_modules are smaller, so it's definitely an improvement)

@grgrzybek
Copy link
Contributor

I'll definitely handle this CDN issue for Monaco - we had this in Hawtio, but I don't remember the details. Let me finish with deadlocks in Pax Web first.

@grgrzybek
Copy link
Contributor

And I'll of course use the work from @ViliusS!

@grgrzybek
Copy link
Contributor

I've verified the change. Without:

import * as monacoEditor from 'monaco-editor'
import { loader } from '@monaco-editor/react'

loader.config({ monaco: monacoEditor, paths: {} })

I see (when opening SendMessage dialog):
image

When this code is used, I see:
image

So there's still something missing.

@grgrzybek
Copy link
Contributor

The stack leading to first CDN load is:

injectScripts
[index.js:86:1](webpack://artemis-console-app/node_modules/@monaco-editor/loader/lib/es/loader/index.js)
../node_modules/@monaco-editor/loader/lib/es/utils/compose.js/compose/</<
[compose.js:8:1](webpack://artemis-console-app/node_modules/@monaco-editor/loader/lib/es/utils/compose.js)
../node_modules/@monaco-editor/loader/lib/es/utils/compose.js/compose/<
[compose.js:7:1](webpack://artemis-console-app/node_modules/@monaco-editor/loader/lib/es/utils/compose.js)
init
[index.js:73:1](webpack://artemis-console-app/node_modules/@monaco-editor/loader/lib/es/loader/index.js)
../node_modules/@monaco-editor/react/dist/index.mjs/Ve/<
[index.mjs:1:1](webpack://artemis-console-app/node_modules/@monaco-editor/react/dist/index.mjs)
commitHookEffectListMount
[react-dom.development.js:23189:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
commitPassiveMountOnFiber
[react-dom.development.js:24965:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
commitPassiveMountEffects_complete
[react-dom.development.js:24930:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
commitPassiveMountEffects_begin
[react-dom.development.js:24917:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
commitPassiveMountEffects
[react-dom.development.js:24905:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
flushPassiveEffectsImpl
[react-dom.development.js:27078:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
flushPassiveEffects
[react-dom.development.js:27023:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
commitRootImpl
[react-dom.development.js:26974:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
commitRoot
[react-dom.development.js:26721:1](webpack://artemis-console-app/node_modules/react-dom/cjs/react-dom.development.js)
...

@grgrzybek
Copy link
Contributor

BTW, I'm working on merged PRs (mine and @ViliusS'):

$ git lgg -n 20
* 3ac37f8 - (HEAD -> ggrzybek-console-fixes) [build] Use latest xml-formatter (2025-07-30 11:23:49 +0200) <Grzegorz Grzybek>
*   5dbf415 - Merge branch 'pr109' into ggrzybek-console-fixes (2025-07-30 11:21:07 +0200) <Grzegorz Grzybek>
|\  
| * 9b6bb76 - (pr109) Extract workers (2025-07-26 13:16:47 +0300) <Vilius Šumskas>
| * 34ca60a - Dependencies fixed (2025-07-26 03:43:24 +0300) <Vilius Šumskas>
| * 8744409 - Reorganize dependencies (2025-07-26 02:25:10 +0300) <Vilius Šumskas>
| * be13d9e - Overload correct loader (2025-07-22 11:21:24 +0300) <Vilius Šumskas>
| * 7c26d3f - ARTEMIS-5569 Include Monaco editor scripts locally (2025-07-22 10:48:32 +0300) <Vilius Šumskas>
* | ef9a42c - ARTEMIS-5577: Update "resolutions" to latest versions (2025-07-30 11:12:25 +0200) <Grzegorz Grzybek>
* | 8af50f3 - ARTEMIS-5443: Upgrade to @hawtio/react 1.10.0 (2025-07-30 10:23:44 +0200) <Grzegorz Grzybek>
* | 6b04c56 - [build] With DISABLE_WS=1 webpack will start without hot reload (2025-07-30 10:12:02 +0200) <Grzegorz Grzybek>
* | 68f4702 - (fork/ggrzybek-console-fixes) ARTEMIS-5580: Separate initialization and UI code (2025-07-22 16:00:13 +0200) <Grzegorz Grzybek>
* | 84ae08d - ARTEMIS-5497: Synchronizing model changes on layout animation (2025-07-22 10:34:01 +0200) <Grzegorz Grzybek>
* | b139a3a - ARTEMIS-5546: Prevent rejected promises initialized in ArtemisService (2025-07-17 08:28:59 +0200) <Grzegorz Grzybek>
* | 490a1a3 - ARTEMIS-5577: Switch to dynamic Hawtio plugin registration and initialization UI (2025-07-17 08:28:58 +0200) <Grzegorz Grzybek>
* | b8bdebe - ARTEMIS-5577: Adjust dev/peer dependencies for upcoming @hawtio/react 1.10.0 (2025-07-17 08:28:57 +0200) <Grzegorz Grzybek>
* | c73b037 - ARTEMIS-5443: Upgrade to yarn 4.9.2 and update yarn information in DEV.md (2025-07-17 08:28:55 +0200) <Grzegorz Grzybek>
|/  
* bbd7a6c - (origin/main, origin/HEAD, main) [maven-release-plugin] prepare for next development iteration (2025-06-25 06:17:39 +0100) <Andy Taylor>

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 30, 2025

@grgrzybek make sure you nuke node_modules before testing final solution. I had the same issue that JS chunks were incorrectly generated because node_modules where populated with dependencies from previous runs. After I did dependency refactoring, deleted node_modules and restested it then was generated correctly.

Also, not sure how webpack-dev environment is loaded, but even on production bundle I still saw some references to CDN in the code. They were just never triggered. Before my changes there were 4-5 places mentioned in the various JS chunks regarding CDN. After changes it went down to 2 (which never triggers).

@grgrzybek
Copy link
Contributor

grgrzybek commented Jul 30, 2025

Actually it's not about rm-rfing node_modules. When working on dependencies/devDependencies/peerDependencies I used some hacks to verify if the bundlers are properly configured.

We have (here and in Hawtio too) two bundlers:

  • tsup (esbuild + rollup) for libraries
  • webpack for apps

The point is to not let duplicate code to sneak in anywhere.

For this purpose I check tsup produced file by filtering the bundle by ^// - it should never contain any node_modules references. Here I see:

$ pwd
/home/ggrzybek/sources/github.com/apache/activemq-artemis-console/artemis-console-extension/artemis-extension/packages/artemis-console-plugin

$ grep '^//' dist/index.js
// src/globals.ts
// src/util/jmx.ts
// src/config-manager.ts
// src/artemis-service.ts
// src/artemis-preferences-service.ts
// src/table/ArtemisTable.tsx
// src/producers/ProducerTable.tsx
// src/consumers/ConsumerTable.tsx
// src/connections/ConnectionsTable.tsx
// src/sessions/SessionsTable.tsx
// src/queues/CreateQueue.tsx
// src/context.ts
// src/addresses/CreateAddress.tsx
// ../../node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js
// ../../node_modules/state-local/lib/es/state-local.js
// ../../node_modules/@monaco-editor/loader/lib/es/config/index.js
// ../../node_modules/@monaco-editor/loader/lib/es/utils/curry.js
// ../../node_modules/@monaco-editor/loader/lib/es/utils/isObject.js
// ../../node_modules/@monaco-editor/loader/lib/es/validators/index.js
// ../../node_modules/@monaco-editor/loader/lib/es/utils/compose.js
// ../../node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js
// ../../node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js
// ../../node_modules/@monaco-editor/loader/lib/es/loader/index.js
// ../../node_modules/@monaco-editor/loader/lib/es/index.js
// ../../node_modules/@monaco-editor/react/dist/index.mjs
// src/messages/SendMessage.tsx
// src/addresses/AddressesTable.tsx
// src/status/Status.tsx
// src/queues/QueuesTable.tsx
// src/messages/QueueSelect.tsx
// src/messages/MessagesTable.tsx
// src/messages/MessageView.tsx
// src/queues/QueuesView.tsx
// src/brokers/BrokerDiagram.tsx
// src/views/ArtemisTabView.tsx
// src/Artemis.tsx
// src/ArtemisTreeView.css
// src/ArtemisTreeView.tsx
// src/artemisJMX.css
// src/ArtemisJMXContent.css
// src/addresses/DeleteAddress.tsx
// src/queues/DeleteQueue.tsx
// src/views/ArtemisJMXTabView.tsx
// src/ArtemisJMXContent.tsx
// src/ArtemisJMX.tsx
// src/ArtemisPreferences.tsx
// src/ArtemisHeader.tsx
// src/plugin-ui.ts
// src/index.ts
// src/help.md
// src/index.ts
// Annotate the CommonJS export names for ESM import in node:
//# sourceMappingURL=index.js.map

which means that tsup didn't find:

  • @monaco-editor/loader
  • @monaco-editor/react
  • state-local

modules among dependencies, so tsup simply put the source into target bundle.

For webpack it's a bit more complicated, as we have chunks etc. But I simply open the files in Gvim and do :v/!\*\*\*.*node_modules/d which gives me something like:

  !*** ../node_modules/@babel/runtime/helpers/esm/extends.js ***!
  !*** ../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js ***!
  !*** ../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js ***!
  !*** ../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js ***!
  !*** ../node_modules/d3-axis/src/axis.js ***!
  !*** ../node_modules/d3-axis/src/identity.js ***!
  !*** ../node_modules/d3-axis/src/index.js ***!
  !*** ../node_modules/d3-brush/src/brush.js ***!
  !*** ../node_modules/d3-brush/src/constant.js ***!
  ...
  (2405 lines like this)

Mind that this is the final bundle and it should contain everything - including node_modules references. But these cryptic "module names" are related to how Webpack works. Here I check if there are no weird ../../../../../node_modules which may be (but doesn't have to be) a sign that there's something wrong.

@grgrzybek
Copy link
Contributor

By grepping the output of tsup bundler we definitely need

  • @monaco-editor/loader
  • @monaco-editor/react
  • state-local

as dependencies in the package. Checking now.

@grgrzybek
Copy link
Contributor

And now it works:
image

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 30, 2025

As I'm not familiar how exactly JS dev infrastructure works I spent hours trying to find why tsup generates large JS file and why there are code duplicates in the final. Now, with your explanation, everything makes sense. It's just sad that neither tsup, nor webpack, nor yarn documentation is really useful for newcomers like me.

Anyway, thank you again and we will be waiting for the final release.

@grgrzybek
Copy link
Contributor

Now with yarn webpack build --mode development I've concatenated all *.js files and it's:

  • 37MB
  • 5569 unique "modules" like !*** ../node_modules/monaco-editor/esm/vs/platform/registry/common/platform.js ***!
  • 5 duplicates:
      2   !*** ../node_modules/@hawtio/react/dist/index.js ***!
      2   !*** ../node_modules/monaco-editor/esm/vs/basic-languages/typescript/typescript.js ***!
      2   !*** ../node_modules/monaco-editor/esm/vs/editor/common/services/textModelSync/textModelSync.protocol.js ***!
      2   !*** ../node_modules/@patternfly/react-styles/css/components/ExpandableSection/expandable-section.css ***!
      2   !*** ../node_modules/@patternfly/react-tokens/dist/esm/c_expandable_section_m_truncate__content_LineClamp.js ***!

Doing some statistics ("module" is a single JavaScript file from all used NPM Packages):

  • 559 D3 modules
  • 268 lodash modules
  • 1049 monaco-editor modules
  • 83 @patternfly/react-charts modules
  • 11 @patternfly/react-code-editor modules
  • 573 @patternfly/react-core modules
  • 1750 @patternfly/react-icons modules. yes. See hawtio/hawtio-next@a9c2937d which saved me 15MB
  • 197 @patternfly/react-styles modules
  • 49 @patternfly/react-table modules
  • 325 @patternfly/react-tokens modules
  • 217 @patternfly/react-topology modules
  • and some minors

Now I'll check the duplicates (there shouldn't be any) and icons/styles/tokens optimization

@grgrzybek
Copy link
Contributor

@ViliusS I found ChatGPT quite useful explaining how webpack, tsup and bundlers work. it helped me (but lead me to some dead ends too) with peer/dev dependencies etc.

I can say one thing - Java+Maven is a beautiful combination comparing to what we see in JavaScript+bundlers.

@grgrzybek
Copy link
Contributor

Looks like the released @hawtio/react 1.10.0 has the same issue with @monaco-editor/loader

@grgrzybek
Copy link
Contributor

In prod mode (before icons optimization) there's 15.5MB of JavaScript:

$ ll -h *.js
-rw-r--r--. 1 ggrzybek ggrzybek 116K 07-30 14:35 786.a09a9dc1.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 2,1K 07-30 14:35 834.2b549fae.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 2,6K 07-30 14:35 859.9ba9465e.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 2,6K 07-30 14:35 862.685481a9.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 7,3M 07-30 14:35 hawtio.bd9562a7.js
-rw-r--r--. 1 ggrzybek ggrzybek  293 07-30 14:35 main.d81501d6.js
-rw-r--r--. 1 ggrzybek ggrzybek 3,8M 07-30 14:35 monaco.fd2bb988.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 1,4M 07-30 14:35 other.f594e082.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 1,5K 07-30 14:35 patternfly-mini-css-extract-plugin.a9fe3183.js
-rw-r--r--. 1 ggrzybek ggrzybek 2,4M 07-30 14:35 patternfly-patternfly.e245c097.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 152K 07-30 14:35 react.52f8e43c.chunk.js
-rw-r--r--. 1 ggrzybek ggrzybek 9,4K 07-30 14:35 runtime.0aed21eb.js

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 30, 2025

Strange that you still have patternfly-mini-css-extract-plugin.a9fe3183.js. mini-css-extract-plugin is used in webpack as a dev dependency as far as I can tell. Production build from my PR for reference:

-rwxrwxrwx. 1 root root 115K Jul 27 09:06 192.c8adcbd9.chunk.js
-rwxrwxrwx. 1 root root 2.6K Jul 27 09:06 240.86c086ec.chunk.js
-rwxrwxrwx. 1 root root 2.1K Jul 27 09:06 834.b7f74f9b.chunk.js
-rwxrwxrwx. 1 root root 2.6K Jul 27 09:06 859.86c086ec.chunk.js
-rwxrwxrwx. 1 root root  639 Jul 27 09:06 862.cef9c60f.chunk.js
-rwxrwxrwx. 1 root root 2.6K Jul 27 09:06 97.86c086ec.chunk.js
-rwxrwxrwx. 1 root root 7.3M Jul 27 09:06 hawtio.f1328e2f.js
-rwxrwxrwx. 1 root root  280 Jul 27 09:06 main.7246363d.js
-rwxrwxrwx. 1 root root 3.8M Jul 27 09:06 monaco.f3b534f1.chunk.js
-rwxrwxrwx. 1 root root 1.4M Jul 27 09:06 other.0be43ad5.chunk.js
-rwxrwxrwx. 1 root root 2.4M Jul 27 09:06 patternfly.ab35d913.js
-rwxrwxrwx. 1 root root 152K Jul 27 09:06 react.52f8e43c.chunk.js
-rwxrwxrwx. 1 root root 9.3K Jul 27 09:06 runtime.5a527fd8.js

@grgrzybek
Copy link
Contributor

With https://issues.apache.org/jira/browse/ARTEMIS-5600:

  • dev bundle size from 37MB to 32MB (from 1750 to 79 JS modules)
  • prod bundle size from 16MB to 14MB

@grgrzybek
Copy link
Contributor

Hmm, indeed... when I build it I can see this:

$ rm -rf build/; yarn webpack --mode production
[afterChunks] original chunk: main
[afterChunks] original chunk: runtime
[afterOptimizeChunks] optimized chunk: main
[afterOptimizeChunks] optimized chunk: runtime
[afterOptimizeChunks] optimized chunk: react
[afterOptimizeChunks] optimized chunk: patternfly-css-loader
[afterOptimizeChunks] optimized chunk: patternfly-mini-css-extract-plugin
[afterOptimizeChunks] optimized chunk: patternfly-patternfly
[afterOptimizeChunks] optimized chunk: monaco
[afterOptimizeChunks] optimized chunk: hawtio
[afterOptimizeChunks] optimized chunk: other
modules count: 5618

this patternfly-mini-css-extract-plugin.a9fe3183.js is almost empty...

@grgrzybek
Copy link
Contributor

grgrzybek commented Jul 30, 2025

I've just pushed #110 which combines my changes and @ViliusS changes... I know it's a big one, but this is special situation (big Hawtio upgrade).

@ViliusS may I ask you to have a look at this one?

I always prefer separate commits over squashed ones for clarity and future investigation ("why it was done like this?")

@ViliusS
Copy link
Contributor Author

ViliusS commented Jul 31, 2025

@grgrzybek, the production build from your branch looks great. Monaco editor is loaded locally and SendMessage works.

PatternFly chunk is much smaller, which is cool. I don't see patternfly-mini-css-extract-plugin.js either.

[root@activemq-artemis-node-1 js]# ls -la *.js
-rwxrwxrwx. 1 root root 116K Jul 31 10:04 786.cd3e7f0f.chunk.js
-rwxrwxrwx. 1 root root 2.1K Jul 27 09:06 834.b7f74f9b.chunk.js
-rwxrwxrwx. 1 root root 2.6K Jul 31 10:04 859.fd201182.chunk.js
-rwxrwxrwx. 1 root root 2.6K Jul 31 10:04 862.45256e60.chunk.js
-rwxrwxrwx. 1 root root 7.3M Jul 31 10:04 hawtio.4d3456bc.js
-rwxrwxrwx. 1 root root  289 Jul 31 10:04 main.aeddac53.js
-rwxrwxrwx. 1 root root 3.8M Jul 27 09:06 monaco.f3b534f1.chunk.js
-rwxrwxrwx. 1 root root 1.4M Jul 31 10:04 other.30f5c573.chunk.js
-rwxrwxrwx. 1 root root 992K Jul 31 10:04 patternfly.862b7cbd.js
-rwxrwxrwx. 1 root root 152K Jul 27 09:06 react.52f8e43c.chunk.js
-rwxrwxrwx. 1 root root 9.3K Jul 31 10:04 runtime.7ea245ba.js

I still see some Monaco loader code in other.js chunk (search for string "https://cdn."), but that probably is never loaded.

I will close this PR in favour of yours, and move new discussion there.

@ViliusS ViliusS closed this Jul 31, 2025
@grgrzybek
Copy link
Contributor

I still see some Monaco loader code in other.js chunk (search for string "https://cdn/."),

this is part of @monaco-editor/loader code which runs when you don't call loader.config({ monaco: monacoEditor, paths: {} }) yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants