mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 14:45:15 +00:00
chore: type-check .mjs
files (#20711)
This commit is contained in:
parent
7cb4c69935
commit
a793e7ad48
@ -45,7 +45,9 @@
|
|||||||
"@types/node": "^18.16.5",
|
"@types/node": "^18.16.5",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.3.13",
|
||||||
"case-police": "^0.6.0",
|
"case-police": "^0.6.0",
|
||||||
|
"chalk": "^5.2.0",
|
||||||
"changelogen": "^0.5.3",
|
"changelogen": "^0.5.3",
|
||||||
|
"consola": "^3.1.0",
|
||||||
"crawler": "^1.4.0",
|
"crawler": "^1.4.0",
|
||||||
"devalue": "^4.3.0",
|
"devalue": "^4.3.0",
|
||||||
"eslint": "^8.40.0",
|
"eslint": "^8.40.0",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
import { viteNodeFetch } from './vite-node-shared.mjs'
|
import { viteNodeFetch } from './vite-node-shared.mjs'
|
||||||
|
|
||||||
export default () => viteNodeFetch('/manifest')
|
export default () => viteNodeFetch('/manifest')
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
import { Agent as HTTPSAgent } from 'node:https'
|
import { Agent as HTTPSAgent } from 'node:https'
|
||||||
import { $fetch } from 'ofetch'
|
import { $fetch } from 'ofetch'
|
||||||
|
|
||||||
@ -5,6 +6,7 @@ export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS ||
|
|||||||
|
|
||||||
export const viteNodeFetch = $fetch.create({
|
export const viteNodeFetch = $fetch.create({
|
||||||
baseURL: viteNodeOptions.baseURL,
|
baseURL: viteNodeOptions.baseURL,
|
||||||
|
// @ts-expect-error https://github.com/node-fetch/node-fetch#custom-agent
|
||||||
agent: viteNodeOptions.baseURL.startsWith('https://')
|
agent: viteNodeOptions.baseURL.startsWith('https://')
|
||||||
? new HTTPSAgent({ rejectUnauthorized: false })
|
? new HTTPSAgent({ rejectUnauthorized: false })
|
||||||
: null
|
: null
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
import { performance } from 'node:perf_hooks'
|
import { performance } from 'node:perf_hooks'
|
||||||
import { createError } from 'h3'
|
import { createError } from 'h3'
|
||||||
import { ViteNodeRunner } from 'vite-node/client'
|
import { ViteNodeRunner } from 'vite-node/client'
|
||||||
@ -5,8 +7,10 @@ import { consola } from 'consola'
|
|||||||
import { viteNodeFetch, viteNodeOptions } from './vite-node-shared.mjs'
|
import { viteNodeFetch, viteNodeOptions } from './vite-node-shared.mjs'
|
||||||
|
|
||||||
const runner = createRunner()
|
const runner = createRunner()
|
||||||
|
/** @type {(ssrContext: import('#app').NuxtSSRContext) => Promise<any>} */
|
||||||
let render
|
let render
|
||||||
|
|
||||||
|
/** @param ssrContext {import('#app').NuxtSSRContext} */
|
||||||
export default async (ssrContext) => {
|
export default async (ssrContext) => {
|
||||||
// Workaround for stub mode
|
// Workaround for stub mode
|
||||||
// https://github.com/nuxt/framework/pull/3983
|
// https://github.com/nuxt/framework/pull/3983
|
||||||
@ -33,6 +37,7 @@ function createRunner () {
|
|||||||
return new ViteNodeRunner({
|
return new ViteNodeRunner({
|
||||||
root: viteNodeOptions.root, // Equals to Nuxt `srcDir`
|
root: viteNodeOptions.root, // Equals to Nuxt `srcDir`
|
||||||
base: viteNodeOptions.base,
|
base: viteNodeOptions.base,
|
||||||
|
// @ts-expect-error https://github.com/vitest-dev/vitest/pull/3312
|
||||||
resolveId (id, importer) { _importers.set(id, importer) },
|
resolveId (id, importer) { _importers.set(id, importer) },
|
||||||
async fetchModule (id) {
|
async fetchModule (id) {
|
||||||
const importer = _importers.get(id)
|
const importer = _importers.get(id)
|
||||||
@ -67,11 +72,18 @@ function createRunner () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param errorData {any}
|
||||||
|
* @param id {string}
|
||||||
|
* @param importer {string}
|
||||||
|
*/
|
||||||
function formatViteError (errorData, id, importer) {
|
function formatViteError (errorData, id, importer) {
|
||||||
const errorCode = errorData.name || errorData.reasonCode || errorData.code
|
const errorCode = errorData.name || errorData.reasonCode || errorData.code
|
||||||
const frame = errorData.frame || errorData.source || errorData.pluginCode
|
const frame = errorData.frame || errorData.source || errorData.pluginCode
|
||||||
|
|
||||||
|
/** @param locObj {{ file?: string, id?: string, url?: string }} */
|
||||||
const getLocId = (locObj = {}) => locObj.file || locObj.id || locObj.url || id || ''
|
const getLocId = (locObj = {}) => locObj.file || locObj.id || locObj.url || id || ''
|
||||||
|
/** @param locObj {{ line?: string, column?: string }} */
|
||||||
const getLocPos = (locObj = {}) => locObj.line ? `${locObj.line}:${locObj.column || 0}` : ''
|
const getLocPos = (locObj = {}) => locObj.line ? `${locObj.line}:${locObj.column || 0}` : ''
|
||||||
const locId = getLocId(errorData.loc) || getLocId(errorData.location) || getLocId(errorData.input) || getLocId(errorData)
|
const locId = getLocId(errorData.loc) || getLocId(errorData.location) || getLocId(errorData.input) || getLocId(errorData)
|
||||||
const locPos = getLocPos(errorData.loc) || getLocPos(errorData.location) || getLocPos(errorData.input) || getLocPos(errorData)
|
const locPos = getLocPos(errorData.loc) || getLocPos(errorData.location) || getLocPos(errorData.input) || getLocPos(errorData)
|
||||||
|
@ -40,9 +40,15 @@ importers:
|
|||||||
case-police:
|
case-police:
|
||||||
specifier: ^0.6.0
|
specifier: ^0.6.0
|
||||||
version: 0.6.0
|
version: 0.6.0
|
||||||
|
chalk:
|
||||||
|
specifier: ^5.2.0
|
||||||
|
version: 5.2.0
|
||||||
changelogen:
|
changelogen:
|
||||||
specifier: ^0.5.3
|
specifier: ^0.5.3
|
||||||
version: 0.5.3
|
version: 0.5.3
|
||||||
|
consola:
|
||||||
|
specifier: ^3.1.0
|
||||||
|
version: 3.1.0
|
||||||
crawler:
|
crawler:
|
||||||
specifier: ^1.4.0
|
specifier: ^1.4.0
|
||||||
version: 1.4.0
|
version: 1.4.0
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
import Crawler from 'crawler'
|
import Crawler from 'crawler'
|
||||||
import { consola } from 'consola'
|
import { consola } from 'consola'
|
||||||
import { parseURL, withoutTrailingSlash } from 'ufo'
|
import { parseURL, withoutTrailingSlash } from 'ufo'
|
||||||
@ -67,7 +68,7 @@ const crawler = new Crawler({
|
|||||||
callback (error, res, done) {
|
callback (error, res, done) {
|
||||||
const { $ } = res
|
const { $ } = res
|
||||||
const { uri } = res.options
|
const { uri } = res.options
|
||||||
const { statusCode } = res.request.response
|
const { statusCode } = res.response
|
||||||
|
|
||||||
if (error || ![200, 301, 302].includes(statusCode) || !$) {
|
if (error || ![200, 301, 302].includes(statusCode) || !$) {
|
||||||
// TODO: normalize relative links in module readmes - https://github.com/nuxt/nuxt.com/issues/1271
|
// TODO: normalize relative links in module readmes - https://github.com/nuxt/nuxt.com/issues/1271
|
||||||
|
Loading…
Reference in New Issue
Block a user