-
Notifications
You must be signed in to change notification settings - Fork 50
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
Distribution Formats #18
Comments
Is umd forever a strict es5? Or do we ever try to include some ES6 features that are widely adopted, but wrapped in umd given the missing ESM loader spec? |
With the current TypeScript compiler (1.8), it is all or nothing. So my recommendation would be UMD would be ES5 target. Even if there is granular targeting in TypeScript (which is likely for 2.0), we could create distributions that include some ES6 features, but which ones? While the expectation that the UMD would work in any environment (assuming that we plan to support IE11 for a while). I think anything finer grained would be dependent upon a build pipeline which would either use "pure" ES6+ or TypeScript as input. I guess the only thing worth considering distributing is a "modern" build, which I would recommend being a single UMD bundle with certain modern features and be only for Node.js 4+, Chrome, Firefox, Edge, Safari 9+, iOS 9+, Android 5+, but that might be a rabbit hole. |
Will typings be provided in ES5 or ES6 format or both? Currently |
Currently, but I have my PR for Symbols, Iterators, Set, Generators are syntax and TypeScript are working on being able to down emit them. |
I took a look at the PR. I'm not sure what our approach should be for implementing shims in Dojo 2. I understand the value in supporting My thought regarding typings were more about finding ways to add ES6 typings to modules where it might make sense. For instance, Symbol and Symbol.iterator are supported on every platform > IE11, so for project with a browser matrix Edge 12+ will dojo/core provide a good experience? Furthermore, how do we write dojo in such a way that TypeScript code in For instance, in
But for developers using ES6 the first argument should include iterables:
One possible solution is to selectively compile in es6 specific code that handles current ES features like iterators; e.g. Going back to the original question, I think we can delay some of these decisions. If we do, I think the above proposal provides a good starting point. However, given this discussion we may want to remove the Also, please let me know if I'm missing the point. In Dojo 1 we simply wrote everything to work in the lowest targeted browser and created shim or feature detection to use later methods. With TypeScript it seems that we must also take into account the most modern features for typings while writing code against the lowest common denominator of browser support. |
No, we never said all. We said those parts of ES6+ which we found useful.
Lots of people say that, but Dojo has never been able to afford the assumption that browsers are supported. IE11 is still 23% of the market share, IE8 still 8.16%. Not supporting IE8 is still "controversial" for Dojo 2. Plus you have Android 4.4. It isn't all about desktop browsers.
That only took 6 years.
See above.
If we believe we can shim Iterables (we can) and we like Iterables (we do) we should adjust the APIs so that someone can depend on core and write their code in a way where they don't have to think about it. TypeScript takes care of the syntax and dojo-core should take care of the functional shimming where appropriate. Specifically going back and updating the APIs post the landing of a iterable shim would be a task we should accomplish. I think we need to bisect this issue though. There are really two parts to this I realise now:
Let's keep this issue focused on distribution formats and open a new issue regarding the second point. But in summary, we need to still write our core libraries shimming as much ES6 functionality as we need or find useful. End users can easily narrow the targeting of what UAs they can deal with, we don't have that luxury. |
I took a look at how RxJS handles ES6 types like symbol and found the same issue there as I'm trying to resolve here. When RxJS uses an iterator it does so with a shim created in RxJS: https://github.com/ReactiveX/rxjs/blob/master/src/symbol/iterator.ts As a result, RxJS often uses In I think Conditional Decorators and Granular Targeting offer good solutions for this. Thank you for pointing me to those. Does this mean we are going to wait to address ES6 typings until TypeScript 2.1? If we wanted, we could create a separate array.core.es6.d.ts typings to address this for ES6 users, which will in-turn provide proper intellisense and type hints for ES6 Dojo users. If we don't do this, should we broaden some of our typings (like RxJS does) to allow developers of ES5 and ES6 to use the same typings? And if we don't do any of this, is it appropriate for us to release an ES6 dist? |
Yes, I agree, we will have to put ES6 typings on hold until we have the Conditional Decorators and Granular Targeting. @tomdye is working on the ES6 compiling stuff. Ideally we should integrate whatever solution we come up with into SitePen/dts-generator. So for now, I propose we do this:
I will create a separate issue for ES6+ typings. |
@bryanforbes is going to do some thinking on this too... moving to him for now. |
I have done some thinking about this and @novemberborn, @tomdye, and myself had a chat which provoked me. Also, @kfranqueiro brought up some thoughts and considerations. Here is what I propose:
I suspect that this would require us to change the layout of our current packages so that the structure does not differ significantly from the built and unbuilt packages. I would propose that we:
|
The recent Dojo packages tend to contain multiple public modules, e.g. What would the export be of the rolled-up main? Tests typically shouldn't be distributed. You can't run them anyway without the dev dependencies. I'm not 100% sure, but I suspect that when installing a package from GitHub, npm won't install dev-dependencies. This would make it harder to automatically build the |
Possibly, but then I would do CJS, AMD, ES6 and UMD. I still don't think there is a big risk with UMD. We had a loader defect, which we fixed. I still think we should have a "ready to go" distribution that focuses on the main way we expect the modules to be consumed. We have modules that are dependent on AMD plugins, therefore we could say the "official" public distribution is only AMD.
My concern was spitting modules in the root directory when sources are elsewhere in certain distributions is problematic. Having them located in the
Asking realistic questions, shame on you. 😄 I assumed they would be an AMD layer bundle, therefore exporting the mids versus the export structure. Therefore in CJS land I would assume it would be like this: require('dojo-core')['dojo-core/async/Task']; But in TypeScript land it would just be the same old thing and in AMD, it would be loading a layer.
Google Foo suggests an approach |
Sure. I'm just being overly precise 😄
It's just that CJS doesn't have a package map, and Node may not gain one for ES6 either.
The problem would be that that |
Can someone explain the benefit of including a "single rolled-up UMD module"? Seems to me that packages are more often than not a collection of semi-disparate things that users are more likely not interested in loading 100% of, and would be better off relying on a build or rollup step of their own to generate a layer/bundle of everything they want. The proposed "CJS land" way of exposing/loading stuff from it also seems super-unorthodox (and for that matter, on the Node side of things, the entire thought of a rolled-up module seems less relevant). I'm also concerned that providing the rolled-up module OOTB might again contribute to false claims of "oversized kitchen sink" like we already get in Dojo 1 by people who don't/didn't understand how modularity and builds worked (though admittedly the lack of pruning in Dojo 1's build system also contributed to that in a sense). |
I will admit I am 50/50 on it. I suggested it because it would be a simple "take it and run" scenario, especially if many of our packages are not semi-disparate things. Yes, One thing I thought about writing was "if it is appropriate for the package" to have one consumable rolled up module, but the "if appropriate" would cause the distributables to be inconsistent. |
I think that a rolled up (or at least an optimised rolled up) module may well be the only 'easy' way for us to provide webpack support unless we create a work around for the AMD plugins. But I would hope that an end user would create their own selectively from source to avoid bloat |
I think it's fine to have a Rolling up implies duplicating the code in the |
We should also consider targeting CDNs (i.e. google) for distribution. Not sure if that would add weight to having a rolled-up minified UMD release or not. |
Something that came up RE potentially publishing dgrid to npm may also have bearing on the idea of double-publishing these packages (once under @dojo, once outside): There is no way to alias packages in npm, which I presume would mean you would have to reference each of the two packages differently (or move/rename/symlink one manually), which seems like it could be highly annoying and lead to inconsistent docs/usage between the two versions. |
@gbaumgart I took a look at your guide lines. There are a few things to consider:
|
Ok, several of us discussed this and this is what we came to:
|
* Integrate grunt-dojo2 * Realign distribution build (refs: dojo/meta#18) * Migrates to typings/typings, except for /tests (refs: dojo/meta#27) * Add prepublish and test to package.json
* Integrate grunt-dojo2 * Realign distribution build (refs: dojo/meta#18) * Migrates to typings/typings, except for /tests (refs: dojo/meta#27) * Add prepublish and test to package.json
* Integrate grunt-dojo2 * Realign distribution build (refs: dojo/meta#18) * Migrates to typings/typings, except for /tests (refs: dojo/meta#27) * Add prepublish and test to package.json
* Integrate grunt-dojo2 * Realign distribution build (refs: dojo/meta#18) * Migrates to typings/typings, except for /tests (refs: dojo/meta#27) * Add prepublish and test to package.json
* Integrate grunt-dojo2 * Realign distribution build (refs: dojo/meta#18) * Migrates to typings/typings (refs: dojo/meta#27) * Add prepublish and test to package.json * Other packaging updates
* Integrate grunt-dojo2 * Realign distribution build (refs: dojo/meta#18) * Migrates to typings/typings, except for /tests (refs: dojo/meta#27) * Add prepublish and test to package.json
Thinking about how we should format distributions, I was thinking something like this:
I think it will be important to consumers to have easy ways to consume the packages in different workflows. I would expect our build pipeline would eventually just grab the
/src
and keep rolling things up into a final distribution build, but I can see where people will want to grab things like/es
and use Babel or something else to do their targeting won't need to have TypeScript installed.The text was updated successfully, but these errors were encountered: