-
Notifications
You must be signed in to change notification settings - Fork 99
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
Docs: add info about merged app directory #780
Comments
// cc I think it should be for case - we have |
I've also gotten bitten by the ESA Application route class export stomping my TS class. |
I've also experienced the same issue with |
This is a big trap. Any app that consumes an addon that exports a file that matches the name of a file in the app will sporadically get a bad build. ESA is one of the most popular add-ons, and it happens to export the application route. So that is why people have come across this issue using it. Another very common case will be apps that consume app-specific addons (ones written just for one or two apps, not public consumption). The reason is this type of addon is often used to define a base which the one or more apps can extend. It is natural in this case for the files to have the same name in app and addon, and for there to be lots of them. We were bitten by both the above scenarios (three apps use esa and consume two local add-ons). It was difficult to track down and cost us a bunch of time. |
Ran into this again. This time it's the This happens only to me and does not happen to my teammates and CI. Extremely frustrating! I strongly believe that, if |
Note that I can't use a different service name like Are you expecting me to fork |
OK, this seems to be the one: broccolijs/broccoli-persistent-filter#166 |
@lolmaus we have hacked around this by creating a // app/services/-private/intl.ts
// whatever code you need to customize… Then re-export it in a JS file: // app/services/intl.js
export { default } from `<your-app-or-addon-name>/services/-private/intl`; This way you don't have two TS files with the same name in your tree. |
Happily we have a way to at least give you a warning here (see the PR @dfreeman just opened earlier today). The issue here is unfortunately entirely upstream from us and there's nothing we can do but warn. The medium-term solution here is for |
Maybe it's possible to manually remove JS files from the build via an in-repo addon? |
Doing so would be inherently fragile and likely to break things, because people (for good or for ill) depend on that behavior across the ecosystem. You might be able to build something that works for your specific app, but unfortunately it wouldn't be generalizable. If you do, it'd be a great thing to blog about and link to from here for the sake of others hitting this pain point! |
Well, I'm basically asking if using |
so how can we solve this issue issue for ESA? |
There are multiple suggested workarounds in this thread. Those are the best options available at present, unfortunately. |
@theloosecannon this is our current approach: #780 (comment) |
We ran into a similar issue with ember-redux. Our reducers/index.ts file needed to be renamed to index.js and the warning went away. |
We ran into this problem with We did have a custom store subclass and hit this issue once we renamed it to // app/services/store.js
export { default } from './-store';
export * from './-store'; // app/services/store.d.ts
export { default } from './-store';
export * from './-store'; I haven't tested that the |
Have there been any updates as to the best practices to handle this, or perhaps modern / upcoming Ember APIs that might sidestep these issues? |
The workarounds described here remain (and will remain) the best options as long as Ember’s app-level build is still a “classic” build system reliant on the resolution and override rules it has used for roughly a decade now. When it is replaced with a v2 app authoring story (presumably using Vite or similar), the issue will be fundamentally resolved. In the meantime, this is inactionable on our end. Equally importantly, we now recommend that people switch to using |
We currently document one gotcha for addon authors building addons in TypeScript:
To expand on that for future readers who may stumble on this (and as a starting point for the docs we should write up):
Having
.js
supplied to a specific path inside theapp
namespace by both an addon and the app itself, when one of them is using TypeScript to generate that file, creates a caching problem. When addons inject.js
files into theapp
namespace, and we're compiling.ts
files to.js
files in the consuming app (always in theapp
namespace), or vice versa, we can end up in a situation where Ember CLI sees that there is already a.js
file there, so it ignores the one generated from.ts
. Which one it picks up seems to be semi-random (at least: we haven't chased it down to see if it's consistently replicable).The real solution here is for addons to stop injecting themselves into the app namespace and to supply imports people can use instead to explicitly opt into using their functionality. However, until that becomes a community norm (best guess: not until Embroider lands), we should document this as a gotcha, including the kinds of build errors it produces, so that people find it when it happens to them and we have a useful place to direct addon authors to in understanding why and how they're breaking their consumers.
Ecosystem issues
The text was updated successfully, but these errors were encountered: