-
Notifications
You must be signed in to change notification settings - Fork 128
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
Transpile nuxt2 module #54
Comments
Perhaps try adding |
@danielroe Doesn't seem to work
|
I have the same problem months ago, when I found ohmyfetch, and the error was because the particular import of Webpack in Nuxt2: The ohmyfetch package expose 4 types of bundles depending of the import mode (if it was from a ES module or a CJS module) and the environment (if it was for Node or for the browser), but I don't know why Webpack or Nuxt can't understand the dynamic import of the module. If you want to import ohmyfetch in a module for Nuxt2 you need to split your imports in 2 plugins: one that imports the CJS file directly and one server plugin that imports the polyfills needed for Node (just like in the @nuxt/http) module. |
Hi @BrandonlinU do you have an example of that :D ? |
What is your node version? |
Hi @danielroe I have tried with the last one : 16.17.0 same error There is my plugin api file : https://gist.github.com/joffreyBerrier/cd5c8c0a4fd7fa1db78fbcb442098269 Error when i have added
Thx |
Any idea @danielroe ? :) |
It's hard to say without a minimal reproduction. |
Hi @danielroe there is an example 🙏 |
I'm afraid this is a known bug in webpack 4 which was resolved in webpack 5. You can work around it like this, as we do in Bridge: https://stackblitz.com/edit/github-vtace5?file=nuxt.config.js https://github.com/nuxt/bridge/blob/2dfed6aa69a60999d581d4d0ec71ea80bc478e51/src/app.ts#L89-L102 |
OMG thanks a lot @danielroe you are a King ! 👑 |
I am reluctant to dispense such unlimited agreement 😜 But I don't believe webpack 5 has this issue. |
Thx a lot 🙏 |
Since there is a workaround for the issue, I will close this issue for now. |
I'm creating a nuxt module for both: nuxt2 and nuxt3. However I'm having some trouble by building a nuxt2 project by using nuxt generate. The module is using the OhMyFetch module which is not transpiled. Does anyone know what I have to do to get this fixed? I'm getting these kind of import errors:
Basically what I do is the following:
nuxt-module-build
is going correctly and all files are generated.Can't resolve 'node:buffer' Can't resolve 'node:http' ...
Also I do have tried the build.transpile: ['module-name] config. Any thoughts? Thanks 😄
The text was updated successfully, but these errors were encountered: