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

Loader when compiling Spell #200

Open
burn83 opened this issue Nov 11, 2022 · 12 comments
Open

Loader when compiling Spell #200

burn83 opened this issue Nov 11, 2022 · 12 comments
Labels
backlog Queued in backlog bug Something isn't working

Comments

@burn83
Copy link

burn83 commented Nov 11, 2022

When I try to compile code like as example i receive an error that suggest me to add another loader to read correctly a row of the Spellprops.js in which we can retrieve "return <"
Instruction. Can, anyone helps me?


File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
   }

>   return <TextFieldEntry
     id={id}
     element={element}
  • Angular 13
  • Node 16.17.1, npm 8.5.2
  • OS: Windows 11
@burn83 burn83 added the bug Something isn't working label Nov 11, 2022
@nikku
Copy link
Member

nikku commented Nov 13, 2022

Could you specify the exact project you're trying?

@burn83
Copy link
Author

burn83 commented Nov 14, 2022

Yes. sure.

i tried to realize this one:
https://github.com/bpmn-io/bpmn-js-examples/tree/master/properties-panel-extension

but my compiler seems to need another loader for compile that row of code. It seems that i must to configure Babel aproppriately. It's correct? There is another solution more simple?

@nikku
Copy link
Member

nikku commented Nov 14, 2022

Indeed. The project uses JSX and you need to add the babel-loader to transpile it to plain javascript: https://medium.com/@sivaraj-v/basic-webpack-4-and-es5-to-es6-transpiler-using-babel-dc66e72c86c6.

@burn83
Copy link
Author

burn83 commented Nov 14, 2022

But in my project i don't have webpack.config.js, in order to add directive about babel. I only have tsconfig.json

@nikku
Copy link
Member

nikku commented Nov 14, 2022

You do, as the error message indicates. At least it seems to be used under the hood.

What you need to enable is transpilation of JSX (inside an Angular project). Not sure how that works. Alternatively you'd need to split-up the extension (to be transpiled individually) and the integration into your Angular app.

@burn83
Copy link
Author

burn83 commented Nov 14, 2022

"Alternatively you'd need to split-up the extension (to be transpiled individually) and the integration into your Angular app. ..."
How can do this?

@nikku
Copy link
Member

nikku commented Nov 14, 2022

"Alternatively you'd need to split-up the extension (to be transpiled individually) and the integration into your Angular app. ..."

How can do this?

1️⃣ You create your customizations in a fork of https://github.com/bpmn-io/bpmn-js-examples/tree/master/properties-panel-extension. That project compiles JSX -> JS.

2️⃣ Consume the transpiled JS resources produced in 1️⃣ in your Angular app.

To get additional feedback on this case I'd ask you to create a topic in our forum and cross-reference this thread. Maybe users already solved this issue in a simpler manner.

@burn83
Copy link
Author

burn83 commented Nov 14, 2022

OK ... i found a complete solution to convert SpellProps.js(x) in SpellProps.js, in pure mode.
`"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

exports["default"] = _default;

var _propertiesPanel = require("@bpmn-io/properties-panel");
var _bpmnJsPropertiesPanel = require("bpmn-js-properties-panel");
var _react = require("react");

function _default(element) {
return [{
id: 'spell',
element: element,
component: Spell,
isEdited: _propertiesPanel.isTextFieldEntryEdited
}];
}

function Spell(props) {
var element = props.element,
id = props.id;
var modeling = (0, _bpmnJsPropertiesPanel.useService)('modeling');
var translate = (0, _bpmnJsPropertiesPanel.useService)('translate');
var debounce = (0, _bpmnJsPropertiesPanel.useService)('debounceInput');

var getValue = function getValue() {
return element.businessObject.spell || '';
};

var setValue = function setValue(value) {
return modeling.updateProperties(element, {
spell: value
});
};

return _react.createElement(_propertiesPanel.TextFieldEntry, {
id: id,
element: element,
description: translate('Apply a black magic spell'),
label: translate('Spell'),
getValue: getValue,
setValue: setValue,
debounce: debounce
});
}
`

and this is the output...

Now in browser, on the console, i find this error : " Uncaught (in promise): TypeError: Cannot add property __, object is not extensible" ... It's a bug?! or ... what?

@burn83
Copy link
Author

burn83 commented Nov 15, 2022

image

can anyone help me?

@nikku
Copy link
Member

nikku commented Nov 16, 2022

@burn83 This looks like another Angular <-> bpmn.io tooling incompatibility issue.

Please share a codesandbox that allows us to reproduce this behavior.

We aim for compatibility with existing UI frameworks. Experience has shown that some (Angular, Vue) do interesting magic though that you may need to disable for bpmn-js to work reliably.

@nikku
Copy link
Member

nikku commented Dec 3, 2022

We plan to simplify our examples to not use JSX/transpilation anymore (#206). That should workaround most of the complications you mentioned in this issue.

@minzhenyu
Copy link

minzhenyu commented Mar 6, 2023

in my project, vue2, it doesn't work
image

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