nuxt / nuxt/bridge

Error in using Element-ui without client-only tag

Open
#348 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
285
Forks
33
Avg merge
22h 38m
Merged PRs (30d)
3

Description

Environment
- Operating System: `Darwin`
- Node Version:     `v16.15.0`
- Nuxt Version:     `2.16.0-27358576.777a4b7f`
- Package Manager:  `yarn@1.22.15`
- Builder:          `webpack`
- User Config:      `render`, `css`, `plugins`, `build`, `alias`, `bridge`, `buildModules`
- Runtime Modules:  `-`
- Build Modules:    `@nuxt/bridge@3.0.0-27545203.75e046f`

Reproduction

sandbox
please download code and run yarn buildstart or run nuxi build and nuxi preview

Describe the bug

When I use element-ui plugin without client mode:

if I run nuxi build && nuxi preview ,after I open localhost:3000 Terminal will throw error:
[nuxt] [request error] document is not defined at Object.<anonymous> (./.output/server/node_modules/element-ui/lib/utils/types.js:39:165) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (./.output/server/node_modules/element-ui/lib/utils/util.js:19:14) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

nuxi dev is ok

And when I use element-ui plugin in client mode,I need to put all element-ui component in client-only tag , but in Nuxt2 , I can use it without client mode ,all element-ui components I have Used supports ssr good in Nuxt2

Additional context

why it's ok in nuxi dev but throw error in nuxi preview?

Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sandbox and reproduce the failure using nuxi build and nuxi preview, then compare it with nuxi dev. Trace the server error through .output/server/node_modules/element-ui/lib/utils/types.js and util.js. Done means the Element UI plugin can be used without client-only tags and preview no longer throws document is not defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, nuxt, webpack
Domain
build-system, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.