kimroen / ember-cli-coffeescript

Adds precompilation of CoffeeScript files and all the basic generation types to the ember generate command.
MIT License
72 stars 49 forks source link

Conflict with another 3rd party package that includes an app/adapters/application.js #87

Closed hoIIer closed 7 years ago

hoIIer commented 9 years ago

Hello,

We've run into an issue when using this package with another called ember-django-adapter, I created an issue there but linking it here in case it can be solved on this side or it?

https://github.com/dustinfarris/ember-django-adapter/issues/121

Essentially that package is including an app/adapters/application.js which breaks ember server bc it's seeing a .js file when we have coffeescript enabled. Not sure what's best solution to fix?

Any info appreciated, thanks!

kimroen commented 9 years ago

Unfortunately I don't have the time to check this out further at the moment, but here's a description of the problem:

When an addon includes a file in its app folder, it will be placed in the user's app structure, unless a file already exists at the same path. In this case, because your application adapter is called application.coffee and not application.js, they will both be included. Then, when the CoffeeScript-compiler we're using (broccoli-coffeescript) tries to compile application.coffee to application.js, it will blow up because that file already exists.

Some potential solutions to look in to:

Your best bet at an immediate solution to your particular case would be to use javascript instead of coffeescript for this particular file, though.

kimroen commented 9 years ago

I've talked to the ember-cli people, and they agree that ideally all the transpilation should happen before the merge, but unfortunately that is a pretty big change.

hoIIer commented 9 years ago

@kimroen thanks for the information and looking into this.. yeah I just went ahead and used javascript for this file since it wasn't much of a deal to do that...

toovy commented 8 years ago

I'm also having this issue with ember-simple-auth, the transpiled route/application.coffee file is not merged with the addons routes/application.js file. Just for my understanding, is it a big change on ember-cli or on ember-cli-coffeescript?

I think this fix would be important as addon developers are just discovering the possibilities of addons. The possibility to merge addon and application files seems to be powerful. But the conflict would affect all files with the same name, not only the application route, right?

bkCDL commented 8 years ago

I'm having the same issue as @toovy . See also this thread

kimroen commented 8 years ago

@toovy I agree that it is important to fix this, and I've tried to outline what is happening earlier in this thread, but there is a clear correct solution, and there is a temporary solution:

Proper solution

ember-cli should run all the addons that do processing of files before it merges the files in. This way, the application.js would already exist, and no addons would merge their files in to cause conflicts with the output of Coffeescript.

Temp solution

We could make the Coffeescript converter ignore conflicts and overwrite files that already exist. This way the application.js would be merged in from the addon, and then overwritten by your own file when converting. This could cause other problems I can't think of right now though.


I discussed this some with ember-cli people in the community Slack, and as far as I can gather, the proper solution is a pretty big change, unfortunately. The way forward on that is for someone to look in to what exactly is needed in ember-cli, and create an issue there describing what is needed, and then after some discussion to make the change in a PR.

This is not a problem that is unique to ember-cli-coffeescript, it would also affect any addons that provide other things like templating languages or css. Unfortunately I don't have the extra capacity to look in to this problem at the moment, so I would be really grateful if someone found the time to do so. Hopefully we can make this work!


@bkCDL Thanks for the link! This change in ember-simple-auth has surfaced this error for quite a few people, me included.