broccolijs / broccoli-sample-app

Sample Ember app for Broccoli
MIT License
89 stars 45 forks source link

test, build and src jQuery subfolders causing build errors. #7

Closed maxmechanic closed 9 years ago

maxmechanic commented 10 years ago

With broccoli-cli installed, cloning the broccoli-sample-app repo and running broccoli serve after npm install and bower install throws errors and will not serve the app:

 In appkit/bower_components/jquery/build/release-notes.js:

Line 1: Unexpected token ILLEGAL

Error: Line 1: Unexpected token ILLEGAL
    at throwError (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:2584:21)
    at scanPunctuator (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:1354:9)
    at advance (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:2002:16)
    at peek (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:2028:21)
    at parseProgram (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:5176:9)
    at broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:5661:38
    at parse (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:6038:23)
    at $Parser.parse (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:6810:17)
    at new $Parser.constructor (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:6803:12)
    at $Compiler.parse (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:6588:20)
    at new $Compiler.constructor (broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/es6-module-transpiler/dist/es6-module-transpiler.js:6585:12)
    at addModule (broccoli-sample-app/node_modules/broccoli-es6-concatenator/index.js:80:24)
    at ES6Concatenator.transform (broccoli-sample-app/node_modules/broccoli-es6-concatenator/index.js:53:5)
    at broccoli-sample-app/node_modules/broccoli-es6-concatenator/node_modules/broccoli-transform/index.js:13:19
    at invokeCallback (broccoli-sample-app/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:228:21)
    at publish (broccoli-sample-app/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:176:9)
    at publishFulfillment (broccoli-sample-app/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/promise.js:312:5)
    at flush (broccoli-sample-app/node_modules/broccoli/node_modules/rsvp/dist/commonjs/rsvp/asap.js:41:9)
    at process._tickDomainCallback (node.js:459:13)

It seems to be trying to include those files in addition to the built version of jQuery when doing es6 concatenation/compilation; deleting those folders lets the app build and run as expected.

What is the idiomatic way with Broccoli to exclude these files? Am I missing something else about configuration?

I'm running Node 0.10.26 and Bower 1.2.8 on OS X.

joliss commented 10 years ago

It seems very strange that you ended up with the whole bower_components under the appkit namespace. Something is really going wrong. You are the second person to report this, so I wonder if there's some gotcha to document.

Can you run find . -name bower_components in the broccoli-sample-app directory and tell me whtat it says?

I'd be happy to take a tarball of your broccoli-sample-app directory to investigate myself. Send it to joliss42@gmail.com (you may have to put in on Dropbox because it's quite large).

maxmechanic commented 10 years ago

I inferred from your comment that Broccoli expects the bower_components folder to be in the root directory in not in app/ (where bower install opted to place Bower packages), and when there is a .bowerrc explicitly configuring the folder at root, the build is successful.

Bower seems to say that the default directory is bower_components/, but on multiple machines I've had the experience of Bower defaulting the placement of its install folder inside app/. If this inference/expectation is true, would it be potentially worthwhile to include a .bowerrc file to ensure deps are where Broccoli expects them?

joliss commented 10 years ago

Can you figure out under which circumstances bower puts the bower_components directory in app?

I can't make it happen on my systen, would like to understand what's going on. I'm running Bower 1.2.8 as well, no Bower configuration in ~ or anything.

maxmechanic commented 10 years ago

I don't have a .bowerrc in ~ and I'm not sure why it's still defaulting that way. There's a mention that it might be related to Yeoman (though I think that's potentially a matter of a .bowerrc file being a part of the scaffolding) and another confirmation of /app/bower_components as a default as well as maybe some related unintentional weirdness, but nothing I can find in either the yo or bower repos indicating that.

I tried uninstalling and reinstalling Bower, uninstalling Yo and un/re-installing Bower, and blowing away the .bower cache and un/re-installing. Without a .bowerrc I'm still getting a default install directory inside app/. I'm not sure if there is something else not getting wiped out that might be from an older version of Bower or something that Yeoman did.

Having a .bowerrc file seems to mitigate whatever differences -- however they may be coming up.

joliss commented 10 years ago

I'd really prefer not to merge #8, and just figure out what is going on. Something is clearly broken.

Searching the bower repos for app doesn't yield anything useful either.

maxmechanic commented 10 years ago

I definitely understand hesitation about #8 and debated opening it. My primary advocacy for it at the moment is that if someone does have a .bowerrc at ~ with app/ as the install directory, that the project .bowerrc would prevent these issues. That said, a README caveat would serve a similar purpose without enforcing project folder names/structures or more quietly spackling over a potential issue.

I'm still digging. requireing Bower in the REPL from a local npm install shows a directory property of 'app/bower_components' on bower.config, so I'm guessing it's still from some cached resource that isn't ~.bower/.

joliss commented 10 years ago

Bower has a cache directory in ~/.cache/bower. It doesn't seem like it would make a difference, but on the off chance: Does it help to move it away?

lanceharper commented 10 years ago

Bower has a cache directory in ~/.cache/bower. It doesn't seem like it would make a difference, but on the off chance: Does it help to move it away?

FWIW, I experienced the same symptoms of having a components folder created within app and adding the .bowerrc file via #8 remedied the issue. Per your suggestion, I wiped out the cache directory in ~/.cache/bower, updated bower to 1.2.8 as well with still no luck. I'm happy to revert the .bowerrc and try other approaches.

joliss commented 10 years ago

Can you all get a fresh clone of https://github.com/joliss/broccoli-sample-app, run npm install (bower install shouldn't be needed anymore) and let me know if the issue is still there?

maxmechanic commented 10 years ago

It's still installing to an app/ subdirectory. It feels like there has to be something cached we haven't tried clearing. I might open a Bower issue and/or try to take a better look at the source.

joliss commented 10 years ago

I might open a Bower issue and/or try to take a better look at the source.

Sounds great. I was going to open one myself, but I realized I don't have enough information to provide a useful bug report.

LukeWinikates commented 10 years ago

I've also been getting this, and managed to figure out the cause in my case. I had a rogue .bowerrc, not in ~ but in ~/workspace, where I had checked out broccoli-sample-app.

Broccoli gets the bower config by calling require('bower-config').read().directory in tree.js.

bower-config's read() tries really hard to find a .bowerrc. It recursively walks from the cwd up, until it either finds a .bowerrc or hits / and, finding no /.bowerrc, gives up.

Seems like somewhat surprising behavior from bower-config. OTOH, I also have no idea how the offending .bowerrc got here.

joliss commented 10 years ago

I opened an issue on bower: https://github.com/bower/bower/issues/1189

samselikoff commented 10 years ago

Happened to me as well, could we at least add to the readme?

michaelchiche commented 10 years ago

I have the same problem, and did not understand what is the solution.

hbrysiewicz commented 10 years ago

Some coworkers installed my new project in their local environments and are also experiencing this issue. One was able to move the project directory and avoid it but for some reason this is not a viable solution for the other who is still experiencing the issue.

hbrysiewicz commented 10 years ago

For @michaelch and anyone else still experiencing this the only way I was able to get around was removing the dependency on Bower completely. Sad, but will have to do for now.

maxmechanic commented 9 years ago

Closed by #8.