SolidOS / solid-ui

User Interface widgets and utilities for Solid
https://solidos.github.io/solid-ui/dist/solid-ui.js
MIT License
148 stars 41 forks source link

Acccess to solid-ui from a CDN #530

Closed bourgeoa closed 1 year ago

bourgeoa commented 1 year ago

@jeff-zucker

Access to npm published version is from lib/index.js The file contains :


--------------
if (typeof window !== 'undefined') {
  ;
  window.UI = {
    authn: _solidLogic.authn,
    store: _solidLogic.store,
    ns: ns,
    rdf: rdf,
    acl: _index.acl,
    aclControl: _index.aclControl,
    create: _index2.create,
    createTypes: createTypes,
    dom: dom,
    icons: _iconBase.icons,
    language: language,
    log: log,
    login: login,
    matrix: _index3.matrix,
    media: _index4.media,
    messageArea: _messageArea.messageArea,
    infiniteMessageArea: _infinite.infiniteMessageArea,
    pad: pad,
    participation: participation,
    preferences: preferences,
    style: style,
    table: _table.renderTableViewPane,
    tabs: tabs,
    utils: utils,
    widgets: widgets,
    versionInfo: _versionInfo.versionInfo,
    initHeader: _header.initHeader,
    initFooter: _footer.initFooter
  }; // Simpler access by non-node scripts
}
-----

Is it enough to use in a script tag ? lib is not accessible from github ? is it a must ?

jeff-zucker commented 1 year ago

No, lib/index.js is not a browser- accessible library. If I put that in a script tag, it barfs on the require statements. The only thing, as far as I know that works in a browser from a CDN is dist/main.js.

jeff-zucker commented 1 year ago

So my suggestion would be to build it at the same time you build mashlib and place it also in https://solidcommunity.net/main.js so it can be accessed the same way mashlib is for those apps (like many I am working on) which do not need panes.

jeff-zucker commented 1 year ago

To document why this is useful - I am working on a variety of apps that use the solid-ui-components framework but do not need the panes that come with mashlib. If we want to make solid-ui and SolidOS available to developers, this would greatly simplify things. Additionally, it should be minified because currently solid-ui takes a long time to load.

jeff-zucker commented 1 year ago

Or, instead of serving from solidcommunity.net, f the dist folder is built and included in the npm, then I believe npmjs will automatically create a CDN for it. Or the same for github.

timea-solid commented 1 year ago

We could publish solid-ui on github as we do do mashlib on the gh-pages branch (see: https://github.com/SolidOS/mashlib/tree/gh-pages)

timea-solid commented 1 year ago

It is for now here: http://solidos.github.io/solid-ui/dist/main.js -> we need to change its name to solid-ui.js before we make use of it.

timea-solid commented 1 year ago

We discussed that http://solidos.github.io/solid-ui/dist/main.js is fine as is.

bourgeoa commented 1 year ago

I propose we add :

jeff-zucker commented 1 year ago

@bourgeoa - it is already there and @timea already documented in the Solid-ui readme.

jeff-zucker commented 1 year ago

https://solidos.github.io/solid-ui/dist/main.js

bourgeoa commented 1 year ago

Could be added that dist/main.js being published in npm it is available in CDN like jsdelivr

jeff-zucker commented 1 year ago

@bourgeoa I can't find it on either npmjs CDN or jsdelivr CDN.

bourgeoa commented 1 year ago

@jeff-zucker can you look to branch browser in dist/ can you try dist/solid-ui.js

jeff-zucker commented 1 year ago

I built solid-ui 2.4.22 and in a web-app, I can point at solid-ui/dist/main.js and it works fine. There is no main.js on github.io. If I use https://solidos.github.io/solid-ui/dist/solid-ui.min.js (with or without the min) I get the following errors and nothing works.

solid-ui-error

jeff-zucker commented 1 year ago

One of the reasons this is a problem is that a demo of solid-uix can work with solid-ui rather than mashlib and runs considerably faster because it does not have to load the panes. So I'd really like to be able to point to a stable solid-ui online. It's not totally critical though - I can load mashlib instead and just have it work slower. So if you're swamped for time, you can back burner this.

jeff-zucker commented 1 year ago

When I npm install solid-ui 2.4.27 from npm and point to dist/main.js the web version works fine. The online solid-ui.js does not.

bourgeoa commented 1 year ago

@jeff-zucker I just updated to the correct link could you try https://solidos.github.io/solid-ui/dist/solid-ui.js

Well if it works ? shall I keep that link or do you prefer a solid-ui.min.js ? But may be it is a bad idea to have changed the name and main.js was better. I don't know

jeff-zucker commented 1 year ago

I get the same error as previously "Automatic publicPath is not supported".

Yes, it would be much simpler to just keep the existing URL and simply build and include dist when you push to github. There is no reason this should be a separate file from main.js which is generated automatically on build.

timea-solid commented 1 year ago

I found this explanation to the problem: https://stackoverflow.com/questions/64294706/webpack5-automatic-publicpath-is-not-supported-in-this-browser And proposed this solution: https://github.com/SolidOS/solid-ui/pull/547

jeff-zucker commented 1 year ago

What I wonder is why dist/main.js works perfectly and this thing does not and why they should be two different files.

timea-solid commented 1 year ago

@jeff-zucker right now there is only one solid-ui or main. It used to be main now it is solid-ui. The problem could occur in any name we chose from what I read.

bourgeoa commented 1 year ago

@jeff-zucker merged #547 to main. Could you check if the issue is resolved

jeff-zucker commented 1 year ago

I can confirm this works with both dist/solid-ui.js and dist/solid-ui.min.js work when I clone main and build locally but am unable to find them at https://solidos.github.com/solid-ui/dist/solid-ui.js.

bourgeoa commented 1 year ago

This is link https://solidos.github.io/solid-ui/dist/solid-ui.js

timea-solid commented 1 year ago

Thank you for the collaboration to get this fixed, much appreciated!

jeff-zucker commented 1 year ago

I can confirm the github.io CDN works, thanks much!