Skip to content

Commit

Permalink
Merge branch 'dev' into after-nuxt-render
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Jun 2, 2021
2 parents ab80d9e + fa12cf1 commit 8d39741
Show file tree
Hide file tree
Showing 37 changed files with 1,007 additions and 870 deletions.
4 changes: 2 additions & 2 deletions distributions/nuxt-start/package.json
Expand Up @@ -30,11 +30,11 @@
"@nuxt/config": "2.15.6",
"@nuxt/core": "2.15.6",
"@nuxt/server": "2.15.6",
"@nuxt/telemetry": "^1.3.3",
"@nuxt/telemetry": "^1.3.6",
"@nuxt/utils": "2.15.6",
"@nuxt/vue-renderer": "2.15.6",
"node-fetch": "^2.6.1",
"vue": "^2.6.12",
"vue": "^2.6.13",
"vue-client-only": "^2.0.0",
"vue-meta": "^2.4.0",
"vue-no-ssr": "^1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions distributions/nuxt/package.json
Expand Up @@ -38,10 +38,10 @@
"@nuxt/config": "2.15.6",
"@nuxt/core": "2.15.6",
"@nuxt/generator": "2.15.6",
"@nuxt/loading-screen": "^2.0.3",
"@nuxt/loading-screen": "^2.0.4",
"@nuxt/opencollective": "^0.3.2",
"@nuxt/server": "2.15.6",
"@nuxt/telemetry": "^1.3.3",
"@nuxt/telemetry": "^1.3.6",
"@nuxt/utils": "2.15.6",
"@nuxt/vue-app": "2.15.6",
"@nuxt/vue-renderer": "2.15.6",
Expand Down
38 changes: 19 additions & 19 deletions package.json
Expand Up @@ -33,55 +33,55 @@
"test:unit": "jest packages --forceExit"
},
"devDependencies": {
"@babel/core": "^7.14.2",
"@babel/preset-env": "^7.14.2",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@ls-lint/ls-lint": "^1.9.2",
"@nuxtjs/eslint-config": "^6.0.0",
"@nuxtjs/eslint-config-typescript": "^6.0.0",
"@nuxtjs/eslint-config": "^6.0.1",
"@nuxtjs/eslint-config-typescript": "^6.0.1",
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"@vue/server-test-utils": "^1.2.0",
"@vue/test-utils": "^1.2.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"chrome-launcher": "^0.13.4",
"chrome-launcher": "^0.14.0",
"consola": "^2.15.3",
"create-require": "^1.1.1",
"cross-spawn": "^7.0.3",
"esbuild": "^0.12.1",
"eslint": "^7.26.0",
"esbuild": "^0.12.5",
"eslint": "^7.27.0",
"eslint-multiplexer": "^2.0.0",
"execa": "^5.0.0",
"execa": "^5.0.1",
"express": "^4.17.1",
"finalhandler": "^1.1.2",
"fs-extra": "^10.0.0",
"get-port": "^5.1.1",
"glob": "^7.1.7",
"got": "^11.8.2",
"improved-yarn-audit": "^2.3.2",
"improved-yarn-audit": "^2.3.3",
"jest": "^26.6.3",
"jiti": "^1.9.2",
"jsdom": "^16.5.3",
"jiti": "^1.10.1",
"jsdom": "^16.6.0",
"jsonfile": "^6.1.0",
"klaw-sync": "^6.0.0",
"lerna": "^4.0.0",
"lodash": "^4.17.21",
"node-fetch": "^2.6.1",
"puppeteer-core": "^9.1.1",
"puppeteer-core": "^10.0.0",
"request": "^2.88.2",
"rimraf": "^3.0.2",
"rollup": "2.48.0",
"rollup-plugin-esbuild": "^4.2.3",
"rollup-plugin-license": "^2.3.0",
"sass": "^1.32.13",
"rollup": "2.50.5",
"rollup-plugin-esbuild": "^4.3.1",
"rollup-plugin-license": "^2.4.0",
"sass": "^1.34.0",
"sass-loader": "^10.1.1",
"sort-package-json": "^1.50.0",
"typescript": "~4.2",
"typescript": "~4.3",
"vue-jest": "^4.0.1"
}
}
12 changes: 6 additions & 6 deletions packages/babel-preset-app/package.json
Expand Up @@ -10,21 +10,21 @@
],
"main": "src/index.js",
"dependencies": {
"@babel/compat-data": "^7.14.0",
"@babel/core": "^7.14.2",
"@babel/helper-compilation-targets": "^7.13.16",
"@babel/compat-data": "^7.14.4",
"@babel/core": "^7.14.3",
"@babel/helper-compilation-targets": "^7.14.4",
"@babel/helper-module-imports": "^7.13.12",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-decorators": "^7.14.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
"@babel/plugin-proposal-optional-chaining": "^7.14.2",
"@babel/plugin-proposal-private-methods": "^7.13.0",
"@babel/plugin-transform-runtime": "^7.14.2",
"@babel/preset-env": "^7.14.2",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@babel/runtime": "^7.14.0",
"@vue/babel-preset-jsx": "^1.2.4",
"core-js": "^2.6.5",
"core-js-compat": "^3.12.1",
"core-js-compat": "^3.13.1",
"regenerator-runtime": "^0.13.7"
},
"publishConfig": {
Expand Down
7 changes: 1 addition & 6 deletions packages/babel-preset-app/src/index.js
Expand Up @@ -97,12 +97,7 @@ module.exports = (api, options = {}) => {
modern: { esmodules: true }
}

let { targets = defaultTargets[envName] } = options

// modern mode can only be { esmodules: true }
if (envName === 'modern') {
targets = defaultTargets.modern
}
const { targets = defaultTargets[envName] } = options

const polyfills = []

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Expand Up @@ -22,7 +22,7 @@
"crc": "^3.8.0",
"defu": "^5.0.0",
"destr": "^1.1.0",
"execa": "^5.0.0",
"execa": "^5.0.1",
"exit": "^0.1.2",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/utils/generate.js
Expand Up @@ -89,7 +89,14 @@ export async function ensureBuild (cmd) {

// Quick diff
let needBuild = false
for (const field of ['nuxtVersion', 'ssr', 'target', 'env', 'process.env']) {

const fields = ['nuxtVersion', 'ssr', 'target']

if (nuxt.options.generate.ignoreEnv !== true) {
fields.push('env', 'process.env')
}

for (const field of fields) {
if (JSON.stringify(previousBuild[field]) !== JSON.stringify(currentBuild[field])) {
needBuild = true
consola.info(`Doing webpack rebuild because ${field} changed`)
Expand Down
4 changes: 2 additions & 2 deletions packages/config/package.json
Expand Up @@ -14,11 +14,11 @@
"consola": "^2.15.3",
"defu": "^5.0.0",
"destr": "^1.1.0",
"dotenv": "^9.0.2",
"dotenv": "^10.0.0",
"lodash": "^4.17.21",
"rc9": "^1.2.0",
"std-env": "^2.3.0",
"ufo": "^0.7.4"
"ufo": "^0.7.5"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions packages/config/src/config/generate.js
Expand Up @@ -3,6 +3,7 @@ export default () => ({
routes: [],
exclude: [],
concurrency: 500,
ignoreEnv: false,
interval: 0,
subFolders: true,
fallback: '200.html',
Expand Down
1 change: 1 addition & 0 deletions packages/config/test/__snapshots__/options.test.js.snap
Expand Up @@ -219,6 +219,7 @@ Object {
"dir": "/var/nuxt/test/dist",
"exclude": Array [],
"fallback": "200.html",
"ignoreEnv": false,
"interval": 0,
"manifest": true,
"nojekyll": true,
Expand Down
2 changes: 2 additions & 0 deletions packages/config/test/config/__snapshots__/index.test.js.snap
Expand Up @@ -194,6 +194,7 @@ Object {
"dir": "dist",
"exclude": Array [],
"fallback": "200.html",
"ignoreEnv": false,
"interval": 0,
"manifest": true,
"nojekyll": true,
Expand Down Expand Up @@ -583,6 +584,7 @@ Object {
"dir": "dist",
"exclude": Array [],
"fallback": "200.html",
"ignoreEnv": false,
"interval": 0,
"manifest": true,
"nojekyll": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/generator/package.json
Expand Up @@ -15,8 +15,8 @@
"devalue": "^2.0.1",
"fs-extra": "^10.0.0",
"html-minifier": "^4.0.0",
"node-html-parser": "^3.3.0",
"ufo": "^0.7.4"
"node-html-parser": "^3.3.4",
"ufo": "^0.7.5"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Expand Up @@ -24,7 +24,7 @@
"serve-placeholder": "^1.2.3",
"serve-static": "^1.14.1",
"server-destroy": "^1.0.1",
"ufo": "^0.7.4"
"ufo": "^0.7.5"
},
"publishConfig": {
"access": "public"
Expand Down
16 changes: 9 additions & 7 deletions packages/server/src/server.js
Expand Up @@ -87,13 +87,15 @@ export default class Server {
this.useMiddleware(createTimingMiddleware(this.options.server.timing))
}

// For serving static/ files to /
const staticMiddleware = serveStatic(
path.resolve(this.options.srcDir, this.options.dir.static),
this.options.render.static
)
staticMiddleware.prefix = this.options.render.static.prefix
this.useMiddleware(staticMiddleware)
if (this.options.render.static !== false) {
// For serving static/ files to /
const staticMiddleware = serveStatic(
path.resolve(this.options.srcDir, this.options.dir.static),
this.options.render.static
)
staticMiddleware.prefix = this.options.render.static.prefix
this.useMiddleware(staticMiddleware)
}

// Serve .nuxt/dist/client files only for production
// For dev they will be served with devMiddleware
Expand Down
99 changes: 96 additions & 3 deletions packages/types/app/vue.d.ts
Expand Up @@ -5,14 +5,32 @@
import Vue from 'vue'
import { MetaInfo } from 'vue-meta'
import { Route } from 'vue-router'
import { RecordPropsDefinition, PropsDefinition, ComponentOptions } from 'vue/types/options'
import { CombinedVueInstance, ExtendedVue } from 'vue/types/vue'
import { NuxtRuntimeConfig } from '../config/runtime'
import { Context, Middleware, Transition, NuxtApp } from './index'

// https://github.com/vuejs/vue/blob/dev/types/options.d.ts#L63-L66
type DefaultData<V> = object | ((this: V) => object)
type DefaultProps = Record<string, any>
type DefaultMethods<V> = { [key: string]: (this: V, ...args: any[]) => any }
type DefaultComputed = { [key: string]: any }
type DefaultAsyncData<V> = ((this: V, context: Context) => Promise<object | void> | object | void)

declare module 'vue/types/options' {
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
interface ComponentOptions<V extends Vue> {
interface ComponentOptions<
V extends Vue,
/* eslint-disable no-unused-vars,@typescript-eslint/no-unused-vars */
Data = DefaultData<V>,
Methods = DefaultMethods<V>,
Computed = DefaultComputed,
PropsDef = PropsDefinition<DefaultProps>,
Props = DefaultProps,
/* eslint-enable no-unused-vars,@typescript-eslint/no-unused-vars */
AsyncData = DefaultAsyncData<V>
> {
// eslint-disable-next-line @typescript-eslint/ban-types
asyncData?(ctx: Context): Promise<object | void> | object | void
asyncData?: AsyncData
fetch?(ctx: Context): Promise<void> | void
fetchKey?: string | ((getKey: (id: string) => number) => string)
fetchDelay?: number
Expand All @@ -30,6 +48,59 @@ declare module 'vue/types/options' {
}
}

type DataDef<Data, Props, V> = Data | ((this: Readonly<Props> & V) => Data)
type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T
type Merged<Data, AsyncData> = {
[key in keyof Data | keyof AsyncData]: key extends keyof Data ? key extends keyof AsyncData ? NonNullable<Data[key]> | AsyncData[key] : Data[key] : key extends keyof AsyncData ? AsyncData[key] : never
}

type ThisTypedComponentOptionsWithArrayPropsAndAsyncData<
V extends Vue,
Data,
Methods,
Computed,
PropNames extends string,
AsyncData
> = object &
ComponentOptions<
V,
DataDef<Data, Record<PropNames, any>, V>,
Methods,
Computed,
PropNames[],
Record<PropNames, any>,
DataDef<AsyncData, PropNames, V>
> &
ThisType<
CombinedVueInstance<
V,
Merged<Data, Awaited<AsyncData>>,
Methods,
Computed,
Readonly<Record<PropNames, any>>
>
>
export type ThisTypedComponentOptionsWithRecordPropsAndAsyncData<
V extends Vue,
Data,
Methods,
Computed,
Props,
AsyncData
> = object &
ComponentOptions<
V,
DataDef<Data, Props, V>,
Methods,
Computed,
RecordPropsDefinition<Props>,
Props,
DataDef<AsyncData, Props, V>
> &
ThisType<
CombinedVueInstance<V, Merged<Data, Awaited<AsyncData>>, Methods, Computed, Readonly<Props>>
>

declare module 'vue/types/vue' {
interface Vue {
$config: NuxtRuntimeConfig
Expand All @@ -41,4 +112,26 @@ declare module 'vue/types/vue' {
timestamp: number
}
}
interface VueConstructor<V extends Vue> {
extend<Data, Methods, Computed, PropNames extends string, AsyncData>(
options?: ThisTypedComponentOptionsWithArrayPropsAndAsyncData<
V,
Data,
Methods,
Computed,
PropNames,
AsyncData
>
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>>
extend<Data, Methods, Computed, Props, AsyncData>(
options?: ThisTypedComponentOptionsWithRecordPropsAndAsyncData<
V,
Data,
Methods,
Computed,
Props,
AsyncData
>
): ExtendedVue<V, Data, Methods, Computed, Props>
}
}
1 change: 1 addition & 0 deletions packages/types/config/generate.d.ts
Expand Up @@ -17,6 +17,7 @@ export interface NuxtOptionsGenerate {
dir?: string
exclude?: RegExp[]
fallback?: string | boolean
ignoreEnv?: boolean
interval?: number
nojekyll?: boolean
routes?: NuxtOptionsGenerateRoute[] | NuxtOptionsGenerateRoutesFunction | NuxtOptionsGenerateRoutesFunctionWithCallback
Expand Down
2 changes: 1 addition & 1 deletion packages/types/config/render.d.ts
Expand Up @@ -72,5 +72,5 @@ export interface NuxtOptionsRender {
resourceHints?: boolean
ssr?: boolean
ssrLog?: boolean | 'collapsed'
static?: ServeStaticOptions
static?: ServeStaticOptions | false
}

0 comments on commit 8d39741

Please sign in to comment.