nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.14k stars 630 forks source link

refactor: import defineNitroPlugin from #imports instead of nitropack/runtime #2787

Closed ejfox closed 2 months ago

ejfox commented 2 months ago

This is my first PR- but this bug has been bugging me for a few weeks now, and I'm not sure if I have some unique setup that causes the error, but this is blocking me from doing pretty much anything- so I figured I'd give it a shot!

I am not sure the best way to go about testing this- but I am essentially cargo-culting the solution from nuxt/icon and hoping this can be solved in the same way- let me know how to best support/test/finish this off and I will do my best

🔗 Linked issue

MIGHT SOLVE https://github.com/nuxt/content/issues/2736

Related:

❓ Type of change

I tried the mirror the changes from nuxt/icon in this commit: https://github.com/nuxt/icon/pull/249/files

📚 Description

In the previous version, defineNitroPlugin was imported from nitropack/runtime - this instead uses #imports

Currently when running yarn dev with latest Nuxt / Nuxt Content, I get this:

[10:37:10 AM]  ERROR  [worker reload] [worker init] Package import specifier "#internal/nitro/virtual/plugins" is not defined in package /Users/ejfox/code/website/node_modules/nitropack/package.json imported from /Users/ejfox/code/website/node_modules/nitropack/dist/runtime/app.mjs

  at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
  at new NodeError (node:internal/errors:405:5)
  at importNotDefined (node:internal/modules/esm/resolve:348:10)
  at packageImportsResolve (node:internal/modules/esm/resolve:775:9)
  at moduleResolve (node:internal/modules/esm/resolve:930:16)
  at defaultResolve (node:internal/modules/esm/resolve:1129:11)
  at nextResolve (node:internal/modules/esm/loader:163:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
  at link (node:internal/modules/esm/module_job:76:36)

which prevents both publishing and development

📝 Checklist

itpropro commented 1 month ago

Hey @farnabaz any plans on creating a hotfix release for this?

BayBreezy commented 1 month ago

Kindly asking if this will be released any time soon? I cant deploy most of the apps that use this module because of this error.

farnabaz commented 1 month ago

Hey there, This week I will prepare a patch release

BayBreezy commented 1 month ago

Thanks. Appreciate it

mlkt commented 1 month ago

What is the root cause? In my case, I can't avoid it with #imports

import { useRequestBody } from "nitropack/runtime/utils";

It's not work:

import { useRequestBody } from "#imports";