You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing an external library (private npm package) i get inconsistencies between running dev and build.
When running dev imports work as expected, meaning I'm able to import both the default and named exports successfully. However, when running build I get the notorious:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Example
importModulefrom'@external/component';
In dev, importing Module gives me the expected React.FC:
Where NamedModule works in both commands, but Module works only in dev.
Fixes
Based on #4692 I was able to noExternal the external libraries, which means that default imports work as expected.
I also tried adding logic in the code to set Module to Module.default after importing it as suggested here (#3174 (comment)).
Suggestion
Even if I was able to solve the issue as described in "Fixes", it seems weird that dev and build behave fundamentally differently for default imports. My suggestion is to align the configurations between these commands. If that's not possible, this should at least be documented in depth outside of the closed issues in the repo.
Link to Minimal Reproducible Example
Participation
I am willing to submit a pull request for this issue.
The text was updated successfully, but these errors were encountered:
What version of
astro
are you using?1.6.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
When importing an external library (private npm package) i get inconsistencies between running
dev
andbuild
.When running
dev
imports work as expected, meaning I'm able to import both the default and named exports successfully. However, when runningbuild
I get the notorious:Example
In
dev
, importing Module gives me the expected React.FC:In
build
Module evaluates to:Note that any named imports from the same package works both in
dev
andbuild
:Where NamedModule works in both commands, but Module works only in
dev
.Fixes
Based on #4692 I was able to
noExternal
the external libraries, which means that default imports work as expected.I also tried adding logic in the code to set Module to Module.default after importing it as suggested here (#3174 (comment)).
Suggestion
Even if I was able to solve the issue as described in "Fixes", it seems weird that
dev
andbuild
behave fundamentally differently for default imports. My suggestion is to align the configurations between these commands. If that's not possible, this should at least be documented in depth outside of the closed issues in the repo.Link to Minimal Reproducible Example
Participation
The text was updated successfully, but these errors were encountered: