-
Notifications
You must be signed in to change notification settings - Fork 216
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
Early exports and typescript. #265
Comments
Hey @Yshayy, We've been getting a lot of issues related to curl.js's "early exports" feature, which is somewhat broken, atm. It works fine for some dependency cycles, but not all. The problem is that curl.js executes factory functions eagerly. Unless something forces some modules to wait for the next event turn (setTimeout, domReady, etc), curl.js can't resolve the cycle correctly. I'm going to do a quick assessment to see how much work it will be to defer factory execution. If it's simple, then we'll release 0.9 with deferred factory execution. Otherwise, here's the "Plan B" for 0.9:
Thoughts? -- John |
I think that early export behavior is really problematic when using AMD, because it require adding another layer of async handling for resolving resources other than "define", make code more difficult to predict (if we would've use setTimeout/domReady) and manage (if we use resolved promises). It can be indicated by dropping the referenced argument in the factory method - |
Hey @Yshayy, I was able to defer factory execution. This is the best option, by far. Early exports still happens in most cases, but because factories only execute just-in-time, the exports should never be too early any more. As I feared, there was a cascade of changes to make this work, but there are other benefits to this refactoring, as well. I pushed the latest code to the dev branch. Please try it out as soon as you have a chance. Thanks! -- John |
Have you had a chance to try this, @Yshayy ? |
Not yet, I'll try testing it in the next few days. |
Hi,
We're using curljs for quite some and we recently start migrating our code to typescript.
Typescript generated code is wrapped in AMD by the typescript compiler like this:
define(["require", "exports", 'deps...'], function(require, exports, deps...)
{
}
While this behavior should work fine in RequireJS (according to TS documentation), in curljs it triggers early export (which make sense for cjs modules), and make the deps not available to the module on resolve (which is especially problematic in typescript due to it's classical inheritance features).
Anyway to control/tweak this behavior?
Thanks
Yshay
The text was updated successfully, but these errors were encountered: