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

@ember/test-helpers v4 suggests itself to be in dependencies even when only used for test-support files #1490

Closed
elwayman02 opened this issue Aug 26, 2024 · 4 comments

Comments

@elwayman02
Copy link
Contributor

elwayman02 commented Aug 26, 2024

As of the v4 release, this package now throws an error if used in the addon-test-support/ directory as a devDependency:

Build Error (WebpackBundler)

ember-scroll-modifiers tried to import "@ember/test-helpers" in "ember-scroll-modifiers/test-support/did-intersect-mock.js" from addon code, but "@ember/test-helpers" is a devDependency. You may need to move it into dependencies.

The correct pattern here is to add @ember/test-helpers to peerDependencies for the package that utilizes it in addon-test-support/, because we do not want to cause @ember/test-helpers to be included in production bundles for consuming applications, but we do want to ensure that @ember/test-helpers is properly installed as a devDependency for any consumers of the package providing the test-support util, since the util imports @ember/test-helpers and will fail if the consumer doesn't have it installed.

The error message itself is incorrect: addon-test-support is, by definition, not "addon code", but rather code for supporting tests only. This will confuse developers who will try to move it to dependencies and erroneously add it to production builds for their consumers. The error message should be updated to be more correct and suggest adding it to peerDependencies, since we know where it's being used is not actually addon code but is(maybe) going to be used by consumers.

@elwayman02 elwayman02 changed the title @ember/test-helpers v4 requires itself to be in dependencies even when only used for test-support files @ember/test-helpers v4 suggests itself to be in dependencies even when only used for test-support files Aug 26, 2024
@NullVoxPopuli
Copy link
Collaborator

Looks like you solved it? https://github.com/elwayman02/ember-scroll-modifiers/pull/1106/files

in a v1 addon you need both peer and devDep

@elwayman02
Copy link
Contributor Author

@NullVoxPopuli I updated the issue a bit ago to be more clear what the problem is - peerDep is working but the error message does not correctly suggest that as a solution, even though it has enough information to do so.

@NullVoxPopuli
Copy link
Collaborator

gotchya -- for an issue with the error message, I think you'd want to open an issue on auto-import or embroider

@NullVoxPopuli
Copy link
Collaborator

Just had some successful upgrades here:

I'm going to close issue, because it seems like the issue you're encountering is elsewhere. Please let me know if you want help debugging or anything.

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

No branches or pull requests

4 participants
@NullVoxPopuli @elwayman02 and others