Skip to content

Commit 884d067

Browse files
committed
chore(deps): update to Nuxt 3
1 parent 2c9bf4e commit 884d067

File tree

8 files changed

+4549
-4198
lines changed

8 files changed

+4549
-4198
lines changed

docs/content/0.index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Easily connect your Nuxt 3 application to your content hosted on [Prismic](https
3232

3333
#extra
3434
::alert{type="info" style="max-width: 40rem"}
35-
Like Nuxt 3, the module is in an RC phase. We're polishing the remaining rough edges before launching a stable release <Icon name="noto:rocket" class="inline" />
35+
Like Nuxt 3 used to be, this module is in an RC phase. We're polishing the remaining rough edges before launching a stable release <Icon name="noto:rocket" class="inline" />
3636

3737
<br />
3838
<br />

package-lock.json

Lines changed: 4504 additions & 4158 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,22 @@
4747
"unit:watch": "vitest watch"
4848
},
4949
"dependencies": {
50-
"@nuxt/kit": "^3.0.0-rc",
51-
"@prismicio/client": "^6.6.1",
52-
"@prismicio/vue": "^3.0.0",
53-
"consola": "^2.15.3",
54-
"ufo": "^0.8.5"
50+
"@nuxt/kit": "^3.0.0",
51+
"@prismicio/client": "^6.7.1",
52+
"@prismicio/vue": "^3.1.1",
53+
"consola": "^2.15.3"
5554
},
5655
"devDependencies": {
57-
"@nuxt/module-builder": "latest",
56+
"@nuxt/module-builder": "^0.2.1",
5857
"@nuxt/test-utils": "npm:@nuxt/test-utils-edge@latest",
59-
"@nuxtjs/eslint-config-typescript": "latest",
60-
"c8": "^7.11.3",
61-
"eslint": "^8.20.0",
62-
"mock-fs": "^5.1.2",
63-
"nuxt": "^3.0.0-rc",
58+
"@nuxtjs/eslint-config-typescript": "^12.0.0",
59+
"@vitest/coverage-c8": "^0.25.2",
60+
"eslint": "^8.27.0",
61+
"mock-fs": "^5.2.0",
62+
"nuxt": "^3.0.0",
6463
"standard-version": "^9.5.0",
65-
"typescript": "^4.7.4",
66-
"vitest": "^0.18.1"
64+
"typescript": "^4.9.3",
65+
"vitest": "^0.25.2"
6766
},
6867
"engines": {
6968
"node": ">=14.15.0"

playground/nuxt.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { defineNuxtConfig } from 'nuxt'
2-
31
import prismicModule from '../src/module'
42

53
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config

playground/pages/index.vue

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<template>
22
<div>
33
<div
4-
@click="() => refreshNuxtData()">
4+
@click="() => refreshNuxtData()"
5+
>
56
Pending: {{ pending }}
67
</div>
78
<div v-if="!pending">
8-
<prismic-link v-slot="{ href }"
9-
:field="doc.data.relation">
9+
<prismic-link
10+
v-slot="{ href }"
11+
:field="doc?.data.relation"
12+
>
1013
{{ href }} foo
1114
</prismic-link>
12-
<prismic-link v-slot="{ href }"
13-
:field="{ link_type: 'Web', url: 'https://google.com' }">
15+
<prismic-link
16+
v-slot="{ href }"
17+
:field="{ link_type: 'Web', url: 'https://google.com' }"
18+
>
1419
{{ href }} bar
1520
</prismic-link>
1621
<prismic-rich-text
17-
:field="doc.data.richtext" />
18-
<!-- <prismic-text :field="home?.data.body[0].primary.title" /> -->
19-
<!-- <slice-zone :slices="home?.data.body" /> -->
22+
:field="doc?.data.richtext"
23+
/>
24+
<!-- <prismic-text :field="doc?.data.body[0].primary.title" /> -->
25+
<!-- <slice-zone :slices="doc?.data.body" /> -->
2026
</div>
2127
</div>
2228
</template>

src/module.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,36 @@ import {
55
createResolver,
66
addTemplate,
77
addPlugin,
8-
addAutoImport,
8+
addImports,
99
addComponent,
1010
extendPages
1111
} from '@nuxt/kit'
12-
import { cleanDoubleSlashes } from 'ufo'
1312

1413
import { isRepositoryEndpoint, getRepositoryName } from '@prismicio/client'
1514
import * as prismicVue from '@prismicio/vue'
1615

17-
import { name as pkgName, version as pkgVersion } from '../package.json'
1816
import { logger, fileExists } from './lib'
1917
import type { PrismicModuleOptions } from './types'
2018

2119
// Options export
2220
export type { PrismicModuleOptions } from './types'
2321
export type { PrismicModuleOptions as ModuleOptions } from './types'
2422

23+
const PACKAGE_NAME = '@nuxtjs/prismic'
24+
2525
// Module export
2626
export default defineNuxtModule<PrismicModuleOptions>({
2727
meta: {
28-
name: pkgName,
29-
version: pkgVersion,
28+
name: PACKAGE_NAME,
3029
configKey: 'prismic',
3130
compatibility: { nuxt: '^3.0.0-rc.6' }
3231
},
3332
defaults: nuxt => ({
3433
endpoint: '',
3534
clientConfig: {},
36-
client: cleanDoubleSlashes(`~/${nuxt.options.dir.app}/prismic/client`),
37-
linkResolver: cleanDoubleSlashes(`~/${nuxt.options.dir.app}/prismic/linkResolver`),
38-
htmlSerializer: cleanDoubleSlashes(`~/${nuxt.options.dir.app}/prismic/htmlSerializer`),
35+
client: '~/app/prismic/client',
36+
linkResolver: '~/app/prismic/linkResolver',
37+
htmlSerializer: '~/app/prismic/htmlSerializer',
3938
injectComponents: true,
4039
components: {},
4140
preview: '/preview',
@@ -80,7 +79,10 @@ export default defineNuxtModule<PrismicModuleOptions>({
8079

8180
// Expose options through public runtime config
8281
nuxt.options.runtimeConfig.public ||= {} as typeof nuxt.options.runtimeConfig.public
83-
nuxt.options.runtimeConfig.public[pkgName] = mergedOptions
82+
// @ts-expect-error - Inferred type by `nuxi prepare` might vary depending on previous run.
83+
// However, this is the source of truth for the runtime config and types
84+
// will be inferred after it.
85+
nuxt.options.runtimeConfig.public[PACKAGE_NAME] = mergedOptions
8486

8587
// Add plugin
8688
addPlugin(resolver.resolve('runtime/plugin'))
@@ -115,8 +117,8 @@ export default defineNuxtModule<PrismicModuleOptions>({
115117
from: '@prismicio/vue'
116118
}
117119
})
118-
addAutoImport(composableAutoImports)
119-
addAutoImport({
120+
addImports(composableAutoImports)
121+
addImports({
120122
name: 'usePrismicPreview',
121123
as: 'usePrismicPreview',
122124
from: resolver.resolve('runtime/usePrismicPreview')

test/__testutils__/mockedNuxtKit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const mockedNuxtKit = async () => {
3131
},
3232
addTemplate: vi.fn(),
3333
addPlugin: vi.fn(),
34-
addAutoImport: vi.fn(),
34+
addImports: vi.fn(),
3535
addComponent: vi.fn(),
3636
extendPages: vi.fn((extendPagesHook) => {
3737
const pages = []

test/module-autoImports.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { it, expect, vi, beforeEach, afterEach } from 'vitest'
22

3-
import { addAutoImport, addComponent } from '@nuxt/kit'
3+
import { addImports, addComponent } from '@nuxt/kit'
44

55
import prismicModule from '../src/module'
66

@@ -13,7 +13,7 @@ beforeEach(() => {
1313
logger: { info: vi.fn(), warn: vi.fn() }
1414
}))
1515
vi.mock('@nuxt/kit', async () => {
16-
const { mockedNuxtKit } = await vi.importActual('./__testutils__/mockedNuxtKit')
16+
const { mockedNuxtKit } = await vi.importActual<any>('./__testutils__/mockedNuxtKit')
1717

1818
return mockedNuxtKit()
1919
})
@@ -73,9 +73,9 @@ it('doesn\'t auto-import component when `injectComponents` is `false`', () => {
7373
it('auto-imports composables', () => {
7474
mockedPrismicModule({ endpoint: 'qwerty' })
7575

76-
expect(addAutoImport).toHaveBeenCalledTimes(2)
76+
expect(addImports).toHaveBeenCalledTimes(2)
7777
// @ts-expect-error - Mocked type is wrong
78-
expect(addAutoImport.calls.flat(2).map(options => [options.name, options.as])).toMatchInlineSnapshot(`
78+
expect(addImports.calls.flat(2).map(options => [options.name, options.as])).toMatchInlineSnapshot(`
7979
[
8080
[
8181
"useAllPrismicDocumentsByEveryTag",

0 commit comments

Comments
 (0)