ui5-community / ui5-ts-shim-showcase

UI5 Showcase Project Shims For TypeScript
https://github.com/ui5-community/ui5-ts-modules-showcase
Apache License 2.0
6 stars 2 forks source link

Loading modules with extension cjs instead of js #3

Closed jornfranke closed 8 months ago

jornfranke commented 2 years ago

I try to figure out a way on how to load .cjs files instead of .js files. Background: I try to integrate prosemirror (https://prosemirror.net/) into an OpenUI5 application. I manage to load from the NPM packages the dist/*.js files into my application - however - those are ES moduels and then I get the error:

Uncaught SyntaxError: import declarations may only appear at top level of a module

Now, prosemirror has also commonjs modules, but with the extension .cjs and not .js

I have not found a way to load the .cjs via sap.ui.loader.config({. Alternatively, if it would be possible to load a ES modules via sap.ui.loader

jornfranke commented 2 years ago

@petermuessig do you have an idea? thanks!

petermuessig commented 8 months ago

OMG - I missed to reply here as well

Using the ui5-tooling-modules tooling extension should do the trick that you don't need to take care about the input format of the OSS library and it finally converts it into UI5 AMD-like modules which can be just required/imported in your application without shimming.

A new/updated showcase for this one can be found here: https://github.com/ui5-community/ui5-ts-modules-showcase/