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

Provide global namespace version (no require.js) #27

Closed
mizchi opened this issue Apr 15, 2014 · 11 comments
Closed

Provide global namespace version (no require.js) #27

mizchi opened this issue Apr 15, 2014 · 11 comments

Comments

@mizchi
Copy link

mizchi commented Apr 15, 2014

I want to integrate famo.us to my apps but my environment hevily depends on common.js(browserify). So it's difficult to use by conflicting require function. Maybe I can do with some hacks, but not comfortable at least.

I need all concated files or custom building kitchean if files are huge like jquery.
For example,

var Engine = require('famous/core/Engine');

will be

var Engine = famous.core.Engine;

It's no problems to use.
I'm not going to deny require.js but now difficult to say it is de facto standard. (of cource current way will be left anyway)

I tried r.js to concat files but it can't resolve require.js dependencies.(Sorry, I'm not well at require.js ecosystems)

https://gist.github.com/anonymous/10731828

@jpcamara
Copy link

Have you tried using https://github.com/jaredhanson/deamdify?

@mizchi mizchi closed this as completed Apr 15, 2014
@mizchi mizchi reopened this Apr 15, 2014
@mizchi
Copy link
Author

mizchi commented Apr 15, 2014

Oops, closing and reopen are my faults.

I tried deamdify now. Thanks to @jpcamara .
I need to rename to famous/ to ../ for example require('famous/core/Engine') to require('../core/Engine')

dirs

famous/
main.js

And exec browserify -t deamdify main.js -o bundle.js makes bundle.js. yeah!

main.js is here.

var Engine = require('./famous/core/Engine');

It works but need many procedures. (and need to merge manually after that)
I tried aliasify but looks not active to AMD.

Anyway, if this way are refined, common.js users can use famo.us easily but only common.js users. Almost develpper can't choose their own building system under constructuring.

My point of view is current using way is only for requirejs. I think providing all included file are easy to use if famous can.

@jodyheavener
Copy link

I'd also be interested in seeing a version that doesn't use require.js.

@MylesBorins
Copy link
Contributor

For what it is worth you can change the name space in the requirejs config
which is bundled with the yo scaffolded base project. You could also
consider looking at the project browserify-ftw which is used to convert
require to common.

I personally have not played with either but I know @andredeandarade has.
On Apr 15, 2014 9:54 AM, "jodyheavener" notifications@github.com wrote:

I'd also be interested in seeing support for not needing require.js.


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-40506067
.

@jdiaz5513
Copy link

browserify-ftw worked wonders for me; you only need a minimal config to get it working.

Make sure there's nothing else in your working directory besides the famous folder before you do this, or browserify-ftw might mess with them too! Create these three files in the directory containing the main famous folder:

require.js
require.config({ paths: {} });
entry.js
define([],function(){});
config.js
module.exports = { indent: 0, dryrun: false };

Then run browserify-ftw -r require.js -c config.js -e entry.js.

It'll transform all the files in place (and create a few extra files outside of the famous folder). You can delete all the extra files when you're done.

While this works, it sure as hell is clunky so I might start working on forking a brunch skeleton for Famous that uses the CommonJS format.

@andrewdeandrade
Copy link
Contributor

@jdiaz5513 Let me know how browserify-ftw could be modified (beyond your instructions above) to get it working out of the box with no modifications. If it is reasonable, I can submit another pull request to browserify-ftw since I'm already familiar with that repo (since I made most of the changes that allow it to work nicely with famous code). I'm particularly interested in knowing the reason why those changes you made were necessary. i.e. what side effects did you observe without them that were undesirable? (FWIW I used browserify-ftw as a library and not as a CLI tool, so I'm not familiar with its CLI behavior).

To make things easier for others and to make this repeatable in other repos, add the following script to ~/bin and chmod +x it.

#!/bin/sh
set -eu
command -v browserify-ftw >/dev/null 2>&1 || { npm install -f browserify-ftw; }
DIR=`pwd`
REQUIRE=$DIR/require.js; ENTRY=$DIR/entry.js; CONFIG=$DIR/config.js
FILES=( $REQUIRE $ENTRY $CONFIG )
for i in "${FILES[@]}"
do
  [ -f $i ] && { echo "${i} already exists. aborting"; exit 1; }
done
echo "require.config({ paths: {} });" > $REQUIRE
echo "define([],function(){});" > $ENTRY
echo "module.exports = { indent: 0, dryrun: false };" > $CONFIG
browserify-ftw -r $REQUIRE -c $CONFIG -e $ENTRY
rm $REQUIRE $ENTRY $CONFIG

@jdiaz5513
Copy link

The indent behavior for me was odd.

I was expecting {indent: 2} to refactor all the code to an indent spacing of two, but instead what it (appears) to do is leave the require statements at indent level 0, and then everything below it got an indent of 2. I don't really see how that is useful at all?

The browserify-ftw command-line would be super useful if it had an option to just target a specific folder in "library mode", with the above config implied. No main entrypoint, do not generate browserify bundle build files, and add a flag to disable dryrun so you don't need a refactor config file either.

It should be as simple as this: browserify-ftw --library --folder famous/ --dryrun false

I'll have to look into using browserify-ftw as a library, maybe that'll be illuminating (I was assuming it was just a CLI tool).

@aelr
Copy link

aelr commented Apr 16, 2014

@mizchi @jdiaz5513 I put together a port of Famo.us to CommonJS here: https://github.com/aelr/famous-commonjs

@mizchi
Copy link
Author

mizchi commented Apr 17, 2014

@aelr Great! And I created global namespace version by use your modules.
https://github.com/mizchi/famous-bundled

What I want is this repository's famous.min.js. It is fork so I can't maintaine.

@qrg
Copy link

qrg commented Apr 17, 2014

👍

@MylesBorins
Copy link
Contributor

I'm closing this for right now. Please feel free to reopen if you do not feel like you found the necessary answers in here

@ghost ghost mentioned this issue May 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants