writer-framework icon indicating copy to clipboard operation
writer-framework copied to clipboard

Custom Components not loading with .cjs extension

Open Sanuki-073 opened this issue 1 year ago • 2 comments

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

Sanuki-073 avatar Apr 28 '24 03:04 Sanuki-073

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.

FabienArcellier avatar Apr 29 '24 08:04 FabienArcellier

@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.

ramedina86 avatar Apr 29 '24 09:04 ramedina86

This issue has been fixed in version 0.6.0.

FabienArcellier avatar Aug 06 '24 07:08 FabienArcellier