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: webpack resolve options #785

Merged
merged 3 commits into from Jun 24, 2021
Merged

Conversation

kinetifex
Copy link
Contributor

Motivation

We have some packages that export both ESM and CommonJS modules using conditional package exports using the import and require conditions, such as in this example. These work fine in our Webpack 5 apps, however if we try to use these imports in Linaria blocks with the Linaria Webpack loader, it blows up with the error:

Package path ./sizes is not exported from package

Summary

What's missing is that the Linaria webpack loaders do not pass down the appropriate conditionNames to the enhanced resolver. This PR adds the require condition name by default, and also introduces the ability to customing the loader resolveOptions.

Test plan

@rmazzeo-godaddy put together this repo that reproduces the problem.

git clone git@github.com:rmazzeo-godaddy/linaria-conditionnames-missing.git
cd linaria-conditionnames-missing
npm ci
npm run start

@callstack-bot
Copy link

callstack-bot commented Jun 22, 2021

Hey @kinetifex, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@kinetifex kinetifex changed the title Webpack resolve options fix: webpack resolve options Jun 23, 2021
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

3 participants