Closed Munter closed 10 years ago
It would be preferable to not bundle a specific version of almond.js with assetgraph-builder, so I'm thinking that the user could configure it with something like this:
<script src="require.js" data-main="main" data-almond="almond.js"></script>
A non-homegrown syntax would be nicer, though. Maybe almond.js could be harmlessly included with a regular script tag even during development?
Also, I'm wondering how it'll play with require-jquery.js
.
What is the use case of require-jquery.js
other than include jquery.js
before require.js
?
I didn't think about the versioning problem. I can't think of any case I have where I would need to control the almond version myself other than getting a fairly new one, since it seems to have been stable for quite a while.
An alternative to the data-almond
syntax could be to have a version of almond in builder through npm, which would replace requirejs when --almond
is set. If a value to that switch is set to a path to almond.js
this is the version that will be used, so people can override the bundled version.
What is the use case of require-jquery.js other than include jquery.js before require.js?
That's pretty much it. It makes require(['jquery'], ...)
work without screwing up the "on DOM ready" event etc. I'm using it in a project, but I'll experiment with kicking it out soon. It's kind of an antipattern to bundle the two together, especially when you don't want to upgrade both at once. I'll follow up here if I succeed :)
An alternative to the data-almond syntax could be to have a version of almond in builder through npm, which would replace requirejs when --almond is set. If a value to that switch is set to a path to almond.js this is the version that will be used, so people can override the bundled version.
Hmm, couldn't that turn into a versioning nightmare? I think the user should be in control of exactly which version of almond.js gets injected.
That's pretty much it. It makes require(['jquery'], ...) work without screwing up the "on DOM ready" event etc. I'm using it in a project, but I'll experiment with kicking it out soon. It's kind of an antipattern to bundle the two together, especially when you don't want to upgrade both at once. I'll follow up here if I succeed :)
I'm pretty sure work has been done so you can just configure jquery
as a target path in require.config()
and it will work out of the box. jrburke has been feeding back stuff to jquery to make them interoperable.
Hmm, couldn't that turn into a versioning nightmare? I think the user should be in control of exactly which version of almond.js gets injected.
The user would be in control if they use --almond /path/to/my/almond.js
in the described case.
+1
I've given this a bit more thought and am leaning toward the declarative html-attribute definition now. I propose this:
<script src="require.js" data-main="main" data-assetgraph-almond="almond.js"></script>
Without a command line switch. If the attribute is there, just replace with almond and don't look back.
Only if no urls are loaded using require.
This should probably be behind a command line switch as well.