Compare commits

..
Author SHA1 Message Date
github-actions[bot] cdc373986c Version Packages 2023-11-14 03:12:17 +00:00
Alexander Sorokin 9d939c1b1b Switch to using module ID markers
Previously VIntl for Nuxt kept track of files that were used as locale
messages and matched module IDs based on them. This, however, was very
unreliable in certain environments.

With this change VIntl for Nuxt now uses 'markers', URL parameters added
to the end of imported module IDs. This allows it to very quickly test
whether a specific module is imported through a message file and should
be processed by the VIntl unplugin.
2023-11-14 04:03:39 +01:00
github-actions[bot] 2007377bcf Version Packages 2023-10-30 06:01:58 +00:00
Alexander Sorokin 6479891b2d Update VIntl to v4.4.1 2023-10-30 06:57:18 +01:00
renovate[bot]andSasha Sorokin ec6744774d Update all non-major dependencies 2023-10-30 04:47:10 +01:00
renovate[bot]andSasha Sorokin 70a4cc57b0 Update actions/setup-node action to v4 2023-10-30 04:44:13 +01:00
github-actions[bot] f8f4494527 Version Packages 2023-10-10 21:46:16 +00:00
Sasha Sorokin fe75e7ca94 Explicitly pass build subcommand to nuxt-module-build 2023-10-10 23:41:44 +02:00
Sasha Sorokin a9fdc595f5 Update VIntl Unplugin to 1.5.0 2023-10-10 23:39:42 +02:00
13 changed files with 2405 additions and 1214 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
+5 -5
View File
@@ -13,15 +13,15 @@
"start": "node .output/server/index.mjs"
},
"devDependencies": {
"@formatjs/cli": "^6.2.0",
"@formatjs/cli": "^6.2.1",
"@nuxt-themes/docus": "^1.15.0",
"@nuxt/eslint-config": "^0.2.0",
"@vintl-dev/eslint-config-peony": "workspace:^",
"@vintl/nuxt": "workspace:^",
"eslint": "^8.51.0",
"nuxi": "^3.9.0",
"nuxt": "^3.7.4",
"eslint": "^8.52.0",
"nuxi": "^3.9.1",
"nuxt": "^3.8.0",
"theme-colors": "^0.0.5",
"vue": "^3.3.4"
"vue": "^3.3.7"
}
}
+3 -3
View File
@@ -17,8 +17,8 @@
"@vintl-dev/eslint-config-peony": "workspace:^",
"@vintl-dev/pg-messages": "workspace:^",
"@vintl/nuxt": "workspace:^",
"eslint": "^8.51.0",
"nuxi": "^3.9.0",
"nuxt": "^3.7.4"
"eslint": "^8.52.0",
"nuxi": "^3.9.1",
"nuxt": "^3.8.0"
}
}
+2 -3
View File
@@ -29,7 +29,7 @@ const messages = defineMessages({
},
brokenMessage: {
id: 'broken-message',
defaultMessage: 'This is {broken, }'
defaultMessage: 'This is {broken, }',
},
} as const)
@@ -89,10 +89,9 @@ const useAutomatic = computed({
id="language-select"
v-model="currentLocale"
:disabled="vintl.automatic"
@change="onLocaleChange"
>
<option
v-for="locale in [...$nuxt.$i18n.$locales.value.keys()]"
v-for="locale in [...$i18n.$locales.value.keys()]"
:key="locale.tag"
:value="locale.tag"
>
+2 -2
View File
@@ -8,7 +8,7 @@
],
"devDependencies": {
"@changesets/cli": "^2.26.2",
"turbo": "^1.10.15"
"turbo": "^1.10.16"
},
"scripts": {
"pg:prepare": "turbo run --no-daemon @vintl-dev/pg#dev:prepare",
@@ -36,5 +36,5 @@
}
}
},
"packageManager": "pnpm@8.8.0"
"packageManager": "pnpm@8.9.2"
}
+5 -5
View File
@@ -27,13 +27,13 @@
],
"dependencies": {
"@rushstack/eslint-patch": "^1.5.1",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"eslint-plugin-vue": "^9.17.0",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"eslint-plugin-vue": "^9.18.0",
"typescript": "^5.2.2"
},
"devDependencies": {
"@types/eslint": "^8.44.3",
"eslint": "^8.51.0"
"@types/eslint": "^8.44.6",
"eslint": "^8.52.0"
}
}
+40
View File
@@ -1,5 +1,45 @@
# @vintl/nuxt
## 1.8.0
### Minor Changes
- 9d939c1: Switched to using module ID markers
Previously VIntl for Nuxt kept track of files that were used as locale messages and matched module IDs based on them. This, however, was very unreliable in certain environments.
With this change VIntl for Nuxt now uses markers, URL parameters added to the end of imported module IDs. This allows it to very quickly test whether a specific module is imported through a message file and should be processed by the VIntl unplugin.
## 1.7.1
### Patch Changes
- 6479891: VIntl updated to the latest version
Latest version of VIntl fixes missing type declarations for global properties, like `$t`, `$fmt` and `$i18n`.
We might add automatic handling for disabling of `controllerOpts.globalMixin` in the future releases. You can follow the status update in [#74](https://github.com/vintl-dev/nuxt/issues/74).
For now, if you disable global mixin, use the below augmentation to disable these unusable properties:
```ts
declare global {
namespace VueIntlController {
interface Options {
globalMixin: false
}
}
}
```
## 1.7.0
### Minor Changes
- a9fdc59: Add support for parsing the messages in the error handlers
With [update to `@vintl/unplugin`](https://github.com/vintl-dev/unplugin/releases/tag/v1.5.0), it's now possible to use `parseMessage` from the error handler's context to parse custom messages or re-parse the current message with any modified options.
## 1.6.0
### Minor Changes
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@vintl/nuxt",
"version": "1.6.0",
"version": "1.8.0",
"description": "Nuxt Module for VIntl integration",
"keywords": [
"i18n",
@@ -34,28 +34,28 @@
"dist"
],
"scripts": {
"build": "nuxt-module-build",
"build": "nuxt-module-build build",
"lint": "eslint --cache .",
"prepack": "pnpm run -s lint && pnpm run -s build"
},
"devDependencies": {
"@nuxt/module-builder": "^0.5.2",
"@nuxt/schema": "^3.7.4",
"@types/hash-sum": "^1.0.0",
"@types/node": "^18.18.4",
"@nuxt/schema": "^3.8.0",
"@types/hash-sum": "^1.0.1",
"@types/node": "^18.18.7",
"@unhead/vue": "^1.7.4",
"@vintl-dev/eslint-config-peony": "workspace:^",
"hookable": "^5.5.3",
"prettier-plugin-jsdoc": "^1.1.0",
"prettier-plugin-jsdoc": "^1.1.1",
"typescript": "^5.2.2",
"vue-router": "^4.2.5"
},
"dependencies": {
"@formatjs/intl": "^2.9.3",
"@formatjs/intl": "^2.9.5",
"@formatjs/intl-localematcher": "^0.4.2",
"@nuxt/kit": "^3.7.4",
"@vintl/unplugin": "^1.4.1",
"@vintl/vintl": "^4.2.3",
"@nuxt/kit": "^3.8.0",
"@vintl/unplugin": "^1.5.1",
"@vintl/vintl": "^4.4.1",
"astring": "^1.8.6",
"consola": "^3.2.3",
"hash-sum": "^2.0.0",
+1 -1
View File
@@ -96,7 +96,7 @@ export default defineNuxtModule<ModuleOptions>({
return resolveInResDir(specifier).relativeTo(optionsFile.dst)
},
registerMessagesFile(file, importPath) {
pluginOptionsBank.registerFile(
return pluginOptionsBank.registerFile(
file,
resolvePath(dirname(optionsFile.dst), importPath),
)
+6 -3
View File
@@ -623,11 +623,12 @@ interface GeneratorContext {
*
* @param file Input message file options.
* @param importPath Resolved path.
* @returns Marked import path.
*/
registerMessagesFile(
file: t.output<typeof messagesImportSourceSchema>,
importPath: string,
): void
): string
/**
* Resolves a module from the runtime directory.
@@ -780,8 +781,10 @@ export function generate(
for (const messageFile of files) {
const { from: importPath, name: importKey } = messageFile
const resolvedPath = resolve(messageFile.from)
registerMessagesFile(messageFile, resolvedPath)
const resolvedPath = registerMessagesFile(
messageFile,
resolve(messageFile.from),
)
if (isDefaultLocale) {
// if import key is 'default' then:
+34 -4
View File
@@ -12,9 +12,36 @@ import type {
type UniqueOptions = t.output<typeof messagesImportOptionsSchema>
class Marker {
private readonly regExp: RegExp
public constructor(public readonly marker: string) {
this.regExp = new RegExp(`(\\?|&)${marker}(&|$)`)
}
public apply(id: string) {
return `${id}${id.includes('?') ? '&' : '?'}${this.marker}`
}
public matches(id: string) {
return this.regExp.test(id)
}
}
class MarkedFileSet extends Set<string> {
public readonly marker: Marker
constructor(marker: Marker, iterable?: Iterable<string> | null | undefined) {
super(iterable)
this.marker = marker
}
}
export class PluginOptionsBank {
// let the uniqueOptions be a map of unique options to a list of files that have the same options
private readonly filesByOptions: Map<UniqueOptions, Set<string>> = new Map()
private readonly filesByOptions = new Map<UniqueOptions, MarkedFileSet>()
private incrementingMarker = 0
private findOrCreateFileSet(optionsVariation: UniqueOptions) {
for (const [knownOptionsVariation, files] of this.filesByOptions) {
@@ -31,7 +58,9 @@ export class PluginOptionsBank {
parser: optionsVariation.parser,
}
const fileSet = new Set<string>()
const marker = new Marker(`icu-messages-${this.incrementingMarker++}`)
const fileSet = new MarkedFileSet(marker)
this.filesByOptions.set(filteredOptions, fileSet)
return fileSet
}
@@ -40,7 +69,8 @@ export class PluginOptionsBank {
file: t.output<typeof messagesImportSourceSchema>,
resolvedPath: string,
) {
this.findOrCreateFileSet(file).add(resolvedPath)
const { marker } = this.findOrCreateFileSet(file).add(resolvedPath)
return marker.apply(resolvedPath)
}
public createOptions<T extends { name: string }>(
@@ -49,7 +79,7 @@ export class PluginOptionsBank {
const options: PluginOptions<T>[] = []
for (const [{ format, parser }, files] of this.filesByOptions) {
const filter = (id: string) => files.has(id)
const filter = (id: string) => files.marker.matches(id)
options.push({
...baseOptions,
+2295 -1176
View File
File diff suppressed because it is too large Load Diff