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

wrong version of dependency imported with duplicate dependencies using preact-cli #1616

Closed
sjmarshy opened this issue Nov 16, 2021 · 4 comments · Fixed by #1622
Closed

wrong version of dependency imported with duplicate dependencies using preact-cli #1616

sjmarshy opened this issue Nov 16, 2021 · 4 comments · Fixed by #1622

Comments

@sjmarshy
Copy link

My preact app uses fp-ts@2. The app has a dependency on arya which has a dependency on fp-ts@1.19

When I build or watch using preact-cli then my arya library gets built against fp-ts@2. This causes errors because the interfaces are different.

It's possible that this is a webpack configuration issue, as I have found a similar issue here: webpack/webpack#6538

It's not clear to me how to apply the solution provided in that issue in context of preact-cli, so any help/advice would be appreciated.

Thanks.

@rschristian
Copy link
Member

Can you provide a reproduction? arya doesn't seem to have any dependencies so I'd need some more info to try to test a solution against.

sjmarshy added a commit to sjmarshy/preact-cli-repro that referenced this issue Nov 23, 2021
@sjmarshy
Copy link
Author

Sorry, was just on holiday for a few days so didn't see this response! The arya I was referring to is a private package, so that's my fault. I've created a reproduction in a repo here: https://github.com/sjmarshy/preact-cli-repro

Thanks!

@rschristian
Copy link
Member

No worries, thanks for providing that.

Seems to be an issue with how we resolve dependencies at the moment, nothing for you to solve in user config I believe. Will try to get a fix together.

@rschristian
Copy link
Member

rschristian commented Nov 24, 2021

Okay so this is a tad hacky, but will unblock you for the time and won't create issues if/when we do get this fixed.

// preact.config.js

export default (config, env, helpers) => {
    const modules = config.resolve.modules;
    if (modules[2] === 'node_modules') {
        modules.splice(2, 1);
        modules.unshift('node_modules')
    }
}

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 a pull request may close this issue.

2 participants