ui.js
ui.js copied to clipboard
Dev module tree shaking
Hi,
I had split classes to separated files and added a rollup dev dependancy to merge it again and produce the exact same file (ok maybe 2 extra blank lines and UITab being moved before UITabbedPanel who depends on it).
I added the build results to avoid forcing users to build themself and let them use the ui.js
directly as before...
The build contains the same ui.js
as original and a namespaced one ui.ns.js
to be used without modules using a global script tag (see README).
Hope this can help to get more contributions...
Everything looks good but I would remove the ui.ns.js
build and related code. This lib was already modules-only.
Why not let the choice to the user for modules or not? It's already there... ( please note I'm in favor of modules anyway, but the need of a webserver may bother some cases )
Another thing is that src/namespace.js
(that produce ui.ns.js
) is also a way to get bindings without the "UI" prefix that can be a bit redundant when all classes are imported with a
import * as UI from './src/index.js'
new UI.UIText()
against
import * as UI from './src/namespace.js'
new UI.Text()
(please note that function (class) names are always 'UI' prefixed aka UI.Text.name == "UIText"
)
... btw, I'll do how you want, but I wanted to expose arguments why this version exists ;)
Another question I had :
Do you want rollup to produce the file in src/ui.js
as before? I did create a build folder as usual but it easy to change...
Why not let the choice to the user for modules or not?
Because the more "choices" the more things to maintain in the future.
Do you want rollup to produce the file in
src/ui.js
as before? I did create a build folder as usual but it easy to change...
No need. The simpler the PR the better 🙂
import * as UI from './src/index.js' new UI.UIText()
That's not how the library is supposed to be used though.
It's supposed to be used like this:
import { UIText } from './src/index.js'
new UIText()
HI!
I just did the changes said above... I'm not sure about the README change because it was show the "choices" for importing, but there is no choices anymore... You may not merge this last commit...
I'm not sure what to do about the old file in src/ui.js
, you guys from three/editor may still need it right know, dunno :)
So I kept it !