Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using custom component in FormEditor #12

Open
EinArlyn opened this issue Mar 20, 2024 · 6 comments
Open

Error when using custom component in FormEditor #12

EinArlyn opened this issue Mar 20, 2024 · 6 comments
Assignees
Labels
backlog Queued in backlog bug Something isn't working

Comments

@EinArlyn
Copy link

Description

I've encountered a problem when trying to integrate a custom component into FormEditor. I was following an example for FormPlayground, but when using it within FormEditor, selecting the custom Range component in the UI throws an error.

Code to Reproduce

formEditorRef.value = new FormEditor({
  container: document.querySelector('#form-editor'),
  additionalModules: [
    RangeExtension,
    PropertiesPanelExtension,
  ],
});

Expected Behavior

The custom component should be available and functional within the form editor without any errors.

Actual Behavior

When selecting the custom Range component in the interface, the following JavaScript error is displayed:
Uncaught TypeError: Cannot read properties of undefined (reading '__H')

Screenshots

image

Steps to Reproduce

  1. Integrate the custom Range component into FormEditor using the code provided above.
  2. Open the form editor UI.
  3. Select the custom Range component.
  4. Notice the error in the browser console.

Additional Information

Version of bpmn-io/form-js: 1.7.0
Version Vue.js: 3.2.45

@EinArlyn EinArlyn added the bug Something isn't working label Mar 20, 2024
@pkochubey
Copy link

Related issue #8
Use webpack not vite for buid you project.

@EinArlyn
Copy link
Author

Related issue #8
Use webpack not vite for buid you project.

So, should I better compile the component using Webpack and then integrate it into my project? I was confused by the fact that when I tried exactly as in the example through FormPlayground, everything worked properly without the need for a Webpack build, but Vite wasn't used in that project. Does this mean that the behavior I'm experiencing is specifically related to the build tool?

@pkochubey
Copy link

pkochubey commented Mar 20, 2024

Does this mean that the behavior I'm experiencing is specifically related to the build tool?

100%

In example by default used webpack.

@EinArlyn
Copy link
Author

Does this mean that the behavior I'm experiencing is specifically related to the build tool?

100%

In example by default used webpack.

Alright, thank you. I will try integrating it into my application after building the component with Webpack and then I'll report back on the results.

@EinArlyn
Copy link
Author

Does this mean that the behavior I'm experiencing is specifically related to the build tool?

100%

In example by default used webpack.

Hello. Thank you for your answers. I implemented a sample application that is built with Webpack, but the application where I need to integrate this functionality still uses a Vite + Vue + TS environment. I could not replicate my previous experience on it. I created an issue hoping someone could help me with my problem, but it remains unanswered. There is more detailed information and two test projects there. Perhaps you might have some thoughts on where to direct attention to solve this issue. I would be very grateful.

@Skaiir Skaiir self-assigned this May 29, 2024
@Skaiir Skaiir added the in progress Currently worked on label May 29, 2024
@Skaiir Skaiir added backlog Queued in backlog and removed in progress Currently worked on labels Jun 11, 2024
@EinArlyn
Copy link
Author

The main problem that needed to be solved was enabling the extension of the component set with custom components while ensuring everything worked smoothly with Vue.js + Vite.

To address this issue, a separate library was developed. This library facilitates the use of custom components and replicates the necessary functionalities from bpmn/form.js.

Additionally, to ensure compatibility with Vue.js + Vite, a custom plugin was created for minification purposes.

Further configurations were required in the vite.config.ts file:

optimizeDeps: {
  exclude: [
    '@einarlyn/bpmn-form-extended',
  ],
},
build: {
  rollupOptions: {
    output: {
      manualChunks(id) {
        if (id.includes('bpmn-form-extended')) {
          return 'customFormEditor';
        }
        return 'app';
      },
    },
    plugins: [minifyBundles()],
  },
  minify: false,
},

References:

  1. Vue.js + Vite project repository link
  2. Library repository link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants