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

Babel not auto-configured when used in an addon #134

Open
buschtoens opened this issue Jul 20, 2017 · 15 comments
Open

Babel not auto-configured when used in an addon #134

buschtoens opened this issue Jul 20, 2017 · 15 comments
Labels
5.x Issues affecting the 5.x series docs help wanted

Comments

@buschtoens
Copy link
Collaborator

I just tried to use ember-decorators in an addon and was happy to see that rwjblue@9328992 removed the setup section from the README, including the setup for usage in addons.

However, I still had to include the init patch in my addon's index.js. Was that piece of the README removed by accident or should this work without manually adding the plugins in index.js?

@rwjblue
Copy link
Contributor

rwjblue commented Jul 20, 2017

It should work properly in addons also, can you whip up a demo repo so we can all try to poke at it.

@buschtoens
Copy link
Collaborator Author

buschtoens commented Jul 20, 2017

Yeppa 🙂

https://github.com/buschtoens/ember-light-table-cell-type-multi-value/tree/ember-decorators-auto-config

Edit: I pushed an ember-decorators-auto-config branch for your convenience. 😉

buschtoens referenced this issue in buschtoens/ember-light-table-cell-type-multi-value Jul 20, 2017
@pzuraq
Copy link
Contributor

pzuraq commented Jul 21, 2017

ok, so it looks like the issue here is that Ember-CLI considers dependencies in an addon to actually be addon dependencies, and devDependencies to be the Dummy app's dependencies. By putting ember-decorators in devDeps, it included the addon for the Dummy app (with the dummy app as the parent) and so it only added the plugins to your Dummy app's transpiled code, not the actual addon code. Including it in dependencies applies it to both.

Not sure if this behavior is documented in Ember-CLI but we should definitely document it in our README.

@kellyselden
Copy link
Contributor

@buschtoens
Copy link
Collaborator Author

Oh gosh. What a rookie mistake. 🤦‍♂️
Thank you, guys!

Adding the -S option should fix it: ember install -S ember-decorators

I don't think that's a problem exclusive to ember-decorators, but I am happy to submit a PR adding a note to the installation instructions regarding add-ons.

@pzuraq
Copy link
Contributor

pzuraq commented Jul 22, 2017

Yeah, that'd be awesome 👌

@allthesignals
Copy link
Contributor

allthesignals commented May 17, 2018

I think I'm having a similar issue. I don't understand the proper way to install this dependency for an addon. Everything I try lands with:

Build Error (Babel)

ember-labs-maps/components/labs-layers-tooltip.js: Unexpected token (10:2)

   8 |
   9 | export default class LabsLayersTooltipComponent extends Component {
> 10 |   @computed('top', 'left', 'offset')
     |   ^

What are the correct steps for installing this in an addon?

@pzuraq
Copy link
Contributor

pzuraq commented May 17, 2018

If you run ember install ember-decorators it should also install @ember-decorators/babel-transforms at the latest version. Can you confirm that the babel transforms addon has been added to your package.json?

@allthesignals
Copy link
Contributor

Thanks, @pzuraq - yes, this is a snippet of my package.json:

  "dependencies": {
    "ember-cli-babel": "^6.6.0",
    "ember-decorators": "2.0.0"
  },
  "devDependencies": {
    "@ember-decorators/babel-transforms": "^2.0.0",
    "babel-eslint": "8.2.3",
    //...

@pzuraq
Copy link
Contributor

pzuraq commented May 17, 2018

ah, if this is an addon you'll have to include it in dependencies. We should definitely document this, and possibly update the blueprint to install it in the correct place.

@pzuraq pzuraq reopened this May 17, 2018
@allthesignals
Copy link
Contributor

allthesignals commented May 17, 2018

Happy to PR something, here's where I successfully landed:

  "dependencies": {
    "ember-cli-babel": "^6.6.0",
    "ember-decorators": "2.0.0",
    "@ember-decorators/babel-transforms": "^2.0.0",
    "babel-eslint": "8.2.3",
    "ember-cli-htmlbars": "^2.0.1",
    "ember-cli-htmlbars-inline-precompile": "^1.0.0"
  },
  "devDependencies": {
   //...

@pzuraq
Copy link
Contributor

pzuraq commented May 17, 2018

I don't think babel-eslint should be necessary since apps that include your addon will not be linting your files (but they will be building them, hence needing the transforms)

@luketheobscure
Copy link

Same problem when developing a lazily-loaded in-repo ember engine. The solution seems to be to make sure @ember-decorators/babel-transforms and ember-decorators are in the dependencies block of the host.

@jalligator
Copy link

wow, I spent my whole afternoon chasing this down. I'm happy to update the documentation if someone wants to point me in the direction of how to do that. This really needs to be documented.

@pzuraq
Copy link
Contributor

pzuraq commented Oct 1, 2018

@jalligator I think a "Usage in Addons" page would be great to add, and perfect for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.x Issues affecting the 5.x series docs help wanted
Projects
None yet
Development

No branches or pull requests

7 participants