You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pluginBuilder not applied when used as a sub-dependency that loads first #228
Then during the build, I am getting the version of moduleA without the pluginBuilder substitution run against the module 'test2'.
What I'd like is for 'moduleA' to be the pluginBuilder version during a build and the normal version outside a build. This allows moduleB to act like an 'extension' of moduleA sharing API calls.
Marking this for "next" consideration, which means that it may get included in the next bug fix build, but would not block a higher priority bug fix build if there were worse bugs in the queue.
I'm still in need of this support for some refactoring in RequireCSS. I want the css module to have an 'injection' api for dynamic css injection as well as the plugin injections.
Basically, I think the main thing is to check if a module defines a "pluginBuilder" property before loading it as part of an optimized build. If it does, then to load that version, even when the load isn't a plugin-style load.
Otherwise I think the work around for this is just to ensure that some dummy plugin load is run before the normal load to ensure it is defined this way from the start.
I think the workaround above should work. In the end I didn't need this functionality, as the dynamic plugin use during an optimizer build turned out to be an unnecessary edge case. Rather put the time into 241 if you can!
I just realised this issue is actually critically affecting many of my plugins.
If I have a plugin, which I load through a wrapper module, then during the build the wrapper module loads the plugin as a normal module. Because the plugin is loaded, the pluginBuilder config item is ignored. Thus plugins loaded via wrapper modules have no ability to specify a pluginBuilder!
This is tricky because moduleB wants to use moduleA in source form, because moduleB is used as a plugin, but then you want moduleA's pluginBuilder to be used when processing plugin resources handled by moduleA. I'm not sure how to support that right now because it basically means having two different module values for the same module ID. The loader just uses requirejs under the covers, and it does not support that concept.
Unfortunately, I'm under a time constriction for getting 2.1 out, so I'm going to bump this out of that milestone. It will require a bigger change, and I'm not sure what that will look like yet. I have reopened the bug though.
I think the initial case mentioned is somewhat of an edge case.
In the latter case, the module is being used for the first time as a plugin, but because it was passed through a wrapper this distinction is not detected. A quick but perhaps hacky fix would be to detect wrapper module structures (with a regular expression) and apply the pluginBuilder check in this case.
The alternative is that I provide map config instructions for plugin users which really isn't a big issue, I've just been trying to avoid it and perhaps unnecessarily.
I just realised the wrapper issue is a duplicate of #209. Perhaps this should be reopened over this one, as the main issue here still remains an edge case.
I'm not sure I follow, the brief scan of #209 seems to be that it is closed out, the map config fixes it. Maybe the issue was the just opened today requirejs/requirejs#484 which is now fixed in the dev2.1 branch? If not, then I think I need a test case/test repo I can try to understand the problem.
The main motivation being saving users the need to enter a map config (which is not a big deal I know, I've changed the modules for now to avoid this).
css.js is the automatically created wrapper module of the form:
Css is a plugin, and has a 'pluginBuilder' property pointing to './css-builder'.
When building, the relative path for the pluginBuilder is seen relative to the wrapper module, causing the pluginBuilder call to fail.
One other side point is that pluginBuilder fails are quite silent and difficult to spot. A nicer error message for the path not resolving (instead of a null issue later I think it was) would assist spotting this.
I'm quite happy to move to the map config method as I have done. I just really liked the idea of a config-free install with volo.
Thanks for walking through the test case. This case fails because the wrapper module is the one that is parsed to check for the pluginBuilder property, not its "dependency" 'require-css/css'.
Dependencies of loader plugins need to be executed in full because they may be used as regular modules to do things, they are not considered to be the "real" plugin implementation. This one is tricky because the "real" implementation that has the pluginBuilder is a dependency.
So this will be tricky to sort out. It is getting caught against the general desire to avoid configuration, the use of pluginBuilder. pluginBuilder to me is less common than just using the plugin that can also do builds but then just excluding the module wholesale via a stubModules build config after the build. But the pluginBuilder capability exists.
I guess the answer it so task the developer to insert a config, either a packages config or a map config to get this to resolve correctly.
I cannot think of an easy code fix though, so going to close this out as "use config to sort it out". There is only so far convention-based programming can go. However we can reopen it later if we think of a way to support this.
Activity
jrburke commentedon Jul 17, 2012
Marking this for "next" consideration, which means that it may get included in the next bug fix build, but would not block a higher priority bug fix build if there were worse bugs in the queue.
guybedford commentedon Sep 19, 2012
I'm still in need of this support for some refactoring in RequireCSS. I want the css module to have an 'injection' api for dynamic css injection as well as the plugin injections.
Basically, I think the main thing is to check if a module defines a "pluginBuilder" property before loading it as part of an optimized build. If it does, then to load that version, even when the load isn't a plugin-style load.
Otherwise I think the work around for this is just to ensure that some dummy plugin load is run before the normal load to ensure it is defined this way from the start.
jrburke commentedon Sep 19, 2012
The "next" tag has not worked out as I hoped, putting this in the 2.1 bucket for consideration, but may get bumped to a later release.
guybedford commentedon Sep 24, 2012
I think the workaround above should work. In the end I didn't need this functionality, as the dynamic plugin use during an optimizer build turned out to be an unnecessary edge case. Rather put the time into 241 if you can!
jrburke commentedon Sep 29, 2012
OK, going to close this for now. We can reopen if there is a use case that really needs this to work.
guybedford commentedon Oct 1, 2012
I just realised this issue is actually critically affecting many of my plugins.
If I have a plugin, which I load through a wrapper module, then during the build the wrapper module loads the plugin as a normal module. Because the plugin is loaded, the pluginBuilder config item is ignored. Thus plugins loaded via wrapper modules have no ability to specify a pluginBuilder!
jrburke commentedon Oct 2, 2012
This is tricky because moduleB wants to use moduleA in source form, because moduleB is used as a plugin, but then you want moduleA's pluginBuilder to be used when processing plugin resources handled by moduleA. I'm not sure how to support that right now because it basically means having two different module values for the same module ID. The loader just uses requirejs under the covers, and it does not support that concept.
Unfortunately, I'm under a time constriction for getting 2.1 out, so I'm going to bump this out of that milestone. It will require a bigger change, and I'm not sure what that will look like yet. I have reopened the bug though.
guybedford commentedon Oct 2, 2012
I think the initial case mentioned is somewhat of an edge case.
In the latter case, the module is being used for the first time as a plugin, but because it was passed through a wrapper this distinction is not detected. A quick but perhaps hacky fix would be to detect wrapper module structures (with a regular expression) and apply the pluginBuilder check in this case.
The alternative is that I provide map config instructions for plugin users which really isn't a big issue, I've just been trying to avoid it and perhaps unnecessarily.
guybedford commentedon Oct 2, 2012
I just realised the wrapper issue is a duplicate of #209. Perhaps this should be reopened over this one, as the main issue here still remains an edge case.
jrburke commentedon Oct 2, 2012
I'm not sure I follow, the brief scan of #209 seems to be that it is closed out, the map config fixes it. Maybe the issue was the just opened today requirejs/requirejs#484 which is now fixed in the dev2.1 branch? If not, then I think I need a test case/test repo I can try to understand the problem.
guybedford commentedon Oct 2, 2012
I will try and explain it a bit more clearly, I've confused a few points above anyway. Let me know if anything still doesn't make sense.
I was using the
volo.mainconfig setting in the package.json to allow for the automatic generation of a wrapper module. So for example:volo add guybedford/require-cssWould create:
require-css/css.js
require-css/css-builder.js
require-css/normalize.js
css.js
The main motivation being saving users the need to enter a map config (which is not a big deal I know, I've changed the modules for now to avoid this).
css.jsis the automatically created wrapper module of the form:Css is a plugin, and has a 'pluginBuilder' property pointing to './css-builder'.
When building, the relative path for the pluginBuilder is seen relative to the wrapper module, causing the pluginBuilder call to fail.
One other side point is that pluginBuilder fails are quite silent and difficult to spot. A nicer error message for the path not resolving (instead of a null issue later I think it was) would assist spotting this.
I'm quite happy to move to the map config method as I have done. I just really liked the idea of a config-free install with volo.
jrburke commentedon Oct 2, 2012
Thanks for walking through the test case. This case fails because the wrapper module is the one that is parsed to check for the pluginBuilder property, not its "dependency" 'require-css/css'.
Dependencies of loader plugins need to be executed in full because they may be used as regular modules to do things, they are not considered to be the "real" plugin implementation. This one is tricky because the "real" implementation that has the pluginBuilder is a dependency.
So this will be tricky to sort out. It is getting caught against the general desire to avoid configuration, the use of pluginBuilder. pluginBuilder to me is less common than just using the plugin that can also do builds but then just excluding the module wholesale via a stubModules build config after the build. But the pluginBuilder capability exists.
I guess the answer it so task the developer to insert a config, either a packages config or a map config to get this to resolve correctly.
I cannot think of an easy code fix though, so going to close this out as "use config to sort it out". There is only so far convention-based programming can go. However we can reopen it later if we think of a way to support this.
guybedford commentedon Oct 3, 2012
Sure, more than happy to go ahead with the config.