Uh oh!
There was an error while loading. Please reload this page.
@ember-data packages - #395
Conversation
lupestro
commented
Nov 7, 2018
Are the classes for which there will be no imports ever returned by public methods? If so, is there any scenario where not having an export for the classes returned by public methods prevents doing something we'd reasonably want to do? I can think of an ill-advised testing hack that somebody might use this information to do (shudder) but I'm asking if there's a legitimate case for needing those classes. |
Uh oh!
There was an error while loading. Please reload this page.
chriskrycho
commented
Nov 7, 2018
Thinking along the lines @lupestro raises, we'll want a story for the TypeScript side of things for types we need to name but which are not importable. I'll have more later, as I'm excited about this. |
runspired
commented
Nov 7, 2018
@lupestro I think you are asking " are there public classes for which there will be no public imports", to which the answer is YES.
Generally speaking, public classes that don't have public import paths are ones which require extensive setup and lifecycle management by the store and for which it would be infeasible for end users to generate one except via the For the most part, public store interfaces are available for accessing instances of these things, where public methods are not available these gaps should be addressed. The common case folks point out is |
mehulkar
left a comment
There was a problem hiding this comment.
This is great, we're already using some mixture of direct imports and DS, and it was never quite clear to me what the difference was (or why the guides don't show import Model from 'ember-data/model, for example)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
igorT
commented
Nov 14, 2018
Need to add RecordData in |
igorT
commented
Nov 14, 2018
Should add a discussion of moving the package into a separate github org |
Adding proper @ember-data package name where missing
Uh oh!
There was an error while loading. Please reload this page.
tomdale
commented
Nov 30, 2018
I don't think the naming rules for Ember Data should deviate from the rules used for Ember.js in RFC #176. |
chriskrycho
commented
Nov 30, 2018
FWIW, I strongly agree with @tomdale here and I think if we have some set of limitations imposed by Node then we should work around Node's limitations. However, it's worth note that it's certainly possible to support non-Node-friendly lookup rules (even with the importMaybe,{map}from'true-myth/maybe';☝️ is not a legal Node import (and accordingly there are workarounds in the library and notes in its docs for Node-only consumers), but it is a resolvable import in contexts which understand ES modules, and for all the reasons that RFC #176 hashed out, it works extremely well to support the design of module APIs that express the actual intent and design of the library. |
chriskrycho
commented
Dec 5, 2018
An addendum to the above after I chatted with @runspired elsewhere for a while: one of the goals here is to make it so that the custom shenanigans I do to make this "just work" in the current Ember CLI pipeline is not necessary. And the base Node algorithm, as noted in that RFC, doesn't support it. That doesn't mean we shouldn't do the workarounds necessary, but it would be a lot nicer not to have to. The net of that conversation was me feeling 🤔 🧐 about the right way forward here. |
runspired
commented
Dec 5, 2018
cc @chriskrycho
Precisely. A key constraint is that both maintainers and consumers of cc @tomdale
Putting aside the conversation surrounding editor / typescript support, (e.g. in a perfect world in which those constraints were fully solved), The Spirit
Furthermore, the original RFC acknowledges that it may not account for all the necessary constraints
Most importantly, the mental model was the driving principle behind the organization proposed by the RFC
This organization was also driven by two rules: If we organize by mental model, these rules conflict when put into practice in Specifically, Using the *note: mixins are treated as classes below, with the importAdapterfrom'@ember-data/adapter';importBuildURLfrom'@ember-data/adapter/build-url-mixin';importAdapterfrom'@ember-data/adapter/rest';importAdapterfrom'@ember-data/adapter/json-api';importAdapterError,{errorsHashToArray,errorsArrayToHash}from'@ember-data/adapter/error';importInvalidErrorfrom'@ember-data/adapter/error/invalid';importTimeoutErrorfrom'@ember-data/adapter/error/timeout';importAbortErrorfrom'@ember-data/adapter/error/abort';importUnauthorizedErrorfrom'@ember-data/adapter/error/unauthorized';importForbiddenErrorfrom'@ember-data/adapter/error/forbidden';importNotFoundErrorfrom'@ember-data/adapter/error/not-found';importConflictErrorfrom'@ember-data/adapter/error/conflict';importServerErrorfrom'@ember-data/adapter/error/server';//...importSerializerfrom'@ember-data/serializer';importSerializerfrom'@ember-data/serializer/json';importSerializerfrom'@ember-data/serializer/rest';importEmbeddedRecordsfrom'@ember-data/serializer/rest/embedded-records-mixin';importSerializerfrom'@ember-data/serializer/json-api';importTransformfrom'@ember-data/serializer/transform';importDateTransformfrom'@ember-data/serializer/transform/date';importBooleanTransformfrom'@ember-data/serializer/transform/boolean';importNumberTransformfrom'@ember-data/serializer/transform/number';importStringTransformfrom'@ember-data/serializer/transform/string';What this shows is that a strict interpretation of the However There's also the following considerations here that
With this in mind, we could potentially make the argument that sub-classes could be "named exports". In the case of importAdapter,{RESTAdapter,JSONApiAdapter,BuildURLMixin}from'@ember-data/adapter';importAdapterError,{errorsHashToArray,errorsArrayToHash,InvalidError,TimeoutError,AbortError,UnauthorizedError,ForbiddenError,NotFoundError,ConflictError,ServerError}from'@ember-data/adapter/error';//...importSerializer,{JSONSerializer,RESTSerializer,JSONAPISerializer}from'@ember-data/serializer';importEmbeddedRecordsfrom'@ember-data/embedded-records-mixin';importTransform,{DateTransform,BooleanTransform,NumberTransform,StringTransform}from'@ember-data/serializer/transform';In some cases, this is a nice cleanup, but in others it produces awkwardness. There is still a third option, a middle ground, in which we recognize the increased importance of Adapter and Serializer and their relative Prominence in the mental model by keeping their subclasses as default exports. Personally, I find this the most intuitive, but it must be conceded that the "mixed" nature of this approach risks confusion... but likely no more confusion than "sub classes not being default exports" already risks. importAdapter,{BuildURL}from'@ember-data/adapter';importAdapterfrom'@ember-data/adapter/rest';importAdapterfrom'@ember-data/adapter/json-api';importAdapterError,{errorsHashToArray,errorsArrayToHash,InvalidError,TimeoutError,AbortError,UnauthorizedError,ForbiddenError,NotFoundError,ConflictError,ServerError}from'@ember-data/adapter/error';//...importSerializerfrom'@ember-data/serializer';importSerializerfrom'@ember-data/serializer/json';importSerializer,{EmbeddedRecords}from'@ember-data/serializer/rest';importSerializerfrom'@ember-data/serializer/json-api';importTransform,{DateTransform,BooleanTransform,NumberTransform,StringTransform}from'@ember-data/serializer/transform';It's been quite some time since I came to the realization that regardless of approach, we're weighing inescapable tradeoffs and making compromises when it comes to the |
tomdale
commented
Dec 5, 2018
I don't understand the concern about IDE/editor integration. Can someone unpack "custom build shenanigans"? The Node module resolution algorithm absolutely supports nested modules in npm packages, in the form See https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview#heading=h.k0mh3o8u5hx for a description of how Angular handles structuring their packages to accomplish this natively. |
This reverts commit 54527bc.
Uh oh!
There was an error while loading. Please reload this page.
runspired
commented
Jan 16, 2019
After further discussion, we've decided to accept this RFC. |
rendered