-
Notifications
You must be signed in to change notification settings - Fork 24
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
WebExtensions load/require other modules #438
Comments
Can you please post code and the exact error message? |
Sure. I wonder, why it is trying to load the module inside the adapter folder?! And the code is something like: Later on: |
For me it sounds like that mime v4 is an ESM only solution... this means that "require" is not allowed at all. ESM packages need to be "import"ed. So try downgrading mime to v3 which should be cjs and so require is allowed. Additonally the interesting fact is that you do not import mime but mime-types? Or is there an other version that uses mime which is not github master? ... but mime-types is not in your package json?! This is also an issue! You need to include each package that you need into the package.json as dependency |
So, that means, i need to have [email protected] Version? Well, i found out, that mime-types is already a dependency of web-adapter. Therefore, i thought i dont need it because my adapter is not running without web installed. Am i correct? In the meantime, i threw out mime and using mime-type instead. |
Always add your dependencies you need! As you see when the extension is loaded from your adapter dir also the package dependenca look up is done from your directory. the logic works always from the file it interprets. Any yes I would try mime @3 or adjust your script to be ESM (but better not start that) |
Okay, if i understand you correctly, i need to include every package into package.json (via npm i on localmachine) and can use them everywhere - except its ESM only. But, "normal" things like "fs" or "path" are not needed, correct? |
correct |
Great. Thanks for confirming! Would you mind, to shortly check web.js and package.json in my repro again? |
Hi,
i am using WebExtensions in my adapter and wanted to require the module "mime".
It is also installed via package.json and further used (trying to) inside web.js.
The Web-Adapter raises an error, regarding a dynamic module should be used.
How to perform this, please?
The text was updated successfully, but these errors were encountered: