Closed adamjgrant closed 10 years ago
Hey @ajkochanowicz,
Can you describe your environment a bit? Are you using AMD? If so, you should configure packages (such as when.js) using the packages
configuration, not paths
. See here.
Does that help?
-- John
Hey @ajkochanowicz That particular file, the es6 Promise shim, is built with browserify and is a self-contained file. All of the referenced modules are contained within and no network fetching should occur. It's in use by many people across AMD and node environments, so we know that it works.
As @unscriptable mentioned, it would be helpful for us to know how you are trying to load it: what environment (eg, node, or AMD in a browser, etc.), using what loader (eg RequireJS), and what your loader configuration looks like.
Thanks!
I'm using browserify to run system.js (kind of overkill, but trust me--it's for good reason) of which when.js is a dependency.
In any case, it does look like I need to refer to @unscriptable 's link.
Thank you.
I think @guybedford is jumping through a few hoops to concatenate the files that go into system.js. I wonder if that's somehow confusing browserify.
My guess is that system.js running within browserify is probably a fairly untested setup :) I'm def not a browserify expert, but I wonder if you need to tell it that when.js es6-shim is already browserified or somesuch. Keep us posted, @ajkochanowicz, and we'll help as best we can.
Yes, that's the conclusion @guybedford came to as well. I'll keep hacking away. Thanks.
Unrelated: hey adam! was cool to see you pop in here
sup brah
I am facing this very same issue. I'm using AMD and configuration using packages. I'm trying to require this as dependency define(['when/es6-shim/Promise'], function(p) {});
.
Am I doing anything wrong?
I am facing this very same issue
@memoorthy It looks like you're using AMD (rather than CommonJS), so I just want to make sure I understand what you mean. Do you mean the original poster's issue wrt browserify? Or are you using another build system, such as r.js?
I should have been more clearer. Yes, I'm using AMD. With respect to the original post, I am facing the error related to ./lib/makePromise
[15:18:24] Error: ENOENT, no such file or directory '/Users/xxx/web/when/es6-shim/makePromise.js'
In module tree:
app/index
app/run
when/es6-shim/Promise
at Object.fs.openSync (fs.js:438:18)
My app/run
contains this define:
define(['when/es6-shim/Promise'], function(p) { ... })
Require config:
packages: [
{
'name' : 'when',
'location' : 'when',
'main' : 'when'
}
]
Thanks.
[15:18:24] Error: ENOENT
That looks like a Node.js error. Are you getting that when running r.js? Or perhaps webpack? ie it appears to be a build-time error, rather than a runtime error, so any info you can provide about your build setup will be helpful. Thanks!
when/es6-shim/Promise is an already-browserified file, and afaik, should work correctly with AMD loaders. However, I don't really know how well it works with build systems like r.js.
ah! Yes, its a build-time error. However, as in the original post the error is due to failure to resolve ./lib/makePromise
. My r.js process (build setup) is very basic to minify (uglifiy) and bundle code with findNestedDependencies
flag set to true.
Let me dig deep in a vanilla setup. Thanks @briancavalier !
Cool, yes keep me posted.
The file when/lib/makePromise.js, along with several other files, is built into when/es6-shim/Promise (take a look inside to see). IOW, it is a self-contained minimal build of an es6-compliant subset of when.js, built using browserify. So, ideally, a build tool like r.js shouldn't go looking for those files. However, it seems like trying to run an already-browserified file through r.js isn't working, even though RequireJS can load it at runtime.
This may mean that we need to rethink our shim-build approach. I'll give it a bit more thought on my end as well.
Any workaround for this? My r.js build is failing for the same reason...
@teohhanhui As a workaround, you can either use the when/es-shim/Promise.browserify-es6
module directly (that is, the non-browserified shim), or create a simple module that does something similar and use that.
For using the browserified version of when.js in the r.js optimizer: if the browserify dependency chain upgrades to https://github.com/ForbesLindesay/umd version 3 (which contains this change) and if r.js 2.1.16 is used (released within the next day, and contains this change), then it should be consumable by r.js.
Hey @jrburke, thanks a bunch for the heads up! Seems like we just need to sit tight until a new version of browserify is available (one that depends on umd >= 3.0.0). Then we can release a new when.js with an es6 shim built using that new version.
I'll be the first to wear the dunce hat and say this is all fantastically confusing.
@ajkochanowicz I agree it's confusing. Sorry about that :( However, it's really a scenario that should have worked all along. The confluence of when's UMD format, browserify (via it's umd
lib dependency), and r.js is what causes it to fail. It was no particular fault of any one of those, but rather likely the fact that it hadn't been common to use r.js to do builds containing pre-browserified files.
The good news is that once browserify updates it's dependencies, it should Just Work.
That's great. I understand it's a difficult problem to solve and appreciate your hard work.
I'm getting the errors
At first I thought this was something wrong with my implementation.
Then, I noticed in the Promise.js file, the references to the modules don't appear to be correct.
They reference the current directory, which is not /lib. Shouldn't they be
?