cocopon / tweakpane

:control_knobs: Compact GUI for fine-tuning parameters and monitoring value changes
https://tweakpane.github.io/docs/
MIT License
3.57k stars 90 forks source link

Please add a UMD library version again. #599

Closed create3000 closed 7 months ago

create3000 commented 8 months ago

I am using Electron, and libraries can only be imported view require. Version 3.* of Tweakpane was still available as UMD, thank you guys. With some small changes, package.json could handle this:

{
    "main": "dist/tweakpane.js",
    "module": "dist/tweakpane.mjs",
    "exports": {
        ".": {
            "require": "./dist/tweakpane.js",
            "import": "./dist/tweakpane.mjs"
        }
    },
}

This is a minimal example how it could be. Please be careful with the path names, dots and slashes are important, names and suffixes can be choosen as you like. It should then be possible to use Tweakpane with both ESM import statement and Node require.

cocopon commented 8 months ago

I've decided to distribute v4 exclusively as ES modules for better maintainability. If you need UMD support, you can continue to use v3.

create3000 commented 8 months ago

I actually assumed that you could automate the whole thing with a build script and that this would not result in any additional work for you.

cocopon commented 8 months ago

There are many ways to use the package: through npm, package bundlers, tsc, or directly using a bundled file, etc. For example, package.json have a property "type: module", indicating that this package exclusively supports ES modules, and does your suggestion still work under these conditions? I'll need to verify all compatibilities for each method by writing test cases, ensuring support across future updates.

aayushchouhan24 commented 7 months ago

sir please add UMD version i want to use your library in my library

But my library is for both UMD AND ES

So i would need to manually modify and host the CDN

Plz help!!!

my modification's

(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.tweakpane = {})) })(this, (function (exports) { 'use strict'

//rest of your library while replacing "export { BladeApi, ButtonApi, FolderApi, ListBladeApi, ListInputBindingApi, Pane, Semver, SeparatorBladeApi, SliderBladeApi, SliderInputBindingApi, TabApi, TabPageApi, TextBladeApi, TpChangeEvent, VERSION };"

exports.BladeApi = BladeApi
exports.ButtonApi = ButtonApi
exports.FolderApi = FolderApi
exports.ListBladeApi = ListBladeApi
exports.ListInputBindingApi = ListInputBindingApi
exports.Pane = Pane
exports.Semver = Semver
exports.SeparatorBladeApi = SeparatorBladeApi
exports.SliderBladeApi = SliderBladeApi
exports.SliderInputBindingApi = SliderInputBindingApi
exports.TabApi = TabApi
exports.TabPageApi = TabPageApi
exports.TextBladeApi = TextBladeApi
exports.TpChangeEvent = TpChangeEvent
exports.VERSION = VERSION

}))

cocopon commented 7 months ago

Here is my opinion at this time. https://github.com/cocopon/tweakpane/issues/599#issuecomment-1923456585