nuxt / content

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

`nuxt build` breaks with remark plugin `@akebifiky/remark-simple-plantuml` #2542

Closed vacijj closed 7 months ago

vacijj commented 7 months ago

Environment

Nuxt project info:
------------------------------
- Operating System: Linux
- Node Version:     v18.18.0
- Nuxt Version:     3.10.1
- CLI Version:      3.10.0
- Nitro Version:    2.8.1
- Package Manager:  npm@10.2.3
- Builder:          -
- User Config:      devtools, modules, content
- Runtime Modules:  @nuxt/content@2.11.0
- Build Modules:    -
------------------------------

package.json

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@akebifiky/remark-simple-plantuml": "^1.0.2",
    "@nuxt/content": "^2.11.0",
    "nuxt": "^3.10.1",
    "vue": "^3.4.15",
    "vue-router": "^4.2.5"
  }
}

nuxt.config.ts

export default defineNuxtConfig({
  devtools: { enabled: true },

  modules: ['@nuxt/content'],

  content: {
    markdown: {
      remarkPlugins: ['@akebifiky/remark-simple-plantuml'],
    },
  },
})

Reproduction

https://stackblitz.com/edit/github-yghvz1?file=package.json

Run npm run build and see error in console.

Describe the bug

We have been using @akebifiky/remark-simple-plantuml for a while. It used to work until nuxt v3.6.5. After upgrading nuxt to a newer version nuxt build breaks with the error RollupError: Expected 'from', got '@'.

Running npm run dev works still just fine.

Additional context

No response

Logs

> npm run build
...
ℹ Initializing prerenderer                                                                                                                                                     nitro 9:16:44 AM

[9:16:46 AM]  WARN  (inject plugin) rollup-plugin-inject: failed to parse /home/projects/github-yghvz1/.nuxt/mdc-imports.mjs. Consider restricting the plugin to particular files via options.include

 ERROR  RollupError: Expected 'from', got '@' (Note that you need plugins to import files that are not JavaScript)                                                              nitro 9:16:46 AM

1: import @akebifikyRemarkSimplePlantuml from '@akebifiky/remark-simple-plantuml'
          ^
2: 
3: export const remarkPlugins = {

 ERROR  Expected 'from', got '@' (Note that you need plugins to import files that are not JavaScript)                                                                                 9:16:46 AM

  at error (node_modules/rollup/dist/es/shared/parseAst.js:468:30)
  at parseError (node_modules/rollup/dist/es/shared/parseAst.js:1103:9)
  at convertNode (node_modules/rollup/dist/es/shared/parseAst.js:2188:12)
  at convertProgram (node_modules/rollup/dist/es/shared/parseAst.js:1096:12)
  at Module.parseAstAsync (node_modules/rollup/dist/es/shared/parseAst.js:2239:12)
  at async Module.tryParseAsync (node_modules/rollup/dist/es/shared/node-entry.js:13564:20)
  at async Module.setSource (node_modules/rollup/dist/es/shared/node-entry.js:13145:35)
  at async ModuleLoader.addModuleSource (node_modules/rollup/dist/es/shared/node-entry.js:17835:13) 

 ERROR  Expected 'from', got '@' (Note that you need plugins to import files that are not JavaScript)
nobkd commented 7 months ago

Probably the related code piece: https://github.com/nuxt-modules/mdc/blob/dfe090d845feb1a92ef6e884b50df3e57c4b084e/src/templates/mdc-imports.ts#L33

Scule does not remove the @ when converting to pascal case.