Skip to content
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

Merging support for multiple config files #8

Open
udondan opened this issue Oct 8, 2014 · 3 comments
Open

Merging support for multiple config files #8

udondan opened this issue Oct 8, 2014 · 3 comments

Comments

@udondan
Copy link

udondan commented Oct 8, 2014

I really like this package and I would love to use it as a dependency in one of my packages. I was testing if multiple config files are supported, and yes, they are, but in a way that is not too helpful.

To give awesome support for other packages it would be great if the multiple configuration files would be merged, so that a 3rd party package could set a required bootstrap component to true while the user is still able to define a custom configuration in her/his application.

So let's say the user installs package A, which ships A.bootstrap.json and requires the formscomponent.

{"modules": {
  "forms":                true
}}

Additionally there is package B which ships B.bootstrap.json and requires the tables component.

{"modules": {
  "tables":                true
}}

The user then has a custom.bootstrap.json in her/his project, which defines the project specific components required. Most likely there will be forms & tables set to true as well.

Currently this would result in duplicate css rules, forms and tables would be included twice. It would be great if there was a mechanism that would resolve duplicates so that each component is only included once. I tried to implement this through an array outside of the handler method which caches which files have already been processed. But I don't quite get how this handler thingy works as I always end up with empty less files. It appears the handler is run multiple times per file so it's already been processed at the 2nd iteration and the file ends up empty...

(Haven't tested yet if your handler actually works in other packages but from my understanding it should)

@udondan
Copy link
Author

udondan commented Oct 10, 2014

OK, so I figured out how to prevent duplicate components. Though it's not working together with other smart packages. Any idea how to make the sourceHandler act on a bootstrap.json file within another package?

I tried to add the file but the resoure handler is not triggered:

Package.onUse(function(api) {
  api.versionsFrom('[email protected]');
  api.use(["less", "templating"], "client");
  api.use(["nemo64:[email protected]_1"], "server"); //that's my fork, PR in #10
  api.addFiles('test.bootstrap.json', "server");
});

Tried it with {isAsset: false} and {isAsset: true}, doesn't matter. Any ideas?

If we can get this working, this package could be THE bootstrap package used by all other packages.

@Nemo64
Copy link
Owner

Nemo64 commented Oct 10, 2014

The source handler should create the final bootstrap files, however you have to add them too because the current solution is kind of a hack. Also, you need to add the package for the client, as it only adds files there. The package has not a single line of code executed during runtime on the server. The source handler is another thing on it's own.

@olivierpascal
Copy link

"If we can get this working, this package could be THE bootstrap package used by all other packages."

I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants