-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Proposal] Ability to run code on load before doing _anything_ else (re: Add user configurable language support) #3142
Conversation
Super late response from me here @internalfx, apologies. I think this is a great solution, and the way it is set up is extensible for any future use cases that have specific needs -- e.g. in the future we could, if necessary, allow an asynchronous function to be provided in lieu of the The only tweak I'd suggest is that, instead of Other than that, I think your solution proposed here is great for Sails going forward, and I'd like to try and get it in the 0.12 release if possible. If you wouldn't mind sending a PR to the 0.12 branch of sails-docs that adds For the reference docs, please make sure to:
It would be great to have a deeper explanation of coffeescript usage in Sails in our conceptual docs as well, but that is not critical (and it takes more work) so that's definitely not a blocker for getting this merged in asap. Thanks a lot!
|
@mikermcneil That's a great idea.... What if we just quit messing around and created a And users can do whatever they want in it. I didn't even think of that initially. |
heh....maybe |
This has some elegant simplicity to it.... You want to run I like your idea better than mine.... |
:)
I think that would work nicely-- i.e. an optional JavaScript file that exports a function that Sails core will look for in the current repo (if it can't require it, no bigs, if it's the wrong type, we throw an error explaining what it's supposed to look like). I would suggest On the other hand, for consistency with |
So I think there are two parts to this that may or may not actually need to be the same feature: 1. Add the ability to run an asynchronous function before sails begins loading without having to hack your
|
I'm thinking we should dump this PR, and just add the mentioned And it solves a whole bunch of problems for users. |
@internalfx agreed-- and it would solve https://github.com/balderdashy/sails/blob/master/lib/hooks/moduleloader/index.js#L145 (although on a separate note, I do like the auto-detection.... and I get why it's sync right now-- just need to figure out a way to make it faster / backgrounded, and also to pull it out of core. E.g. hooks can already register their own route target syntax: since the moduleloader exposes acceptable file extensions as a config, it seems like it wouldn't be too hard to allow a hook to get in the middle and provide support for loading a specific file extension. --- OR better yet, we just make the equivalent of |
I think Something else to throw into the mix is the idea of having |
Would recommend updating bootstrap.js docs to avoid confusion: Currently says 'before sail lifts' and this is called But, this sounds to me like the main purpose of beforeLoad would be to update configs, much like the In general though, sounds like something that could be useful. 👍 |
@Salakar thanks, great point re docs!
Hmm, I see what you mean. This is slightly different in that it runs even before any hooks are loaded, and can even affect what languages are understood when requiring files from the config folder. Here's what I'm thinking we should do for Sails v1:
|
…so adds TODOs re a deprecation warning for '.attributes.json' files, for switching to consistently using 'sails.config.paths.config', and for pulling out all built-in support for the 'configKey' hook property (and related documentation- see http://sailsjs.org/documentation/concepts/extending-sails/hooks/using-hooks#?changing-the-way-sails-loads-an-installable-hook).
@tjwebb @sgress454 @loicsaintroch @mikermcneil
This PR keeps the current functionality the same for existing users, but allows them to override the default supported languages in
moduleloader
the
.sailsrc
can now have alanguages
key added that will replace the default supported languages array.This brings us at least closer to what we wanted all along, It still does not allow the use of
hooks
, but its already been discussed why we need a whole rewrite to fix that.This is a good stop gap I think.
Thoughts?