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

Fix addons not working when resolved with getAbsolutePath #66

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

JReinhold
Copy link
Collaborator

@JReinhold JReinhold commented Feb 28, 2024

Follow-up to #63

In certain monorepo and/or Yarn PnP situations, users will resolve their addon packages with an absolute path instead of the package name, eg.:

// .storybook/main.js
import { join, dirname } from "path";

function getAbsolutePath(value) {
  return dirname(require.resolve(join(value, "package.json")));
}

const config = {
  ...,
  addons: [
    getAbsolutePath("storybook-addon-kit-test-module"),
  ],
  ...
}

In that situation, Node.js will ignore the package's export maps when resolving it and thus none of the entries will be found. To get around that we have to have preset.js, manager.js and/or preview.js files in the root package because they will be used instead.

This has always been the case, we just missed this scenario in #63 and removed the files by mistake.

@JReinhold JReinhold marked this pull request as ready for review February 28, 2024 11:16
@JReinhold JReinhold merged commit 971e1bb into main Feb 28, 2024
2 of 3 checks passed
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.

None yet

2 participants