question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't override default plugins

See original GitHub issue

Environment

  • Operating System: Linux
  • Node Version: v14.17.3
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: content, modules
  • Runtime Modules: @nuxt/content@2.0.1
  • Build Modules: -

Reproduction

https://github.com/imlautaro/content-app

Describe the bug

When you try to override the remark plugins (following the instructions in the documentation), it returns an error.

export default defineNuxtConfig({
  content: {
    markdown: {
      remarkPlugins: () => ['remark-emoji']
    }
  }
})
ERROR  Cannot start nuxt:  (options.remarkPlugins || []).map is not a function   

Additional context

No response

Logs

ERROR  Cannot start nuxt:  (options.remarkPlugins || []).map is not a function                                                                           17:05:30

  at processMarkdownOptions (node_modules/@nuxt/content/dist/module.mjs:82:57)
  at setup (node_modules/@nuxt/content/dist/module.mjs:264:31)
  at async Object.normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:583:5)
  at async installModule (node_modules/@nuxt/kit/dist/index.mjs:398:3)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:1336:7)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6734:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6777:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:46:20)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
pi0commented, Jun 7, 2022

@NozomuIkuta In general for Nuxt, we cannot use arrayFn for merging config since it only evaluates the function if the default value is an Array and if it is, it force evaluates the function which is not always the intended behavior. Also makes issue for Type support. (See *)

However, modules like content can support this explicitly and apply defaults in the module body. This experience for module authors would be simpler later using schema and untyped support in the module definition. We can also add an option to opt-in for this per module defenition but IMO just makes module spec more complex while we have simpler ways to achieve the same both for module authors and end-users.

(*) As a related note to the content module and related use cases, if the intended defaults behavior is overriding and not extending, instead of adding function complexity, they could add only when user options are not provided conditionally. So that users don’t need a function to override and can simply pass an array. Another pattern would be using a KV object so that users can explicitly disable on of the built-in plugins. We use this for postcsss plugins options for example.

2reactions
harlan-zwcommented, Jun 6, 2022

I don’t disagree, just telling you how the code is setup in case you want to unblock yourself.

This issue should be closed only if the doc is updated or the functionality is supported

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to override plugin's default css rules
I'm not able to override the "Total Control HTML5 Audio Player Basic" plugin default css file. I've copied the plugin css default content...
Read more >
jQuery plugin not overriding defaults - javascript - Stack Overflow
I'm working on a jQuery plugin and can't seem to override the default settings, here's a snippet of the plugin.
Read more >
Defect #14758: Can't override default locale with plugin
I'm not saying that plugins locales are not joins, i'm saying that plugin locales can't override default locales, may be they loads before...
Read more >
CKEditor should allow plugins to override default config - Drupal
Drupal's Internal plugin, which loads first, sets some settings by default: This means that another plugin cannot override these.
Read more >
JavaScript - Bootstrap
For example, a button cannot both have a tooltip and toggle a modal. ... You can change the default settings for a plugin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found