Famous / Famous/framework

Support for module loading

Open
#19 5 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
JavaScript
Stars
394
Forks
62
PR merge metrics
No merged PRs in 30d

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.:
1. Create a _pre-build_ entrypoint file, `jon-doe/example/_example.js`
2. Install packages into your component directory
3. Browserify your pre-build entrypoint, with the output file being your _actual_ entrypoint file, `jon-doe/example/example.js`
4. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.