-
Notifications
You must be signed in to change notification settings - Fork 4
standalone attribute in component.json? #11
Comments
Well, the I'm not sure I understand the use case here. If your module is called "robert", why wouldn't it be called "robert" when it's built in standalone mode? |
I have a base module called 'experiment' basically representing the data model. 'experiment-edit' and 'experiment-render' both extend 'experiment'. I want 'Experiment', 'ExperimentEdit' and 'ExperimentRender' as my exportables. |
Is this more like a plugin use case? Like, transform the name using an inflector? |
I believe this is doable with the current software, but you'll break away from the lowercase naming convention: {
"name": "your-thing",
"paths": ["lib"],
"local": [
"Experiment",
"ExperimentEdit",
"ExperimentRender"
]
} You'll just have to rename your components to match. I know this isn't ideal, but it'd likely work. My original thought here was a plugin, but I'm not sure how it'd work. Thoughts? I'm also thinking about how totally useless
/cc @yields have any ideas here? |
@stephenmathieson IMHO at this point you would want to use builder directly, it makes it extremely simple :D @matchdav just curios if "expirement-render" renders the expirement, why not have "expirement-boot" and render the expirement there, why do you want them exported ? |
Just using builder directly makes sense, thats true. |
@yields I understand that's a better way to do it, but I'm reorganizing another monkey's code and it's kind of a stop-gap TBH. I just don't want the current namespaces to break. Back to the point it does seem to me that if the command line lets me set a flag, there should be a corresponding option in the package build options, especially when it's a batch operation like this, and it seems like it should be a simple patch, check |
makes sense, but i don't think it's a good idea to add this feature especially because it's a stop-gap / fix for old code. i think you are much better of just appending |
So this is how I'm doing it, module.exports = function (builder) {
var standalone = builder.config.standalone,
standalones = Object.keys(standalone),
name = builder.local(),
globalName = (standalones && standalones.indexOf && standalones.indexOf(name) > -1)? standalones[name] : false,
expose = (globalName) ? '\nvar ' + globalName = ' = require(\''+name+'\');\n' : false;
expose && builder.append(expose);
}; But it seems a bit shitty to have to do that when there's already a flag to fire the |
For what it's worth, your plugin can be simplified quite a bit: module.exports = function (builder) {
var map = builder.config.standalone;
var local = builder.local();
var name = map[local];
var js = name
? '\nvar ' + name + ' = require("' + local + '");\n'
: '';
builder.append(js);
}; I'm using a very similar plugin for autoboot-like behaviour in my bundles. |
Hmm. Upon testing, that gave me problems because a) The This is the patch I came up with. matchdav@f5db8ec |
a - yeah, noticed that. i obviously didn't test that :p i don't think we'll take a patch for this, as it can be done with a plugin in just a few lines. |
I want to build some of the modules as standalones, but there doesn't seem to be an easy way to do declare standalone names for each bundle; I would like to be able to declare the standalone names in component.json, like
so that they can be exported to anywhere.
I realize this is probably not a great pattern to encourage, but it does provide more flexibility, I think.
The text was updated successfully, but these errors were encountered: