writer / writer-framework

No-code in the front, Python in the back. An open-source framework for creating data apps.
https://dev.writer.com/framework/introduction
Apache License 2.0
1.28k stars 72 forks source link

Custom Components not loading with .cjs extension #405

Open Sanuki-073 opened 3 months ago

Sanuki-073 commented 3 months ago

Thank you for providing such a great library.

I would like to report a minor bug related to custom components. I followed the official documentation (https://www.streamsync.cloud/custom-components.html) to create a custom component. After building, I got two files: templates.umd.cjs and style.css.

image

I placed these files under the extensions/ directory and checked in the builder, but the component was not displayed.

Next, I renamed templates.umd.cjs to templates.umd.js and launched the builder again. This time, I confirmed that the component was displayed correctly in the builder.

As a beginner, I might be mistaken, but I think there are two possible solutions:

  1. Modify the loadExtensions function on line 5 of src/ui/src/core/loadExtensions.ts to also load .cjs files.
  2. Change the build process to not generate files with the .cjs extension.

Please consider this issue. Thank you for your attention.

[Execution environment] PC: macbook pro M3 pro OS version: Sonoma 14.3 npm -v: 10.2.4

FabienArcellier commented 3 months ago

Thank you so much. It's very clear.

We missed this change when we change the declaration of package.json. Library Mode. When introducing "type": "module" in package.json, it change the behavior of vite build (https://github.com/streamsync-cloud/streamsync/pull/373/files#diff-3bb5cacc1bc1cf9df685fd6f0f368991b94e557444a5639a52d5129d78cd1906).

package.json

{
    "name": "streamsync-ui",
    "version": "0.0.0",
    "type": "module"

We will have a look on that.

ramedina86 commented 3 months ago

@Sanuki-073 thanks for reporting and helping Streamsync become better.

It's now merged in dev and it'll be released with the version.

@FabienArcellier Thanks for the research and the fix.