-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Embroider compat #337
Comments
(As ember-fetch is already compatible, there's no need to keep this issue open unless you want to.) |
Thank you @ef4 for the explanation! |
A minimal fix for #600. We should probably follow through with the refactor suggested by @rwjblue in #600 but that can be done later. This is probably not very embroider friendly, but neither is the current code. It's probably easier to just rewrite the shims in terms of ES modules and embroider macros, i.e. what was suggested in #337.
A minimal fix for #600. We should probably follow through with the refactor suggested by @rwjblue in #600 but that can be done later. This is probably not very embroider friendly, but neither is the current code. It's probably easier to just rewrite the shims in terms of ES modules and embroider macros, i.e. what was suggested in #337.
A minimal fix for #600. We should probably follow through with the refactor suggested by @rwjblue in #600 but that can be done later. This is probably not very embroider friendly, but neither is the current code. It's probably easier to just rewrite the shims in terms of ES modules and embroider macros, i.e. what was suggested in #337.
A minimal fix for #600. We should probably follow through with the refactor suggested by @rwjblue in #600 but that can be done later. This is probably not very embroider friendly, but neither is the current code. It's probably easier to just rewrite the shims in terms of ES modules and embroider macros, i.e. what was suggested in #337.
So while it is true that ember-fetch can be consumed by an app using embroider, it's also still true that it needs substantial changes to be truly compatible with embroider, we should likely reopen this. For EmberData, we currently are forced to do the following which is not compatible with us converting to a v2 addon. import require, { has } from 'require';
let _fetch;
if (has("fetch")) {
_fetch = require("fetch");
} This is because |
this is the craziness that makes this not work with embroider v2 addons: https://github.com/ember-cli/ember-fetch/blob/master/index.js#L238-L269 #330 is highly related to this |
Opening this issue because @xg-wang asked in Discord:
There are a couple different ways to answer.
First, does
ember-fetch
work today under@embroider/compat
? Yes, as far as I can tell it works flawlessly, at least in the browser environment. We are still working through fastboot support issues in embroider, so I didn't testember-fetch
in the fastboot environment.Second, how can ember-fetch be implemented as a native V2-formatted addon (assuming emberjs/rfcs#507 is accepted)?
I think it gets simpler to implement using the macro system. All the custom broccoli code becomes unnecessary. Here's a simplified sketch to show the basic idea:
index.js
would look something like:and there would be a
build.js
that looks like:The only bit here that is unclear to me is that we may need to create an API for the addon to get the configured browser targets, so you can implement your
checkIfPolyfillNeeded()
function. That seems like a reasonable extension that can go into the next V2 package RFC (there will definitely be more, because we haven't accounted for all the things all addons need to do yet).The text was updated successfully, but these errors were encountered: