Open stockersky opened 5 years ago
I'm sorry but if you don't provide a repo for reproduction, there's not much we can help.
And did you have core-js
or @babel/polyfill
listed in your package.json
?
Sorry about that. OK, I added a github repository for reproduction (see updated first post).
I installed Vuetify as described in the Vuetify doc.
Actually, the debug instruction in babel.config.json
does not always output verbose information every time I run npm run build
.
NOTE : I also try to use : npx vue-cli-service build --modern
.
It worked : 2 js output : legacy and modern and index.html is updated.
However, it fails with Google Search Engine inspector and with Opera 15 : syntax error (always on vue-router code as my main project)....
As my main point is to be successfully crawled by Google Bot, maybe transpiling is a better way to go than polyfill. What do think about that?
Actually, Google stated in may that their bot would use up to date version of Chrome engine. Well, I got some doubt about that.... Clearly my webapp haven't been successfully crawled and the Search Console inspector confirms this. It's something I did not care about until I went live. But I guess lot's of Vuejs users might come to this bot issue when going live.
There is also a message about @babel/polyfill being deprecated... Should I follow those steps : https://www.thebasement.be/updating-to-babel-7.4/ ?
OK, I could build the Github test-app I provided.
Look at the last commit named "Added transpileDependencies Vuetify in vue.config.js"
Basically, I removed the import of babel/polyfill
from main.js and most important added Vuetify
to the transpileDependencies
in vue.config.js
as stated in the end of this page: https://vuetifyjs.com/en/getting-started/quick-start
module.exports = {
transpileDependencies:[/node_modules[/\\\\]vuetify[/\\\\]/]
}
NOTE : actually, just transpileDependencies:["vuetify"]
works (maybe from vue-cli release 3.4.0 (2019-01-31))
NOTE about debug in babel.config.js
presets: [
['@vue/app', {
debug: true,
}],
],
==> the verbosity output works only on the first build. I have to delete node_modules directory & install again each time to have it work!
This builds and it works with old browser (opera 15).
But, of course, in my "real life" project, I do not have only Vuetify as dependencies... So, after adding Vuetify in transpiledependencies, I can see that the SyntaxError is not on the same line than before.
There is about a 1000 subdirectories in my node_modules/ .
The aim would be to let Babel recursively inspect and work on all dependencies.
OK, I could make my whole "real life" webapp to work.
I issued a vue info
with the output on the first post of this thread. And then added most of the packages in the transpileDependencies array.
Now, it works on old Opera 15 browser, but better, the Google Search Console URL inspector "sees" my page without error. Great!
I also tried build with modern mode (npx vue-cli-service build --modern
) as described here : https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode
I was expecting vue-cli to only apply transpile/polyfill to the legacy build. It actually executes for both...
Well, I don't know if I'm doing it right.
Version
3.9.3
Environment info
Link to minimal reproduction
https://github.com/stockersky/test-app
Steps to reproduce
npm run build
What is expected?
Vuejs / Vuetify app should be built with polyfill in order to support older browsers.
For testing purpose, I use pre ES2015 opera browser version 15 and put it on .browserslistrc which looks like this:
I also noticed that throught the url inspector in Google Search Console, the page is blank, html code is the one of the public/index.html file and
Uncaught SyntaxError: Unexpected reserved word
is raised.I'd expect Google bot to be able to "boot" my SPA app. This actually this which led me to try to generate polyfills.
What is actually happening?
Here is my babel.config.js :
Top of my main.js :
NOTE : if i try:
I get:
Please help !!!!