Skip to content

Filter dependsOn based on environment at build-time, with dev-time warning #25401

Open
@eljass

Description

@eljass

Environment

  • Operating System: Darwin
  • Node Version: v18.17.1
  • Nuxt Version: 3.9.1
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: yarn@4.0.2
  • Builder: -
  • User Config: experimental, typescript, devtools, modules, pwa, routeRules, image, viewport, imports, dayjs, runtimeConfig, app, components, ssr, dev, css, nitro, vite, hooks, sourcemap
  • Runtime Modules: @pinia/nuxt@0.5.1, dayjs-nuxt@2.1.9, nuxt-jsonld@2.0.8, @nuxtjs/device@3.1.1, @hypernym/nuxt-anime@2.1.1, nuxt-viewport@2.1.0, @nuxt/image@1.1.0, @vite-pwa/nuxt@0.4.0, nuxt-vitest@0.11.5
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-3e85ga

Describe the bug

Nuxt gives console warnings Plugin d-plugin depends on b-plugin but they are not registered. if depending on parallel plugin which is not accessible in environment the plugin depending is on (.client or .server suffix).

Also, it appears that the plugin that depends on other plugins does not execute if dependsOn is not fulfilled completely for the current environment.

For example, if I have four plugins:

  • a.client.ts - { name: 'a', parallel: true, dependsOn: undefined }
  • b.server.ts - { name: 'b', parallel: true, dependsOn: undefined }
  • c.ts - { name: 'c', parallel: true, dependsOn: undefined }
  • d.ts - { name: 'd', parallel: undefined, dependsOn: ['a', 'b', 'c'] }

All of these has code:

setup: () => {
    console.log('Hello from "<PLUGIN NAME>" plugin');
  },

My CLI prints:

Hello from "B" plugin
Hello from "C" plugin

My browser's console prints:

Hello from "B" plugin
Hello from "C" plugin
Hello from "A" plugin
Hello from "C" plugin

Additional context

No response

Logs

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Has plan

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions