Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue-server-renderer] Bug failing when using a reference of process - related to SSRClientWebpackPlugin #9194

Open
AlexandreBonaventure opened this issue Dec 12, 2018 · 10 comments

Comments

@AlexandreBonaventure
Copy link

Version

2.5.21

Reproduction link

https://github.com/AlexandreBonaventure/repro-vue-ssr-bug

Steps to reproduce

  1. yarn install
  2. yarn run ssr:build && yarn ssr:start
  3. go to localhost:8000

What is expected?

to serve / correctly

What is actually happening?

error 500:

TypeError: Cannot read property 'replace' of undefined
    at normalizeFile (.../node_modules/vue-server-renderer/build.js:8183:27)

Hi, I came across this weird bug when I was trying to retrieve a global variable (eg. global.localenv.PUBLIC_URL) in App.vue to populate a meta tag (using vue-meta).
I stumble upon the bug, and narrowed it down to referencing process being the cause here.
Another weird thing is that if you remove the component Icons import in the minimal repro, it works fine!

The error stack is initiated by TemplateRenderer.renderPreloadLinks which makes me think that maybe it is a bug in the webpack SSRClientPlugin which inject preload links for every assets.

@tkjaergaard
Copy link

tkjaergaard commented Dec 18, 2018

+1

I'm experiencing the same issue TypeError: Cannot read property 'replace' of undefined.

Downgrading to [email protected], [email protected] and [email protected] made my application run again.

2.5.18-2.5.21 make my application break with the TypeError:

TypeError: Cannot read property 'replace' of undefined
    at normalizeFile (.../node_modules/vue-server-renderer/build.js:8176:27)

@Zacaria

This comment has been minimized.

@chentianyuan

This comment has been minimized.

@vuejs vuejs deleted a comment from chentianyuan Dec 31, 2018
@vuejs vuejs deleted a comment from ediaos Feb 23, 2019
@sebkolind
Copy link

I had this error too when building my client webpack config. It turns out that I forgot to delete VueSSRServerPlugin() and had both the server and client plugin. As soon as I removed the server plugin from the client config it works.

I am not sure if it's related but someone else might have the same issue.

@laure-at-irun
Copy link

laure-at-irun commented Mar 18, 2019

For me, the error was caused by a malformed vue-ssr-client-manifest.json : in the modules section, some modules were mapped to indexes -1. As a result, at runtime, the vue-server-renderer was unable to load the file.

To fix it, I just enabled the source maps for css files. In vue.config.js, add to your client config :

css: {
     sourceMap: true,
},

Tested with version 2.6.9.

I hope this will help.

@AlexandreBonaventure
Copy link
Author

@laure-at-irun yep! that was my issue as well

@OliverJEvans
Copy link

@laure-at-irun This fixed the issue for me too. But why!?

@laure-at-irun
Copy link

The vue client plugin receives from webpack compilation stats a list of files that includes css maps, even when css maps are not emitted. The list is provided by webpack though stats.chunks.files. The stats.assets doesn't contain the css map files.

However, I am not sure why webpack is doing this.

Anyway, the client plugin is not robust to webpack inconsistent data.

@lovetingyuan
Copy link

#9488 (comment)

@lovetingyuan
Copy link

The vue client plugin receives from webpack compilation stats a list of files that includes css maps, even when css maps are not emitted. The list is provided by webpack though stats.chunks.files. The stats.assets doesn't contain the css map files.

However, I am not sure why webpack is doing this.

Anyway, the client plugin is not robust to webpack inconsistent data.

Maybe souceMap in chunks is set by option: devtool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants