-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Bug]: Loading plugin causes error "The requested module does not provide an export named "default" #11248
Comments
Somewhere inside your modules , there is some npm module that does is probably some older version or probably because of how its getting transpiled and how ES6 is loaded or handled There is an issue storybookjs/builder-vite#37 Adding @emotion/react to optimizeDeps solves the issue |
thanks @saranshisatgit - I saw this |
Hi @radoslaw-sz, you can add dependencies to
But thats obviously not ideal if needed in order for users to be able to use your plugin. The issue stems from conflicts that occur because the medusa app is a CJS project, but the dashboard is ESM. We are investigating how/if we can improve how we configure Vite to prevent these kinds of issues until we are ready to migrate Medusa to a ESM project. And I'll report back once we have some more info or a fix. |
hi @kasperkristensen - thank you very much for your response. Indeed, adding configuration to |
@kasperkristensen any updates on this or potential remedies? I’ve got a scenario where importing Dayjs into a widget causes react-is to not export properly. Not entirely certain what the connection is but commenting out the code allows the admin dashboard to render properly again. I’m assuming this has something to do with cjs and esm. |
@kasperkristensen any updates on this? |
Hi @MounsifChr, yes I was able to find a fix for this, the PR is here #11789 feel free to test it out with the snapshots. Currently, we are planning to release it next week. |
Package.json file
Node.js version
v21.7.2
Database and its version
PostgreSQL 16.2
Operating system name and version
Ubuntu 22.04.3 LTS
Browser name
Chrome
What happended?
It might be related to #11229.
We published our plugin to NPM here - https://www.npmjs.com/package/@rsc-labs/medusa-store-analytics-v2.
However, when trying to use as a plugin, we see the error, which blocks application (only blank screen is visible).
The issue is related to one of the package used by the plugin -
@emotion/react
which is needed to use@mui/material
- the most popular React UI framework.When working locally with the Medusa app (as a module) everything works perfectly - Medusa Store Analytics is loaded as module and visible in Admin.
However, when it has been published to NPM, loading it as a plugin gives such error:
It looks like it is related to how Medusa app is bundled (using ES modules) and for some reason, for the plugins is it is being built differently.
I would love to get some feedback from the Medusa Core Team as it can be some kind of low level issue and some special difference how plugins are being loaded to app.
Expected behavior
Plugin shall be loaded and working. It works when copy the code, but it is not working when loading as a plugin.
Actual behavior
Plugin is not being loaded by the app and only blank screen is visible.
Link to reproduction repo
N/A - clean Medusa repository and @rsc-labs/medusa-store-analytics-v2 loaded as plugin
The text was updated successfully, but these errors were encountered: