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

can't reuse entryFields from @bpmn-io/properties-panel #8

Open
DK-2013 opened this issue Nov 10, 2023 · 6 comments
Open

can't reuse entryFields from @bpmn-io/properties-panel #8

DK-2013 opened this issue Nov 10, 2023 · 6 comments
Assignees
Labels
backlog Queued in backlog bug Something isn't working

Comments

@DK-2013
Copy link

DK-2013 commented Nov 10, 2023

Describe the Bug

if wrap playgroundForm in preact component - it work fine
if then add custom component from sample - got error in NumberField

Steps to Reproduce

  1. npm create vite@latest wrapper-sample -- --template preact
  2. add playground in wrapper (its work fine):
export function App() {
  useEffect(() => {
    const container = document.getElementById('anchor');
    console.log(container);
    new FormPlayground({
      container,
      schema,
      data: {},
    });
  }, []);
  return (
    <div id="anchor" />
  )
}
  1. add custom component from custom-sample
    new FormPlayground({
      container,
      schema,
      data: {},

      // load rendering extension
      additionalModules: [
        RenderExtension
      ],

      // load properties panel extension
      editorAdditionalModules: [
        PropertiesPanelExtension
      ]
    });
  1. render fine, but on attempt drug Range to form - got error in console

wrapper-sample

Expected Behavior

no error, custom component work as in custom-sample

Environment

  • Host (Browser/Node version), if applicable: FireFox 119, Node 18.16.0
  • OS: Ubuntu 22.04
  • Library version: @bpmn-io/form-js ^1.4.0
@DK-2013 DK-2013 added the bug Something isn't working label Nov 10, 2023
@DK-2013 DK-2013 changed the title could not reuse entryFields from @bpmn-io/properties-panel can't reuse entryFields from @bpmn-io/properties-panel Nov 10, 2023
@pinussilvestrus
Copy link
Contributor

Hi @DK-2013 , thanks for reporting!

Can you maybe share the errors you got? We had problems with vite properly deduplicating preact, that's why we ended up using webpack in our example who handles it better: #7

@pinussilvestrus pinussilvestrus added the help wanted Extra attention is needed label Nov 13, 2023
@DK-2013
Copy link
Author

DK-2013 commented Nov 13, 2023

I make branch with sample in fork of this repo - directory: wrapper-sample.
steps in sample:

  1. npm i
  2. npm run dev
  3. drug Range field to form (http://localhost:5173/)

image

@pinussilvestrus pinussilvestrus self-assigned this Nov 13, 2023
@pinussilvestrus
Copy link
Contributor

Thanks for sharing, I will have a look 👍

@pinussilvestrus
Copy link
Contributor

When checking the project out, I get the same errors as when we experimented with vite during #6. Vite do not properly deduplicate preact leading to the known

TypeError: Cannot read properties of undefined (reading 'context').

This was the reason we moved to our standard webpack pattern. Would it be an option for you to try something else then vite?

In the meantime, we should figure out how to properly support vite here.

@DK-2013
Copy link
Author

DK-2013 commented Nov 13, 2023

I found this solution, but it is not applicable for libs using pattern, which implemented in properties-panel.
Current structure project is complex to change build tools (client app - wrapper lib - @bpmn-io lib), include integrate react based lib to preact.
Other side if will be impossible use vite then need impliment properties-panel or search other solution.

Anyway thank you for your carry!

@pinussilvestrus
Copy link
Contributor

Update: I tried a couple of things in vite via resolve.alias and the @rollup/plugin-alias plugin to to the module replacement, without any luck so far.

The main problems remains that we bundle preact inside the properties panel, which vite can't properly replace although it's defined via config.

resolve: {
  alias: [
    {
      find: 'preact/hooks',
      replacement: path.resolve(__dirname, 'node_modules/preact/hooks/dist/hooks.module.js'),
    },
    {
      find: 'preact/jsx-runtime',
      replacement: path.resolve(__dirname, 'node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js'),
    },
    {
      find: 'preact/jsx-dev-runtime',
      replacement: path.resolve(__dirname, 'node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js'),
    },
    {
      find: 'preact/devtools',
      replacement: path.resolve(__dirname, 'node_modules/preact/devtools/dist/devtools.module.js'),
    },
    {
      find: 'preact/debug',
      replacement: path.resolve(__dirname, 'node_modules/preact/debug/dist/debug.module.js'),
    },
    {
      find: 'preact/compat',
      replacement: path.resolve(__dirname, 'node_modules/preact/compat/dist/compat.module.js'),
    },
    {
      find: 'preact',
      replacement: path.resolve(__dirname, 'node_modules/preact/dist/preact.module.js'),
    }
  ]
}

@pinussilvestrus pinussilvestrus removed their assignment Nov 23, 2023
@pinussilvestrus pinussilvestrus removed the help wanted Extra attention is needed label Nov 23, 2023
@nikku nikku added the backlog Queued in backlog label Jan 15, 2024 — with bpmn-io-tasks
@Skaiir Skaiir self-assigned this May 29, 2024
@Skaiir Skaiir added in progress Currently worked on and removed backlog Queued in backlog labels May 29, 2024
@Skaiir Skaiir added backlog Queued in backlog and removed in progress Currently worked on labels Jun 11, 2024
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

4 participants