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

Pros & Cons of NPM package namespaces #1

Open
petermuessig opened this issue Mar 3, 2022 · 9 comments
Open

Pros & Cons of NPM package namespaces #1

petermuessig opened this issue Mar 3, 2022 · 9 comments

Comments

@petermuessig
Copy link
Member

petermuessig commented Mar 3, 2022

For custom control packages namespaces and package name both are valid but package name has the following pros and cons:

Pros:

  • Close to NPM package syntax (simple concept)
  • Resolves version dependency for central deployment
  • Configuration free
  • Thirdparty can be embedded easily (Frontend packages)
  • No shimming knowledge needed

Cons:

  • No individual deployment! => libraries can be deployed individually!
  • New concept => requires exlanation
@petermuessig
Copy link
Member Author

@marianfoo @marcelschork FYI

@petermuessig
Copy link
Member Author

@vobu - feel free to join the discussion

@mauriciolauffer
Copy link
Collaborator

mauriciolauffer commented Mar 5, 2022

This new approach wouldn't render old custom libs useless nor break them. It's just a better approach which makes custom controls integration smoothier and fixes some of the current problems, most notorious being: multiple versions and extra configuration.

Another benefit: it opens the door for people start experimenting with ES modules.

The problem for individual deployment could be solved deploying a custom component wrapping the custom pkgs one uses.

@mauriciolauffer
Copy link
Collaborator

Also, this would finally enable a much easier integration with storybooks 😍

Already expected in: #4

@petermuessig
Copy link
Member Author

@mauriciolauffer - thanks for joining the discussion and your feedback.

Rgd. storybook -> I will continue my experiments over the weekend. Last weekend I already got a UI5 Button running - but to support it properly, with JS/XML code, a plugin needs to be written. I found one https://github.com/leon-vg/storybook-ui5/ but this is also a very basic one. I wanted to understand the possibilities of writing a storybook plugin better. It would be really cool to just use it on top of any library or custom control project.

Rgd. pros/cons: one thing I see a bit negative with the pure NPM package approach is that you can't hide the folder structure of the repository. Typically, you organize your project in folders src, lib, whatever and via the NPM package this immediately becomes visible for the consumers. There is the possibility defining main modules which are loaded when requiring just the module but in case of hosting different UI5 Controls this is not useful. There the shimming approach is even a bit better as you can hide those internals. Anyways, in the NPM community, this is a well know practice to refer to modules in the repos folder structure... 😄

@mauriciolauffer
Copy link
Collaborator

Storybook

I've done some work inspired by storybook-ui5, but making it more similar to @storybook/html and cleaned up a little bit (for the sake of maintainability). I've removed some of the overhead (using react to create root elements) and made it work with ui5 objects as well, eg, new sap.m.Button(), it was working only with xml string.

Have a look at my forked branch: https://github.com/mauriciolauffer/storybook-ui5/tree/feat-ui5-obj

The most important file in the project is app/ui5/src/client/preview/render.ts, everything else is just boilerplate.

An example on how to consume it can be found in examples/ui5-kitchen-sink.

  1. To run it, you first need to build the app from the root level: $ npm run package:build
  2. Then, go to the example folder and install the pkg as local file or using npm-link
  3. Now, you can start the storybook with: $ npm run storybook

image
image

@mauriciolauffer
Copy link
Collaborator

PS: after we run some tests and make more changes, I'm going to create a PR with our changes in storybook-ui5.

@vobu
Copy link
Collaborator

vobu commented Mar 15, 2022

just chiming in with .02€, admitting that I've only heard from storybook through here.
But I'm intrigued as it seems a viable way of prototyping UI5-based UIs, with BUILD being gone.
Thanks for shedding some light into this, guys!

@mauriciolauffer
Copy link
Collaborator

Storybooks aren't meant to prototype UIs, as BUILD was. It's a automated testing tool for UI components, actions, visual regression, etc.

For instance, you could use it to test your ui5 control accessibility, visual regression (the button colour/font/etc looks different after a change)...

Where it could overlap with BUILD is the ability to deploy the storybooks as an standalone webapp and share with your team to gather feedback. However, you don't have the option to drag&drop UI elements to build a whole app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants