Description
Most developers will expect to be able to do this:
// In jon-doe/example/example.js
var _ = require('lodash');
FamousFramework.scene('jon-doe:example', {
// etc.
});
Although we don't restrict _against_using require etc., we don't currently have automatic support for it through our build process, meaning that the bundles generated by our build process won't actually have the required packages loaded in.
The current workaround
The current workaround is to pre-bundle your entrypoint file before feeding it through the framework's build process. E.g.:
- Create a pre-build entrypoint file,
jon-doe/example/_example.js - Install packages into your component directory
- Browserify your pre-build entrypoint, with the output file being your actual entrypoint file,
jon-doe/example/example.js - Let the framework build tool take over from there
That's annoying though, so...
The eventual solution(s)?
1.) We could include Browserify as part of our build process. Basically, check if the project directory has a package.json, then check for node_modules, npm i if necessary, and then browserify the necessary files before (or after) the main steps of our build. This is similar to what the Famous CLI deploy task does.
2.) More flexibly, we could allow the user to specify their own build hooks. I.e., a user could put this in their package.json:
"scripts": {
"build-famous": "foobar"
}
Our build process would check for a package.json, and if the "build-famous" script is present in the "scripts" object, then we would run that prior to our build process. This seems like perhaps the most flexible approach.
Open to other suggestions here.