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

Allow shared nested addons to be properly discovered. #3335

Merged
merged 1 commit into from
Feb 23, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Feb 22, 2015

Prior to these changes we always assumed that an addon was at the current package's (could be either the project or another addon) node_modules/<addon-name> path. This is true in many cases, but not all. Specifically, with more recent versions of NPM a package that is shared by a nested child package and an ancestor package will be deduped and used from that parent directory.

Simple example:

  • Package A
    • Depends on Package B
    • Depends on Package C
  • Package C depends on Package B

The folder structure in this case for more recent versions of NPM (2.0.0+) would be:

package-a/node_modules/package-b/*
package-a/node_modules/package-c/*

But our prior logic expected:

package-a/node_modules/package-b/*
package-a/node_modules/package-c/*
package-a/node_modules/package-c/node_modules/package-b/*

This PR ensures that we use the resolve package (which follows the documented node resolution strategy) to determine the path to a given addon.

Please note that this PR also removes the ability to have an addon without any node-land JS (previously it was possible to have only a package.json and vendor/ folder for example). I am not aware of this being relied upon, but it is documented as a breaking change in the changelog for 0.2.0.

Closes #3240.

@rwjblue
Copy link
Member Author

rwjblue commented Feb 22, 2015

/cc @lukemelia could you review? (since you championed the initial AddonDiscovery extraction)

};
```

This should *not* pose a problem for the vast majority of addon's.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the apostrophe

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, updated.

@lukemelia
Copy link
Contributor

Looks good to me. Thanks @rwjblue!

@rwjblue rwjblue force-pushed the nested-addon-discovery branch 2 times, most recently from ac2f6c7 to f5fb943 Compare February 22, 2015 05:51
@rwjblue
Copy link
Member Author

rwjblue commented Feb 22, 2015

There are some acceptance test failures that I am working through...

@rwjblue rwjblue mentioned this pull request Feb 22, 2015
Prior to these changes we always assumed that an addon was at the
current package's (could be either the project or another addon)
`node_modules/<addon-name>` path. This is true in many cases, but not
all. Specifically, with more recent versions of NPM a package that is
shared by a nested child package and an ancestor package will be deduped
and used from that parent directory.

Simple example:

* Package A
  * Depends on Package B
  * Depends on Package C
* Package C depends on Package B

The folder structure in this case for more recent versions of NPM
(2.0.0+) would be:

```
package-a/node_modules/package-b/*
package-a/node_modules/package-c/*
```

But our prior logic expected:

```
package-a/node_modules/package-b/*
package-a/node_modules/package-c/*
package-a/node_modules/package-c/node_modules/package-b/*
```

---

This PR ensures that we use the `resolve` package (which follows the
[documented node resolution
strategy](http://nodejs.org/api/modules.html#modules_all_together)) to
determine the path to a given addon.

**Please note** that this PR also removes the ability to have an addon
without any node-land JS (previously it was possible to have only a
`package.json` and `vendor/` folder for example).  I am not aware of
this being relied upon, but it is documented as a breaking change in the
changelog for 0.2.0.
@rwjblue
Copy link
Member Author

rwjblue commented Feb 22, 2015

Just confirmed that this fixes the demo repo (https://github.com/alvincrespo/test-new-app) provided by @alvincrespo in #3240.

rwjblue added a commit that referenced this pull request Feb 23, 2015
Allow shared nested addons to be properly discovered.
@rwjblue rwjblue merged commit ef74d22 into ember-cli:master Feb 23, 2015
@rwjblue rwjblue deleted the nested-addon-discovery branch February 23, 2015 00:45
@slindberg
Copy link

🍻

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

Successfully merging this pull request may close these issues.

Addon Discovery: Shared Nested Addons Cannot be Found
4 participants