Comments (17)
Hey @substack
This is something we are currently discussing in house about the best way to approach. We want to support a variety of forms of module loading. With the current way we are using require it is actually fairly trivial to convert to common, and we are investigating the best ways to automate this process (something like browserify-ftw looks like overkill though).
from famous.
👍
from famous.
@substack Do you have any ideas of how a CommonJS port could be used through npm where:
- Only the Famo.us modules in use are loaded
- You don't end up with relative
require
calls intonode_modules
(e.g.,require('../node_modules/famous/core/Surface')
?
As far as I'm aware it's not doable. But it would be great if the require calls could be the same as what is currently used for RequireJS (e.g., require('famous/core/Surface')
).
Until a better solution is found, I'm maintaining a CommonJS port and using it through Bower. As @thealphanerd said, it was pretty trivial to convert. My require
calls look like: require('../lib/famous-commonjs/core/Surface')
.
from famous.
I'd love this, too. I really, really don't want to drag bower into my project just for this.
At Spotify, we use npm+browserify for everything and it's amazingly good. I had to do quite a bit of welding to get it into a browserify project. If releasing to npm was part of your release process, this would be solved once instead of us all inventing different solutions to get it to work.
Right now, here is how I hack around it, for anyone interested:
install_famous.sh
#!/bin/bash
# Temporary hack until Famo.us comes to their senses
# and publishes on npm.
rm -rf amd-modules/famous
git clone https://[email protected]/Famous/famous.git amd-modules/famous
cd amd-modules/famous
git fetch --tags
git checkout 0.1.2
Added to package.json
"browserify": {
"transform": [
"deamdify"
]
},
"devDependencies": {
"deamdify": "~0.1.1"
},
"scripts": {
"test": "mocha",
"postinstall": "./install_famous.sh ; gulp"
},
In code
var Surface = require('../amd-modules/famous/core/Surface')
from famous.
Try webpack + bower. Webpack works out of the box with AMD and Commonjs, just have to add the bower-components to your webpack.config. Webpack also builds my project an order of magnitude faster than browserify. Here is an example webpack.config similar to the one I use:
module.exports = {
context: __dirname + "/src",
entry: {
main: "./main",
},
output: {
path: __dirname + "/dist",
filename: "[name].js",
},
resolve: {
root: __dirname + "/src",
modulesDirectories: ["bower_components", "web_modules", "node_modules"]
},
devtool: "inline-source-map"
}
This allows you to use var Surface = require('famous/core/Surface')
in your CommonJS or AMD code (after installing famous as a bower dependency).
from famous.
Nice speigg. Thanks.
from famous.
@aelr You never ever do this: require('../node_modules/famous/core/Surface')
I'm not sure where you're getting that from? You just do require('famous/core/Surface')
which traverses up the parent directories looking for matching subdirectories inside of node_modules. https://github.com/substack/browserify-handbook#how-node_modules-works
from famous.
@substack Amazing. I'd not yet seen a module that utilizes that functionality, so didn't know it worked that way. So then, a CommonJS port of Famo.us makes much more sense than I thought and could be used via NPM or Component in the same way as the Require.JS implementation.
from famous.
@aelr or just use webpack :)
from famous.
Of all of those tools (webpack, browserify, commonjs-everywhere), I could only get browserify to work on Windows with watching. It's what I'm using now.
from famous.
I have something cooking up right now… a proper and working common port may be very very close :D
On May 30, 2014, at 6:30 AM, aelr [email protected] wrote:
Of all of those tools (webpack, browserify, commonjs-everywhere), I could only get browserify to work on Windows with watching. It's what I'm using now.
—
Reply to this email directly or view it on GitHub.
from famous.
For now, you could add this to your package.json
file:
"famous": "git://github.com/aelr/famous-commonjs.git"
from famous.
@thealphanerd that will come in handy 👍
from famous.
Fwiw you do not need to change any of the references to relative paths, this is tested and verified.
On May 30, 2014, at 9:07 AM, Tony Alves [email protected] wrote:
@thealphanerd that will come in handy
—
Reply to this email directly or view it on GitHub.
from famous.
I believe this is currently fixed. https://www.npmjs.org/package/famous
Myles is my hero.
from famous.
hear hear.
from famous.
npm install famous
now works as expected
Hooray!!!
from famous.
Related Issues (20)
- Very bad performance for ScrollView on Android/Cordova HOT 9
- whats happening? HOT 9
- ScrollView breaks when surface content is modified by a third party like Angular. HOT 1
- Using ViewSequence.splice can mess up the internal linked-list HOT 1
- When will "mixed mode" be released? HOT 1
- Utility.clone issue HOT 1
- CORS issue w/ Picasa and slideshow demo HOT 1
- Stress test - Bad performance in Firefox only HOT 1
- FlexibleLayout subview not hidden when its ratio is 0 HOT 1
- Howto build famous without fastclick? HOT 3
- Scroll HOT 2
- Animation Smoothness issue in mobile devices. HOT 1
- mixed mode - native overflow scrolling with famous (+flex view) HOT 4
- Blank homepage of university HOT 1
- Where can we find the docs to the old 0.3.5 version HOT 1
- Weird issues with absolute positioning, movement, and changeContent on iOS HOT 1
- GridView HOT 1
- dev console and CTRL+C HOT 2
- Scrolling problem when height of blocks is less than container height (stuck at the bottom) HOT 2
- What if all the famo.us objects are native ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from famous.