fix(examples): fix EventEmitter heritage error in examples#3550
Conversation
finetjul
left a comment
There was a problem hiding this comment.
It would have been great to have more information about the problem in the commit message.
I'm not sure to 100% understand the issue but from what I could get, Vite does not resolve correctly events and treat them as undefined and "vite-plugin-node-polyfills" fixes this. |
|
Do you know what's specific about those examples ? Why are they different from the other working examples ? |
|
@finetjul all those examples end up using xmlbuilder2, the newer version of xmlbuilder has introduced the usage of node EventEmitter for callback https://github.com/oozcitak/xmlbuilder2/blob/10b65492d4c47a3a7c88e430be5b1d7bbd0ac85a/src/builder/XMLBuilderCBImpl.ts#L22 @Jo-Byr We have already fixed the tests using the official |
|
@daker I'm not sure to understand the fix you suggest. I tried moving @rolldown/plugin-node-polyfills to dependencies instead of devDependencies but it does not fix the problem. |
If I'm not mistaken, this would only cover built examples, not examples ran with I added But adding |
|
@Jo-Byr here is the patch, no need for a new deps diff --git a/Utilities/ExampleRunner/vite.example.config.mjs b/Utilities/ExampleRunner/vite.example.config.mjs
index 169b9a37e2..5c16f9b331 100644
--- a/Utilities/ExampleRunner/vite.example.config.mjs
+++ b/Utilities/ExampleRunner/vite.example.config.mjs
@@ -1,10 +1,10 @@
import path from 'path';
+import nodePolyfills from '@rolldown/plugin-node-polyfills';
import {
glslPlugin,
svgRawPlugin,
cjsonPlugin,
workerInlinePlugin,
- ignorePlugin,
serveStaticDataPlugin,
} from '../build/plugins.mjs';
@@ -44,6 +44,11 @@ export function createExampleConfig({
__BASE_PATH__: JSON.stringify(''),
global: 'globalThis',
},
+ optimizeDeps: {
+ rolldownOptions: {
+ plugins: [nodePolyfills()],
+ },
+ },
css: {
modules: {
localsConvention: 'camelCaseOnly',
@@ -63,7 +68,6 @@ export function createExampleConfig({
glslPlugin(),
svgRawPlugin(),
cjsonPlugin(),
- ignorePlugin(['crypto']),
serveStaticDataPlugin(repoRoot),
{
name: 'vtk-example-runner-entry', |
0429cda to
43318e6
Compare
Thank you, it's corrected. |
Context
Some examples (XMLImageDataWriter, XMLPolyDataWriter, SurfaceLICMapper, GeometryViewer, ImageViewer, OctreeViewer, TubesViewer, VolumeViewer, TimeSeries, VolumeMapperLightAndShadow, WebXRChestCTBlendedCVR, WebXRHeadFullVolumeCVR, WebXRHeadGradientCVR and WebXRVolume) fail due to a
class heritage events_1.EventEmitter is not an object or nullerror.Results
This PR fixes this issue in these examples, though other errors remain in some of the examples cited.
Changes
Added "vite-plugin-node-polyfills" dependency
PR and Code Checklist
npm run reformatto have correctly formatted code