-
Notifications
You must be signed in to change notification settings - Fork 16
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
Adding UMD support #12
Comments
@jwilsson There is nothing to export. So UMD can't give us any flexibility. The only problem of that issue is too strict linting. For multiple modules I'd like to suggest rollup. Here is example |
I think it would be fine to be able to load the main DOMTokenList utility separately, as this is only required in non-browser environments (WebWorker, Node.js). |
@rodneyrehm May I ask about your use case? I don't think it's possible to use |
As far as I see it, DOMTokenList is the perfect base to interface with ID reference lists like aria-describedby (among other similar properties).
I don't see how you can't use it to construct strings of tokens, even outside of the DOM. After all, DOMTokenList is nothing but an elegant interface for mutating a string in a particular way. |
@rodneyrehm Sorry for the late reply. Have you found a way to use |
Sure, see this example. This doesn't work with the browser's DOMTokenList, as it'll throw At this time, your polyfill allows to run outside of the browser, too (example without dom): var data = {
gustav: ''
};
var x = new _DOMTokenList(data, 'gustav');
x.add('one');
x.add('two');
alert(data.gustav); Again, I haven't added any functionality. |
Alright @rodneyrehm, lets do it! I'm thinking we should go with the two separate builds, one "regular" like today and one with UMD support using eduardolundgren/gulp-umd. Would you be interested in taking a look at it? Otherwise, I'll have some time later this week. On another note, I hope I didn't came off as reluctant. I just don't want to introduce too many deviations from the spec :) |
I'm not in a hurry and have no idea of gulp ;)
nope, everything's good! :) |
@rodneyrehm Sorry for the delay. Could you check the new UMD build and see if it works? |
We - and by that I mean me - may have been a bit short sighted. Say I wanted to use both, the full shim and DOMTokenList in the same app, I'd currently be loading DOMTokenList twice. The only way to avoid that is if all the modules, including the file that aggregates/concatenates the source files, are exposed individually. I've only been thinking about either using the shim or the DOMTokenList exclusively in separate context - but I'd actually need to use both in the same context. Since you haven't been exposing modules up to now, you can't break compatibility by anything you do, so long Since all the files in src are valid CommonJS at this point (only // src/index.js -> dist/domtokenlist.js
require('./DOMTokenList-newest.js');
require('./DOMTokenList.js');
require('./classList.js');
require('./relList.js '); This way, anyone with a CommonJS setup would be able to load Considering that anyone who wants to do this, is able to do that |
Hi @rodneyrehm, But I'm thinking that perhaps we should leave it at that then unless someone else is interested in making a proper UMD build of everything either in this project or as a fork of it. Since it's possible, as you say, to build a UMD bundle it using browserify (and other similar tools too, I presume) then I think that's good enough for now at least. I'll reopen and add a "Help wanted" label in case someone finds it and wants to take a stab at it. |
As we started discussing a bit in #11, it would be really nice to add UMD support but it does bring some extra bytes and since we want to keep it as small as possible I were thinking that we should look into a possibility to do a separate/conditional build with UMD support.
I found eduardolundgren/gulp-umd after a quick search, I haven't looked at it any closer but it sounds like something we could use.
Thoughts?
The text was updated successfully, but these errors were encountered: