Skip to content

Commit 68c64fd

Browse files
authored
Make @nuxt/kit dependency optional (#97)
* Update eslint and vitest * Fix eslint warnings * Make @nuxt/kit dependency optional
1 parent 8d8f42a commit 68c64fd

19 files changed

+1248
-807
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ npm install unplugin-fluent-vue --save-dev
3131

3232
```ts
3333
// vite.config.js
34-
import { defineConfig } from 'vite'
3534
import {
3635
ExternalFluentPlugin,
3736
SFCFluentPlugin,
3837
} from 'unplugin-fluent-vue/vite'
38+
import { defineConfig } from 'vite'
3939

4040
export default defineConfig({
4141
plugins: [

__tests__/frameworks/vite/errors.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { resolve } from 'node:path'
2-
import { describe, expect, it } from 'vitest'
3-
42
import vue3 from '@vitejs/plugin-vue'
3+
54
import compiler from '@vue/compiler-sfc'
5+
import { describe, expect, it } from 'vitest'
66

77
import { ExternalFluentPlugin, SFCFluentPlugin } from '../../../src/vite'
88
import { compile } from './util'

__tests__/frameworks/vite/external.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { relative, resolve } from 'node:path'
2-
import { describe, expect, it } from 'vitest'
3-
42
import vue3 from '@vitejs/plugin-vue'
3+
54
import compiler from '@vue/compiler-sfc'
5+
import { describe, expect, it } from 'vitest'
66

77
import { ExternalFluentPlugin } from '../../../src/vite'
88
import { compile } from './util'

__tests__/frameworks/vite/sfc.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { describe, expect, it } from 'vitest'
2-
31
import vue3 from '@vitejs/plugin-vue'
42

53
import compiler from '@vue/compiler-sfc'
4+
5+
import { describe, expect, it } from 'vitest'
66
import { SFCFluentPlugin } from '../../../src/vite'
77
import { compile } from './util'
88

__tests__/frameworks/vite/util.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { resolve, sep } from 'node:path'
2-
31
import type { InlineConfig, ModuleNode } from 'vite'
2+
3+
import { resolve, sep } from 'node:path'
44
import { createServer } from 'vite'
55

66
const baseDir = resolve(__dirname, '../..')
@@ -56,7 +56,8 @@ export async function compile(options: InlineConfig, file: string): Promise<stri
5656
.filter(module => module.transform)
5757
.filter(module => !module.module.url.includes('node_modules'))
5858
.filter(module => !module.module.url.includes('virtual:empty:'))
59-
.map(module => `=== ${module.module.url} ===\n${module.transform.code}`).join('\n\n')
59+
.map(module => `=== ${module.module.url} ===\n${module.transform.code}`)
60+
.join('\n\n')
6061

6162
// normalize paths
6263
return code

__tests__/frameworks/webpack/sfc.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ describe('Webpack SFC', () => {
99
const stats = await compile('fixtures/test.vue')
1010

1111
// Assert
12-
const ftlModules = stats.toJson({ source: true }).modules
13-
?.filter(module => module.name?.includes('blockType=fluent') === true && !module.source.includes('unplugin-fluent-vue-sfc'))
14-
.map(module => module.source)
12+
const ftlModules = stats.toJson({ source: true }).modules?.filter(module => module.name?.includes('blockType=fluent') === true && !module.source.includes('unplugin-fluent-vue-sfc')).map(module => module.source)
1513

1614
expect(ftlModules).not.toBeUndefined()
1715
expect(ftlModules).toHaveLength(1)
@@ -24,9 +22,7 @@ describe('Webpack SFC', () => {
2422
const stats = await compile('fixtures/test.vue', {}, true)
2523

2624
// Assert
27-
const ftlModules = stats.toJson({ source: true }).modules
28-
?.filter(module => module.name?.includes('blockType=fluent') === true && !module.source.includes('unplugin-fluent-vue-sfc'))
29-
.map(module => module.source)
25+
const ftlModules = stats.toJson({ source: true }).modules?.filter(module => module.name?.includes('blockType=fluent') === true && !module.source.includes('unplugin-fluent-vue-sfc')).map(module => module.source)
3026

3127
expect(ftlModules).not.toBeUndefined()
3228
expect(ftlModules).toHaveLength(1)

__tests__/frameworks/webpack/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import type { SFCPluginOptions } from '../../../src/webpack'
12
import path from 'node:path'
2-
import webpack from 'webpack'
3-
import { Volume, createFsFromVolume } from 'memfs'
3+
import { createFsFromVolume, Volume } from 'memfs'
44

55
import { VueLoaderPlugin } from 'vue-loader'
66

7+
import webpack from 'webpack'
78
import { SFCFluentPlugin } from '../../../src/webpack'
8-
import type { SFCPluginOptions } from '../../../src/webpack'
99

1010
export async function compile(fixture: string, options: Partial<SFCPluginOptions> = {}, hot = false): Promise<webpack.Stats> {
1111
const compilation = webpack({

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,32 @@
9494
"prepare": "husky",
9595
"release": "dotenv release-it"
9696
},
97+
"peerDependencies": {
98+
"@nuxt/kit": "^3"
99+
},
100+
"peerDependenciesMeta": {
101+
"@nuxt/kit": {
102+
"optional": true
103+
}
104+
},
97105
"dependencies": {
98106
"@fluent/syntax": "^0.19.0",
99-
"@nuxt/kit": "^3.11.2",
100107
"@rollup/pluginutils": "^5.0.0",
101108
"@vue/compiler-core": "^3.4.21",
102109
"magic-string": "^0.30.0",
103110
"unplugin": "^1.0.0"
104111
},
105112
"devDependencies": {
106-
"@antfu/eslint-config": "^3.0.0",
113+
"@antfu/eslint-config": "^3.6.0",
114+
"@nuxt/kit": "^3.11.2",
107115
"@nuxt/schema": "^3.13.0",
108116
"@release-it-plugins/lerna-changelog": "7.0.0",
109117
"@types/node": "20.16.2",
110118
"@vitejs/plugin-vue": "5.1.3",
111119
"@vitest/coverage-istanbul": "^2.0.5",
112120
"@vue/compiler-sfc": "3.4.38",
113121
"dotenv-cli": "7.4.2",
114-
"eslint": "9.9.1",
122+
"eslint": "9.10.0",
115123
"execa": "9.3.1",
116124
"husky": "9.1.5",
117125
"lint-staged": "15.2.9",
@@ -120,7 +128,7 @@
120128
"tsup": "8.2.4",
121129
"typescript": "5.5.4",
122130
"vite": "5.4.2",
123-
"vitest": "2.0.5",
131+
"vitest": "2.1.0",
124132
"vue": "3.4.38",
125133
"vue-loader": "17.4.2",
126134
"webpack": "5.94.0"

0 commit comments

Comments
 (0)