Skip to content

Commit

Permalink
Merge branch 'main' into fix/next-tick-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL committed Jan 14, 2024
2 parents edbff86 + 98fb2be commit 629461b
Show file tree
Hide file tree
Showing 25 changed files with 571 additions and 667 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
# Cache lychee results (e.g. to avoid hitting rate limits)
- name: Restore lychee cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -91,7 +91,7 @@ jobs:
queries: +security-and-quality

- name: Restore dist cache
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: dist
path: packages
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
run: pnpm install

- name: Restore dist cache
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: dist
path: packages
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV
- name: Cache Playwright's binary
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
key: ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }}
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
Expand All @@ -244,7 +244,7 @@ jobs:
run: pnpm playwright-core install chromium

- name: Restore dist cache
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: dist
path: packages
Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:
run: pnpm install

- name: Restore dist cache
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: dist
path: packages
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
run: pnpm install

- name: Restore dist cache
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: dist
path: packages
Expand Down
8 changes: 4 additions & 4 deletions docs/6.bridge/1.overview.md
Expand Up @@ -23,7 +23,7 @@ Make sure your dev server (`nuxt dev`) isn't running, remove any package lock fi

```diff [package.json]
- "nuxt": "^2.16.3"
+ "nuxt": "^2.17.0"
+ "nuxt": "^2.17.3"
```

Then, reinstall your dependencies:
Expand All @@ -46,16 +46,16 @@ Once the installation is complete, make sure both development and production bui

### Install Nuxt Bridge

Install `@nuxt/bridge-edge` as a development dependency:
Install `@nuxt/bridge` as a development dependency:

::code-group

```bash [Yarn]
yarn add --dev @nuxt/bridge@npm:@nuxt/bridge-edge
yarn add --dev @nuxt/bridge
```

```bash [npm]
npm install -D @nuxt/bridge@npm:@nuxt/bridge-edge
npm install -D @nuxt/bridge
```

::
Expand Down
4 changes: 0 additions & 4 deletions docs/6.bridge/2.typescript.md
Expand Up @@ -38,10 +38,6 @@ If you are using TypeScript, you can edit your `tsconfig.json` to benefit from a
As `.nuxt/tsconfig.json` is generated and not checked into version control, you'll need to generate that file before running your tests. Add `nuxi prepare` as a step before your tests, otherwise you'll see `TS5083: Cannot read file '~/.nuxt/tsconfig.json'`
::

::callout
You may also need to add `@vue/runtime-dom` as a devDependency if you are struggling to get template type inference working with [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar).
::

::callout
Keep in mind that all options extended from `./.nuxt/tsconfig.json` will be overwritten by the options defined in your `tsconfig.json`.
Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions from `./.nuxt/tsconfig.json`. This can lead to module resolutions such as `#imports` not being recognized.
Expand Down
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -35,10 +35,10 @@
"@nuxt/schema": "workspace:*",
"@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "workspace:*",
"rollup": "^4.9.4",
"rollup": "^4.9.5",
"nuxt": "workspace:*",
"vite": "5.0.11",
"vue": "3.4.7",
"vue": "3.4.10",
"magic-string": "^0.30.5"
},
"devDependencies": {
Expand All @@ -47,7 +47,7 @@
"@nuxt/test-utils": "3.9.0",
"@nuxt/webpack-builder": "workspace:*",
"@types/fs-extra": "11.0.4",
"@types/node": "20.10.8",
"@types/node": "20.11.0",
"@types/semver": "7.5.6",
"@vitest/coverage-v8": "1.1.1",
"@vue/test-utils": "2.4.3",
Expand All @@ -64,14 +64,14 @@
"fs-extra": "11.2.0",
"globby": "14.0.0",
"h3": "1.10.0",
"happy-dom": "12.10.3",
"happy-dom": "13.0.2",
"jiti": "1.21.0",
"markdownlint-cli": "0.38.0",
"nitropack": "2.8.1",
"nuxi": "3.10.0",
"nuxt": "workspace:*",
"ofetch": "1.3.3",
"pathe": "1.1.1",
"pathe": "1.1.2",
"playwright-core": "1.40.1",
"rimraf": "5.0.5",
"semver": "7.5.4",
Expand All @@ -80,12 +80,12 @@
"ufo": "1.3.2",
"vitest": "1.1.1",
"vitest-environment-nuxt": "1.0.0",
"vue": "3.4.7",
"vue": "3.4.10",
"vue-eslint-parser": "9.4.0",
"vue-router": "4.2.5",
"vue-tsc": "1.8.27"
},
"packageManager": "pnpm@8.14.0",
"packageManager": "pnpm@8.14.1",
"engines": {
"node": "^14.18.0 || >=16.10.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/kit/package.json
Expand Up @@ -35,10 +35,10 @@
"ignore": "^5.3.0",
"jiti": "^1.21.0",
"knitwork": "^1.0.0",
"mlly": "^1.4.2",
"pathe": "^1.1.1",
"mlly": "^1.5.0",
"pathe": "^1.1.2",
"pkg-types": "^1.0.3",
"scule": "^1.1.1",
"scule": "^1.2.0",
"semver": "^7.5.4",
"ufo": "^1.3.2",
"unctx": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/internal/template.ts
Expand Up @@ -9,7 +9,7 @@ import { toArray } from '../utils'

/** @deprecated */
// TODO: Remove support for compiling ejs templates in v4
export async function compileTemplate (template: NuxtTemplate, ctx: any) {
export async function compileTemplate <T>(template: NuxtTemplate<T>, ctx: any) {
const data = { ...ctx, options: template.options }
if (template.src) {
try {
Expand Down
8 changes: 4 additions & 4 deletions packages/kit/src/template.ts
Expand Up @@ -16,7 +16,7 @@ import { resolveNuxtModule } from './resolve'
/**
* Renders given template using lodash template during build into the project buildDir
*/
export function addTemplate (_template: NuxtTemplate<any> | string) {
export function addTemplate <T>(_template: NuxtTemplate<T> | string) {
const nuxt = useNuxt()

// Normalize template
Expand All @@ -36,7 +36,7 @@ export function addTemplate (_template: NuxtTemplate<any> | string) {
* Renders given types using lodash template during build into the project buildDir
* and register them as types.
*/
export function addTypeTemplate (_template: NuxtTypeTemplate<any>) {
export function addTypeTemplate <T>(_template: NuxtTypeTemplate<T>) {
const nuxt = useNuxt()

const template = addTemplate(_template)
Expand All @@ -56,7 +56,7 @@ export function addTypeTemplate (_template: NuxtTypeTemplate<any>) {
/**
* Normalize a nuxt template object
*/
export function normalizeTemplate (template: NuxtTemplate<any> | string): ResolvedNuxtTemplate<any> {
export function normalizeTemplate <T>(template: NuxtTemplate<T> | string): ResolvedNuxtTemplate<T> {
if (!template) {
throw new Error('Invalid template: ' + JSON.stringify(template))
}
Expand Down Expand Up @@ -99,7 +99,7 @@ export function normalizeTemplate (template: NuxtTemplate<any> | string): Resolv
template.dst = resolve(nuxt.options.buildDir, template.filename)
}

return template as ResolvedNuxtTemplate<any>
return template as ResolvedNuxtTemplate<T>
}

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/nuxt/package.json
Expand Up @@ -59,7 +59,7 @@
},
"dependencies": {
"@nuxt/devalue": "^2.0.2",
"@nuxt/devtools": "^1.0.6",
"@nuxt/devtools": "^1.0.8",
"@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*",
"@nuxt/telemetry": "^2.5.3",
Expand All @@ -68,7 +68,7 @@
"@unhead/dom": "^1.8.9",
"@unhead/ssr": "^1.8.9",
"@unhead/vue": "^1.8.9",
"@vue/shared": "^3.4.7",
"@vue/shared": "^3.4.10",
"acorn": "8.11.3",
"c12": "^1.6.1",
"chokidar": "^3.5.3",
Expand All @@ -87,17 +87,17 @@
"klona": "^2.0.6",
"knitwork": "^1.0.0",
"magic-string": "^0.30.5",
"mlly": "^1.4.2",
"mlly": "^1.5.0",
"nitropack": "^2.8.1",
"nuxi": "^3.10.0",
"nypm": "^0.3.4",
"ofetch": "^1.3.3",
"ohash": "^1.1.3",
"pathe": "^1.1.1",
"pathe": "^1.1.2",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.0.3",
"radix3": "^1.1.0",
"scule": "^1.1.1",
"scule": "^1.2.0",
"std-env": "^3.7.0",
"strip-literal": "^2.0.0",
"ufo": "^1.3.2",
Expand All @@ -109,7 +109,7 @@
"unplugin": "^1.6.0",
"unplugin-vue-router": "^0.7.0",
"untyped": "^1.4.0",
"vue": "^3.4.7",
"vue": "^3.4.10",
"vue-bundle-renderer": "^2.0.0",
"vue-devtools-stub": "^0.1.0",
"vue-router": "^4.2.5"
Expand Down
12 changes: 9 additions & 3 deletions packages/nuxt/src/components/islandsTransform.ts
Expand Up @@ -33,6 +33,7 @@ const SCRIPT_RE = /<script[^>]*>/g
const HAS_SLOT_OR_CLIENT_RE = /(<slot[^>]*>)|(nuxt-client)/
const TEMPLATE_RE = /<template>([\s\S]*)<\/template>/
const NUXTCLIENT_ATTR_RE = /\snuxt-client(="[^"]*")?/g
const IMPORT_CODE = '\nimport { vforToArray as __vforToArray } from \'#app/components/utils\'' + '\nimport NuxtTeleportSsrClient from \'#app/components/nuxt-teleport-ssr-client\''

export const islandsTransform = createUnplugin((options: ServerOnlyComponentTransformPluginOptions, meta) => {
const isVite = meta.framework === 'vite'
Expand All @@ -57,9 +58,14 @@ export const islandsTransform = createUnplugin((options: ServerOnlyComponentTran
const startingIndex = template.index || 0
const s = new MagicString(code)

s.replace(SCRIPT_RE, (full) => {
return full + '\nimport { vforToArray as __vforToArray } from \'#app/components/utils\'' + '\nimport NuxtTeleportSsrClient from \'#app/components/nuxt-teleport-ssr-client\''
})
if (!code.match(SCRIPT_RE)) {
s.prepend('<script setup>' + IMPORT_CODE + '</script>')
} else {
s.replace(SCRIPT_RE, (full) => {
return full + IMPORT_CODE
})
}


let hasNuxtClient = false

Expand Down
17 changes: 4 additions & 13 deletions packages/nuxt/src/components/templates.ts
@@ -1,15 +1,6 @@
import { isAbsolute, relative } from 'pathe'
import { genDynamicImport } from 'knitwork'
import type { Component, Nuxt, NuxtApp, NuxtPluginTemplate, NuxtTemplate } from 'nuxt/schema'

interface ComponentsTemplateContext {
app: NuxtApp
nuxt: Nuxt
options: {
getComponents: (mode?: 'client' | 'server' | 'all') => Component[]
mode?: 'client' | 'server'
}
}
import type { NuxtPluginTemplate, NuxtTemplate } from 'nuxt/schema'

type ImportMagicCommentsOptions = {
chunkName: string
Expand Down Expand Up @@ -70,14 +61,14 @@ export default defineNuxtPlugin({
}
}

export const componentNamesTemplate: NuxtTemplate<ComponentsTemplateContext> = {
export const componentNamesTemplate: NuxtTemplate = {
filename: 'component-names.mjs',
getContents ({ app }) {
return `export const componentNames = ${JSON.stringify(app.components.filter(c => !c.island).map(c => c.pascalName))}`
}
}

export const componentsIslandsTemplate: NuxtTemplate<ComponentsTemplateContext> = {
export const componentsIslandsTemplate: NuxtTemplate = {
// components.islands.mjs'
getContents ({ app }) {
const components = app.components
Expand All @@ -102,7 +93,7 @@ export const componentsIslandsTemplate: NuxtTemplate<ComponentsTemplateContext>
}
}

export const componentsTypeTemplate: NuxtTemplate<ComponentsTemplateContext> = {
export const componentsTypeTemplate: NuxtTemplate = {
filename: 'components.d.ts',
getContents: ({ app, nuxt }) => {
const buildDir = nuxt.options.buildDir
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/core/app.ts
Expand Up @@ -36,7 +36,7 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?:
// Compile templates into vfs
// TODO: remove utils in v4
const templateContext = { utils: templateUtils, nuxt, app }
const filteredTemplates = (app.templates as Array<ReturnType<typeof normalizeTemplate>>)
const filteredTemplates = (app.templates as Array<ResolvedNuxtTemplate<any>>)
.filter(template => !options.filter || options.filter(template))

const writes: Array<() => void> = []
Expand Down
7 changes: 2 additions & 5 deletions packages/nuxt/src/core/nitro.ts
Expand Up @@ -17,7 +17,7 @@ import { template as defaultSpaLoadingTemplate } from '@nuxt/ui-templates/templa
import { version as nuxtVersion } from '../../package.json'
import { distDir } from '../dirs'
import { toArray } from '../utils'
import { ImportProtectionPlugin } from './plugins/import-protection'
import { ImportProtectionPlugin, nuxtImportProtections } from './plugins/import-protection'

export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
// Resolve config
Expand Down Expand Up @@ -339,10 +339,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
nitroConfig.rollupConfig!.plugins!.push(
ImportProtectionPlugin.rollup({
rootDir: nuxt.options.rootDir,
patterns: [
...['#app', /^#build(\/|$)/]
.map(p => [p, 'Vue app aliases are not allowed in server routes.']) as [RegExp | string, string][]
],
patterns: nuxtImportProtections(nuxt, { isNitro: true }),
exclude: [/core[\\/]runtime[\\/]nitro[\\/]renderer/]
})
)
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/core/nuxt.ts
Expand Up @@ -16,7 +16,7 @@ import importsModule from '../imports/module'
/* eslint-enable */
import { distDir, pkgDir } from '../dirs'
import { version } from '../../package.json'
import { ImportProtectionPlugin, vueAppPatterns } from './plugins/import-protection'
import { ImportProtectionPlugin, nuxtImportProtections } from './plugins/import-protection'
import type { UnctxTransformPluginOptions } from './plugins/unctx'
import { UnctxTransformPlugin } from './plugins/unctx'
import type { TreeShakeComposablesPluginOptions } from './plugins/tree-shake'
Expand Down Expand Up @@ -89,7 +89,7 @@ async function initNuxt (nuxt: Nuxt) {
rootDir: nuxt.options.rootDir,
// Exclude top-level resolutions by plugins
exclude: [join(nuxt.options.rootDir, 'index.html')],
patterns: vueAppPatterns(nuxt)
patterns: nuxtImportProtections(nuxt)
}
addVitePlugin(() => ImportProtectionPlugin.vite(config))
addWebpackPlugin(() => ImportProtectionPlugin.webpack(config))
Expand Down

0 comments on commit 629461b

Please sign in to comment.