Nuxt 2 SSR dev response very slow - vue.js

nuxt: 2.15.8
node: v16.14.2
I've been developing it for over 7 months, I'd like to know if it's normal for other people. because I feel it is very slow before being able to refresh each time Especially when developing with TailwindCSS it is slower than waiting for it to respond.
I use SSR and WSL2 and i think it is not from WSL2 and Docker because its api is very fast.
page response time: 3-6s sometimes 7-10s its very slow
dev build client: 8-30s
dev build server: 9-35s
My files
In folder pages: 40+
In folder components: 60+
In forder plugins: 19
"dependencies": {
"#kangc/v-md-editor": "^1.7.8",
"#nuxt/babel-preset-app": "^2.15.8",
"#nuxtjs/auth-next": "5.0.0-1642502410.8e1c713",
"#nuxtjs/axios": "^5.13.6",
"#nuxtjs/composition-api": "^0.31.0",
"#nuxtjs/feed": "^2.0.0",
"#nuxtjs/proxy": "^2.1.0",
"#nuxtjs/robots": "^2.5.0",
"#nuxtjs/sitemap": "^2.4.0",
"#tailwindcss/forms": "^0.5.2",
"#tailwindcss/line-clamp": "^0.3.1",
"#vueform/multiselect": "^2.3.1",
"#vueuse/core": "^7.5.4",
"core-js": "3",
"date-fns": "^2.28.0",
"filepond": "^4.30.3",
"filepond-plugin-file-validate-type": "^1.2.6",
"filepond-plugin-image-preview": "^4.6.10",
"highlight.js": "^11.4.0",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"markdown-it-video": "^0.6.3",
"maska": "^1.5.0",
"numeral": ">=2",
"nuxt": "^2.15.8",
"nuxt-clipboard": "^0.0.7",
"nuxt-jsonld": "v1",
"nuxt-route-meta": "^2.3.4",
"pusher-js": "^7.1.0-beta",
"tailwind-gradient-mask-image": "^1.0.0",
"tailwind-merge": "^1.2.1",
"tinyduration": "^3.2.2",
"vee-validate": "^3.4.14",
"vue": "^2.6.14",
"vue-advanced-cropper": "^1.10.0",
"vue-demi": "^0.12.1",
"vue-filepond": "^6.0.0",
"vue-filter-number-format": "^3.0.1",
"vue-gtag": "^1.16.1",
"vue-if-bot": "^1.2.0",
"vue-lazyload": "^1.3.3",
"vue-lodash": "^2.1.2",
"vue-notification": "!1.3.16",
"vue-scrollto": "^2.20.0",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"vue-toastification": "^1.7.14",
"vue2-datepicker": "^3.11.0",
"vue2-timeago": "^2.0.6",
"vuex-pathify": "^1.5.1",
"vuex-persist": "^3.1.3",
"webpack": "^4.46.0"
},
"devDependencies": {
"#babel/runtime-corejs3": "^7.16.8",
"#iconify/icons-ant-design": "^1.1.1",
"#iconify/icons-bi": "^1.1.12",
"#iconify/icons-bx": "^1.2.3",
"#iconify/icons-carbon": "^1.1.7",
"#iconify/icons-cil": "^1.1.0",
"#iconify/icons-eva": "^1.1.0",
"#iconify/icons-fe": "^1.1.0",
"#iconify/icons-flat-color-icons": "^1.1.0",
"#iconify/icons-fluent": "^1.2.6",
"#iconify/icons-gg": "^1.1.0",
"#iconify/icons-ic": "^1.2.3",
"#iconify/icons-icon-park-outline": "^1.2.1",
"#iconify/icons-ion": "^1.1.2",
"#iconify/icons-la": "^1.2.1",
"#iconify/icons-lucide": "^1.2.11",
"#iconify/icons-mdi": "^1.1.42",
"#iconify/icons-mono-icons": "^1.1.0",
"#iconify/vue2": "^1.1.2",
"#nuxt/postcss8": "^1.1.3",
"#nuxtjs/device": "^2.1.0",
"#nuxtjs/dotenv": "^1.4.1",
"#nuxtjs/laravel-echo": "v2.0.0-alpha.5",
"#vue/test-utils": "^1.3.0",
"#vueuse/nuxt": "^7.5.4",
"autoprefixer": "^10.4.5",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^27.4.4",
"jest": "^27.4.4",
"mini-svg-data-uri": "^1.4.3",
"nuxt-storm": "^1.1.2",
"postcss": "^8.4.5",
"sass": "^1.49.0",
"sass-loader": "^10",
"tailwind-scrollbar": "^1.3.1",
"tailwindcss": "^3.1.8",
"vue-jest": "^3.0.4"
},
I want to know if everyone is like me. Or am I doing something wrong? to make you have to wait every time you press Refresh the web page.
In production it works normally and works fast.

Disclaimer: I don't like WSL so I may be biased saying that it has an impact haha. Nothing beats a vanilla UNIX system performance/stability wise, rather than doing a hacky kernel emulation IMO.
Having WSL and Docker as middlewares between your code and your HMR'ed webpage is clearly a good lead towards why it may be slow (a good optimized configuration may be used there).
You could debug that one by trying your app into a Linux VM (or some colleague's computer) without Docker (quite a cumbersome thing to test for sure but is not that trivial I guess).
Then, you're saying that you have quite some plugins. Those are global things that are run at the start of the rendering process of your Nuxt app, they will definitely slow down the reload speed.
Especially if they are importing huge NPM packages. I recommend to use Import Cost as a VScode extension, quite handy to check how big the package you're importing is big.
Bundlephobia is also a quite nice website for that purpose. Hi 280kB highlight.js!
Make sure that you're using the JIT engine properly with Tailwind too, as this one can bring a LOT of CSS classes that are not used by your code.
Be careful about DOM mismatches because those can impact quite heavily your performance by rehydrating your whole app and mess up even more with Docker/etc.
Be mindful to check what you do have as HTTP calls + middlewares. Mainly check your devtools to try to find out what is making the whole thing slow.
Any kind of analytics + 3rd party scripts like chat boxes, mouse trackers etc...can bring a lot of code and impact your Web Core Vitals quite heavily too.
Try to see if some of your dependecies could be moved towards devDependecies if they are not needed on runtime.
Be sure to have a somewhat decent SSD + CPU + proper cooling to handle a minimal dev experience.
Not sure what is vue-lodash benefit but I recommend using a properly tree-shakable lodash-es solution. Same goes for the rest of the packages, trying to maybe find better/lighter alternatives.
Also, try to remove unneeded packages like #nuxtjs/dotenv (baked-in into Nuxt already).
Finally: SASS. Big boy, if you're not using it to the max, maybe consider removing it especially if you're already using Tailwind + PostCSS.
Most of what I wrote above are "fixed" once bundled for production. And since it's working fast there, I guess it's not a code logic issue per-se (but it still can).
Also, depending on your CI and what kind of endpoints you use locally, you may have some degraded performances locally (some devops teams give slower response times for dev environments).
I may have forgotten a few things and I didn't checked your nuxt.config.js file but I think that you have plenty of things to try out already. Good luck!

It looks like it's from importing Icon packages from "#iconify/icons-xx" because I have to use it offline (Nuxt SSR).
https://docs.iconify.design/icon-components/vue2/offline.html
See issues https://github.com/iconify/iconify/issues/175
Solution: I switched to unplugin-icons for icons to be used offline
So now,My nuxt is loading faster.

Related

Error with task: Cannot read property 'measureInWindow' of undefined

I am trying to setup an application with #react-navigation.
I have installed all the required dependencies:
"#react-navigation/bottom-tabs": "^5.4.2",
"#react-navigation/native": "^5.3.0",
"#react-navigation/stack": "^5.3.2",
"react-native-safe-area-context": "^1.0.0",
react-native-screens": "^2.7.0",
"#react-native-community/masked-view": "^0.1.10",
"react-native-reanimated": "^1.8.0",
"react-native-gesture-handler": "^1.6.1",
When launching the application I receive errors regarding 'measureInWindow'.
wrapNativeSuper.js:10 Unhandled JS Exception: TypeError: Cannot read property 'measureInWindow' of undefined
This would appear to relate to the react-native-safe-area-context per some research but I am unable to figure out why that doesn't work. I have pod installed since adding the libraries and rebuilt the application, but the same error persists. If I remove react-native-safe-area-context then react-navigation will complain it is not added.
This question is related but the answer suggests updating react-navigation and I am on the latest version: TypeError: Cannot read property 'measureInWindow' of undefined - This question also mentions react-native-safe-area-view but I believe react-navigation no longer uses this in favour of -safe-area-context.
This issue on react-navigation seems to relate (https://github.com/react-navigation/react-navigation/issues/7933) but it suggests react-native-safe-area-view is in use and there is a new version (that is not published?)

How to resolve NPM dependency problem with shadow-cljs using react-swipeable-views?

I have a ClojureScript project using shadow-cljs. In this project I am using the NPM package #material-ui, which works fine.
Now I would like to use react-swipeable-views. Therefor I have extended my package.json:
"dependencies": {
"#material-ui/core": "^4.5.2",
"#material-ui/icons": "^4.5.1",
"highlight.js": "9.15.10",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-flip-move": "3.0.3",
"react-highlight.js": "1.0.7",
"react-swipeable-views": "0.13.3"
}
When I try to require ["react-swipeable-views" :as sv] I get this error from shadow-cljs:
The required JS dependency "dom-helpers/transition/properties" is not
available, it was required by
"node_modules/react-swipeable-views/lib/SwipeableViews.js".
And in fact, there is no transition directory in node_modules/dom-helpers/. But there is import transitionInfo from 'dom-helpers/transition/properties'; in node_modules/react-swipeable-views/src/SwipeableViews.js.
It looks like a dependency bug in react-swipeable-views, but I am a newbie to NPM.
Any suggestions what the problem is? Or how to debug?
UPDATE
It seams react-swipeable-views depends on the outdated dom-helpers#3.4.0 while shadow-cljs uses the current dom-helpers#5.1.3. See https://github.com/oliviertassinari/react-swipeable-views/issues/542
Is it possible to use both? Or will I have to wait until someone fixes react-swipeable-views?
You correctly identified this is caused by a version conflict.
It is not possible to use both versions, you must resolve this version conflict. You can try installing the older dom-helpers version as the default by adding it to your package.json and npm install it. Maybe the library that was using the newer one still works with the old one?

The LoginForm's input placeholder of react-admin2.4.2 can't change to 'Username',It is 'ra.auth.username' now.Is this a bug?

I updated my package(react-admin) to 2.4.2, then unfortunately the LoginForm's input placeholder can't change.It is 'ra.auth.username' now. When package version is 2.4.1 , the LoginForm's input placeholder is 'Username'.
Is this a bug?
I had the same problem. There is a issue if you have different versions of react-admin and ra-data-simple-rest (or another data provider).
I fixed by deleting the correspondig node_modules and installing again changing the dependencies in package.json:
...
"ra-data-json-server": "^2.7.0",
"ra-data-simple-rest": "^2.7.0",
"ra-ui-materialui": "^2.7.0",
"react-admin": "^2.7.0",
...

undefined is not an object (evaluating 'CameraManager.Aspect')

I've been getting this error when setting and linking my react-camera with my project on React-Native. I tried all the solutions found in google but still not working, I also tried this video https://www.youtube.com/watch?v=pJseuSOC8HA and not working either. Can someone please try to help me?
this is my package.json:
"dependencies": {
"prop-types": "^15.5.8",
"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
"react-navigation": "^1.0.0-beta.7",
"react-redux": "^5.0.4",
"redux": "^3.6.0",
"redux-promise-middleware": "^4.2.0",
"redux-thunk": "^2.2.0"
},
Linked manually the libraries then try again.. We have the same issue and same version I already fixed it.
use this command.
react-native link
If you have cocoa pods
and you are trying to link package using react-native link
Than be sure that you run pod install after react-native link

Karma Jasmine PhantomJS- PhantomJS have not captured in 60000 ms

In Package JSON, I have tried many different versions of karma-phantomjs-launcher, phantomjs, including phantomjs-prebuilt.
Current Package JSON
"devDependencies": {
"jasmine-core": "^2.5.2",
"karma": "^1.6.0",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^0.1.1",
"phantomjs": "^1.9.20"
}
In all cases I get "PhantomJS have not captured in 60000 ms" It tries twice, then gives up.
I am on Windows 10, running from command line in WebStorm. However, I get same errors in Visual Studio Code.
What is the problem? Karma starts, Karma finds files, PhantomJS starts, but does not capture.
I've seen suggestions to set localhost in hosts file and checking whether karma port 9876 is already in use. Nothing seems to work.
Please advise.
Thanks
From this thread https://github.com/karma-runner/karma-phantomjs-launcher/issues/84
Go to C:\Windows\System32\drivers\etc\hosts or /etc/hosts (if you're on Linux)
Add 127.0.0.1 localhost to your host file and it works!