SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.54k stars 265 forks source link

improve asset loading APIs and document them #546

Closed pskelin closed 5 years ago

pskelin commented 5 years ago

Is your feature request related to a problem? Please describe. There are four types of assets used by ui5-webcomponents icons, CLDR, message bundles, theming parameters

There are sensible defaults (CDN or inline imports) so that developing without a build tool is possible, but configuring local bundling is not documented and the APIs are not unified.

Describe the solution you'd like consistent APIs for configuration asset bundling/loading and documentation for them.

emumanu commented 5 years ago

I want to use ui5-webcomponents with Asp.net Core. Is it possible to use it adding some javascript files and/or css files without using node.js?

Is this issue is tracking that?

MapTo0 commented 5 years ago

Hello @emumanu

NodeJS is not required for consuming the web components at all. You just need a bundled version of the components. We are not providing a CDN usage yet. There are several options that you can choose between to get this working.

  1. Make your own bundling using webpack or rollup (recommended)
  2. Use https://unpkg.com/ as CDN (not really recommended)

Here is an example of rollup.config.json

import 'rollup'; /* eslint no-unused-vars: 0*/
import resolve from 'rollup-plugin-node-resolve';
import json from 'rollup-plugin-json';
import { terser } from "rollup-plugin-terser";

export default {
  input: "src/main.js",
    output: {
    file: "./public/bundle.js",
        format: "esm",
        sourcemap: true
  },
    plugins: [
        json(),
        terser(),
        resolve(),
    ]
};

As starting point you can get https://github.com/rollup/rollup-starter-app

  1. Clone the project
  2. Add ui5-webcomponents as dependency
  3. Import the needed web components in the main.js file
  4. Enhance the rollup.config.js
  5. Build the project rollup -c
  6. Copy the built javascript placed in the public folder to your ASP project and consume it as a script
emumanu commented 5 years ago

Thanks for the tip @MapTo0

It would be good to have an "official development file" with the full bundle, even if its 10MB or more in size. It won't be used for production, but it would be good in order to try ui5 web components in 1 minute.

BR

MapTo0 commented 5 years ago

We are actually not providing as you call it "official development file" as we feel like it will be used in production as well. We even found some usages of the bundle.js which is deployed on github pages for our playground :D.

Easiest 1 minute consumption is probably the unpkg.com example https://jsbin.com/sepegiribe/edit?html,output

No build tool is required, but huge amount of javascript will be downloaded if several components are imported.

emumanu commented 5 years ago

I think that is a poor decision. If someone can do something wrong does not mean that you should avoid easy usage for other people that know the tradeoffs. You have knives at home, right?

Most developers have tight schedules and can't justify extra time to just try a library.

Anyway, I'm going to continue using OpenUI5 as UI5 web components doesn't have any form layout and the table it's too basic.

MapTo0 commented 5 years ago

Any feature requests are welcome :)

emumanu commented 5 years ago

With that implemented, I could invest some time to create asp.net core tag helpers to be able to use the ui5-webcomponents with Visual Studio intellisense support. While that is not implemented and for apps that require more client side functionality, I will stick to my OpenUI5Sharp

BTW, does UI5-webcomponents share some source code with SAPUI5/OpenUI5?

BR and keep on your good work!

vladitasev commented 5 years ago

Implemented.

About C# support, please open another issue, if necessary.

Regards

emumanu commented 5 years ago

Thank you