IjzerenHein / famous-flex

Animatable layouts, FlexScrollView & widgets for famo.us.
MIT License
279 stars 44 forks source link

Browserify unnecessary shim? #71

Closed motiazu closed 9 years ago

motiazu commented 9 years ago

Hi, I started working with Browserify in order to load my modules, and the famous-flex package keeps failing.

The line that fails is in LayoutController (because this is the first component my code requests via require(...)). The following line is generated:

var Utility = typeof window !== 'undefined' ? window.famous.utilities.Utility : typeof global !== 'undefined' ? global.famous.utilities.Utility : null;

window.famous is undefined, thus an error occurs.

After going nuts over this weird thing, I eventually removed the shim process from the transform in famous-flex package.json. I re-browserified and the line became:

var Utility = require('famous/utilities/Utility');

After that, everything worked great. I'd hate to leave modified code of a dependency in my app, and there's a good chance I misconfigured browserify somehow... This is my package.json:

{
  "browserify": {
    "transform": [
      "deamdify"
    ]
  },
  "dependencies": {
    "famous": "^0.3.5",
    "famous-flex": "0.1.9"
  }
}

Any idea why the shim ruins the build?

IjzerenHein commented 9 years ago

Are you using the latest version from master?

motiazu commented 9 years ago

I'm using "0.1.9", Looks like the current version to me here. https://github.com/IjzerenHein/famous-flex/blob/master/package.json

IjzerenHein commented 9 years ago

Yes, I was just wondering whether you are using the latest version from bower/npm or from the master branch.

motiazu commented 9 years ago

Oh, well npm it is. Aren't these in sync?

IjzerenHein commented 9 years ago

No, the master is ahead of the npm/bower version. Various commits have been made to the master concerning the global-famous-flex.js file. I want people to field test these first prior to releasing them as a package on npm/bower. Could you use the current dist/global-famous-flex.js file from the master and see whether that one works for you?

motiazu commented 9 years ago

Tried the master, still get the same problem. Also solved by removing the shim transformation.

IjzerenHein commented 9 years ago

And what about this version released by Sidney in this pull request? https://github.com/IjzerenHein/famous-flex/pull/70

motiazu commented 9 years ago

Same bug, same solution. I'm suspecting maybe when the shim was added it was needed, but famo.us had changed since then and maybe it's not needed anymore.

IjzerenHein commented 9 years ago

Could it be because they removed the 'src' folder in 0.3.5?

motiazu commented 9 years ago

Very possible, this also made famousify redundant.

IjzerenHein commented 9 years ago

Hi, I just released a new version and updated the NPM package v0.2.0. Do you still have issues with the new version?

motiazu commented 9 years ago

Seems to work yo :+1:

IjzerenHein commented 9 years ago

Excellent!! :+1:

motiazu commented 9 years ago

Whoops... still happens. I guess my original check wasn't good, but now only removing the shim resolves the issue like before.

IjzerenHein commented 9 years ago

@motiazu Do you mean just removing the shim from the package.json? Could you post the changes that you needed to make to get it working?

motiazu commented 9 years ago

Before: "browserify": { "transform": [ "browserify-shim", "deamdify" ] }, After: "browserify": { "transform": [ "deamdify" ] },

IjzerenHein commented 9 years ago

Hi, I've just released a new version of famous-flex (v0.3.2). It contains all new generated /dist files to meet different kind of integration scenarios. I've also created a test project, which showcases how to integrate famous-flex using different technologies (requirejs, global, wepback, browserify: https://github.com/IjzerenHein/famous-lib-tester