Skip to content

Commit c36b071

Browse files
authored
Remove every reference to .nuxt global option (#11265)
* Remove unused rehydratation plugin * Remove any reference to the .nuxt folders * Remove globalApp nuxt and any reference or use case to nuxt.error * Replace errors handling with existing fail-whale logic
1 parent c124439 commit c36b071

File tree

19 files changed

+26
-140
lines changed

19 files changed

+26
-140
lines changed

.ackrc

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--ignore-dir=.git
22
--ignore-dir=.vscode
3-
--ignore-dir=.nuxt
4-
--ignore-dir=.nuxt-prod
53
--ignore-dir=.nyc_output
64
--ignore-dir=coverage
75
--ignore-dir=dist

.dockerignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
.nuxt
2-
.nuxt-prod
31
.env
4-
.nuxt
52
.nyc_output
63
coverage
74
node_modules

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ node_modules/
66
.env
77
.cache
88
.next
9-
.nuxt
9+
1010
dist
1111
dist-pkg
1212
.DS_Store

.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ typings/
6666
# next.js build output
6767
.next
6868

69-
# nuxt.js build output
70-
.nuxt
71-
.nuxt-prod
72-
73-
# Nuxt generate
69+
# Build output
7470
dist
7571

7672
# vuepress build output

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"files.exclude": {
33
".eslintcache": true,
4-
".nuxt*": true,
54
"yarn-error.log": true,
65
"pkg/**/.shell": true,
76
"pkg/**/node_modules": true

cypress.config.ts

-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ export default defineConfig({
7676
'docusaurus/**/*.*',
7777
'stories/**/*.*',
7878
'drone/**/*.*',
79-
'.nuxt/**/*.*',
80-
'.nuxt-prod/**/*.*',
8179
],
8280
include: [
8381
'shell/**/*.{vue,ts,js}',

docusaurus/docs/internal/testing/e2e-test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ It's also possible to run a workflow in GitHub Actions E2E test using these valu
111111

112112
## Local and CI/prod run
113113

114-
It is possible to start the project and run all the tests at once with a single command. There's however a difference between `dev` and `production` run. The first will not require an official certificate and will build the project in `.nuxt`, while the production will enable all the SSL configurations to run encrypted.
114+
It is possible to start the project and run all the tests at once with a single command. There's however a difference between `dev` and `production` run. The first will not require an official certificate and will build the project in `dist`, while the production will enable all the SSL configurations to run encrypted.
115115

116116
- `yarn e2e:pre-dev`, to optionally initialize Docker and build the project, if not already done
117117
- `yarn e2e:dev`, single run local development

jest.config.js

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ module.exports = {
2727
'<rootDir>/stories/',
2828
'<rootDir>/shell/scripts/',
2929
'<rootDir>/drone',
30-
'<rootDir>/.nuxt',
31-
'<rootDir>/.nuxt-prod',
3230
],
3331
testPathIgnorePatterns: [
3432
'<rootDir>/node_modules/',

scripts/rejig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Directories and folders not to replace in
4-
GREP_EXCLUDES="--exclude-dir=.git --exclude-dir=.nuxt --exclude-dir=node_modules --exclude=rejig --exclude=nuxt.config.js --exclude-dir=shell --exclude-dir=pkg --exclude-dir=pkg-dist --exclude-dir=dist"
4+
GREP_EXCLUDES="--exclude-dir=.git --exclude-dir=node_modules --exclude=rejig --exclude=nuxt.config.js --exclude-dir=shell --exclude-dir=pkg --exclude-dir=pkg-dist --exclude-dir=dist"
55
GREP_REVERT_EXCLUDES="${GREP_EXCLUDES} --exclude=vue.config.js --exclude=jest.config.js --exclude=tsconfig.default.json --exclude=tsconfig.json --exclude=tsconfig.pkg.json --exclude=extension.js --exclude=extensions.js --exclude=model-loader.js"
66

77
echo "Re-jigging codebase"

shell/components/templates/error.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ export default {
1010
},
1111
1212
computed: {
13-
error() {
14-
return window.$globalApp.nuxt.err || {};
15-
},
1613
statusCode() {
17-
return (this.error && this.error.statusCode) || 599;
14+
return 599;
1815
},
1916
message() {
20-
return this.error.message || '';
17+
return '';
2118
}
2219
},
2320
watch: {

shell/creators/app/files/.eslintignore

-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ node_modules/
77
.env
88
.cache
99
.next
10-
.nuxt
1110
dist
1211
dist-pkg
1312
.DS_Store
1413
dynamic-importer.js
1514
ksconfig.json
16-
nuxt.config.js
1715
shell/utils/dynamic-importer.js
1816
shell/assets/fonts

shell/creators/app/files/.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
".eslintignore": true,
99
".eslintrc.js": true,
1010
".gitignore": true,
11-
".nuxt*": true,
1211
".nyc_output": true,
1312
".vscode": true,
1413
"LICENSE": true,

shell/initialize/App.vue

-20
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export default {
3131
window.addEventListener('online', this.refreshOnlineStatus);
3232
window.addEventListener('offline', this.refreshOnlineStatus);
3333
34-
// Add $nuxt.error()
35-
this.error = this.$options.nuxt.error;
3634
// Add $nuxt.context
3735
this.context = this.$options.context;
3836
},
@@ -41,8 +39,6 @@ export default {
4139
this.$loading = this.$refs.loading;
4240
},
4341
44-
watch: { 'nuxt.err': 'errorChanged' },
45-
4642
computed: {
4743
isOffline() {
4844
return !this.isOnline;
@@ -60,22 +56,6 @@ export default {
6056
this.isOnline = window.navigator.onLine;
6157
}
6258
},
63-
errorChanged() {
64-
if (this.$options.nuxt.err) {
65-
if (this.$loading) {
66-
if (this.$loading.fail) {
67-
this.$loading.fail(this.$options.nuxt.err);
68-
}
69-
if (this.$loading.finish) {
70-
this.$loading.finish();
71-
}
72-
}
73-
74-
this.showErrorPage = true;
75-
} else {
76-
this.showErrorPage = false;
77-
}
78-
},
7959
},
8060
8161
components: { NuxtLoading, NuxtError }

shell/initialize/app-extended.js

-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// This file was generated during Nuxt migration
33
import AppView from '@shell/initialize/App';
44
import { setContext, getRouteData } from '@shell/initialize/entry-helpers';
5-
import { normalizeError } from '@shell/utils/error';
65
import { extendRouter } from '@shell/config/router';
76
import { extendStore } from '@shell/config/store';
87
import { UPGRADED, _FLAGGED, _UNFLAG } from '@shell/config/query-params';
@@ -34,7 +33,6 @@ export const getLocation = (base, mode) => {
3433

3534
/**
3635
* Bundle Vue app component and configuration to be executed on entry
37-
* TODO: #11070 - Remove Nuxt residuals
3836
* @param {*} vueApp Vue instance
3937
* @returns
4038
*/
@@ -53,24 +51,6 @@ async function extendApp(vueApp) {
5351
const appPartials = {
5452
store,
5553
router,
56-
nuxt: {
57-
err: null,
58-
dateErr: null,
59-
error(err) {
60-
err = err || null;
61-
appPartials.context._errored = Boolean(err);
62-
err = err ? normalizeError(err) : null;
63-
let nuxt = appPartials.nuxt; // to work with @vue/composition-api, see https://github.com/nuxt/nuxt.js/issues/6517#issuecomment-573280207
64-
65-
if (this) {
66-
nuxt = this.nuxt || this.$options.nuxt;
67-
}
68-
nuxt.dateErr = Date.now();
69-
nuxt.err = err;
70-
71-
return err;
72-
}
73-
},
7454
...AppView
7555
};
7656

@@ -88,7 +68,6 @@ async function extendApp(vueApp) {
8868
store,
8969
route,
9070
next,
91-
error: appPartials.nuxt.error.bind(appPartials),
9271
payload: undefined,
9372
req: undefined,
9473
res: undefined

shell/initialize/entry-helpers.js

+19-26
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export const loadDebugger = (vueApp) => {
2929
}
3030

3131
if (vm && vm.$root) {
32-
const nuxtApp = Object.keys(window.$globalApp)
33-
.find((nuxtInstance) => vm.$root[nuxtInstance]);
32+
const globalApp = Object.keys(window.$globalApp)
33+
.find((instance) => vm.$root[instance]);
3434

3535
// Show Nuxt Error Page
36-
if (nuxtApp && vm.$root[nuxtApp].error && info !== 'render function') {
37-
const vueApp = vm.$root[nuxtApp];
36+
if (globalApp && vm.$root[globalApp].error && info !== 'render function') {
37+
const vueApp = vm.$root[globalApp];
3838

3939
vueApp.error(err);
4040
}
@@ -54,6 +54,16 @@ export const loadDebugger = (vueApp) => {
5454
}
5555
};
5656

57+
/**
58+
* Handle errors with a redirect
59+
* @param {*} context
60+
* @param {*} message
61+
*/
62+
const errorRedirect = (context, message) => {
63+
context.$store.commit('setError', { error: new Error(message) });
64+
context.$router.replace('/fail-whale');
65+
};
66+
5767
/**
5868
* TODO: Define this logic use case
5969
* @param {*} fn
@@ -104,17 +114,6 @@ export const middlewareSeries = (promises, appContext) => {
104114
});
105115
};
106116

107-
/**
108-
* Trigger errors
109-
* @param {*} app App view instance
110-
*/
111-
const checkForErrors = (app) => {
112-
// Hide error component if no error
113-
if (app._hadError && app._dateLastError === app.$options.nuxt.dateErr) {
114-
app.error();
115-
}
116-
};
117-
118117
/**
119118
* Add middleware to the Vue instance
120119
* @param {*} Components List of Vue components
@@ -137,7 +136,7 @@ function callMiddleware(Components, context) {
137136
}
138137
if (typeof middleware[name] !== 'function') {
139138
unknownMiddleware = true;
140-
this.error({ statusCode: 500, message: `Unknown middleware ${ name }` });
139+
errorRedirect(this, new Error(`500: Unknown middleware ${ name }`));
141140
}
142141

143142
return middleware[name];
@@ -190,8 +189,6 @@ async function render(to, from, next) {
190189
from,
191190
next: _next.bind(this)
192191
});
193-
this._dateLastError = app.nuxt.dateErr;
194-
this._hadError = Boolean(app.nuxt.err);
195192

196193
// Get route's matched components
197194
const matches = [];
@@ -215,7 +212,8 @@ async function render(to, from, next) {
215212
}
216213

217214
// Show error page
218-
this.error({ statusCode: 404, message: 'This page could not be found' });
215+
// this.error({ statusCode: 404, message: 'This page could not be found' });
216+
errorRedirect(this, new Error('404: This page could not be found'));
219217

220218
return next();
221219
}
@@ -256,17 +254,14 @@ async function render(to, from, next) {
256254
}
257255
} catch (validationError) {
258256
// ...If .validate() threw an error
259-
this.error({
260-
statusCode: validationError.statusCode || '500',
261-
message: validationError.message
262-
});
257+
errorRedirect(this, new Error(`${ validationError.statusCode || '500' }: ${ validationError.message }`));
263258

264259
return next();
265260
}
266261

267262
// ...If .validate() returned false
268263
if (!isValid) {
269-
this.error({ statusCode: 404, message: 'This page could not be found' });
264+
errorRedirect(this, new Error('404: This page could not be found'));
270265

271266
return next();
272267
}
@@ -284,7 +279,6 @@ async function render(to, from, next) {
284279

285280
globalHandleError(error);
286281

287-
this.error(error);
288282
next();
289283
}
290284
}
@@ -320,7 +314,6 @@ export async function mountApp(appPartials, VueClass) {
320314

321315
// First render on client-side
322316
const clientFirstMount = () => {
323-
checkForErrors(vueApp);
324317
mount();
325318
};
326319

shell/plugins/dashboard-store/rehydrate-all.js

-44
This file was deleted.

shell/scripts/clean

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ set -e
33

44
cd $(dirname $0)/..
55

6-
rm -rf dist .nuxt* node_modules/.cache
6+
rm -rf dist node_modules/.cache

shell/tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
},
2828
"exclude": [
2929
"node_modules",
30-
".nuxt",
3130
"dist",
3231
"dist-pkg",
3332
"../dist",

tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
},
2727
"exclude": [
2828
"node_modules",
29-
".nuxt",
3029
"dist",
3130
"dist-pkg",
3231
"cypress",

0 commit comments

Comments
 (0)