Compare commits

..
Author SHA1 Message Date
github-actions[bot]andSasha Sorokin f59c0af86e Version Packages 2023-06-09 19:25:11 +01:00
Sasha Sorokin 47f1739873 Fix consola not being a dep or used 2023-06-09 19:18:49 +01:00
Sasha Sorokin f62ae92791 Fix importing of no-parser alias 2023-06-09 19:05:18 +01:00
renovate[bot]andGitHub d5b7e30494 Update all non-major dependencies 2023-06-09 16:15:23 +00:00
github-actions[bot]andSasha Sorokin 1d21fc02fe Version Packages 2023-05-24 00:44:09 +02:00
Sasha Sorokin 9756d4acb9 Migrate resolving code to sync implementation 2023-05-23 23:35:42 +01:00
Sasha Sorokin 3d41dd1757 Add missing changeset for VIntl upgrade 2023-05-23 23:30:08 +01:00
renovate[bot]andGitHub 355a7d0726 Update dependency import-meta-resolve to v3 2023-05-23 21:05:49 +00:00
renovate[bot]andGitHub 1a470e9ee2 Update all non-major dependencies 2023-05-23 20:38:06 +00:00
Sasha Sorokin d36cd55167 Update astring dependency and remove patch 2023-05-23 22:32:34 +02:00
Sasha SorokinandGitHub b872f41ea1 Update dependencies (#32) 2023-05-23 22:30:13 +02:00
Sasha Sorokin 256598c87f Update @vintl/vintl to 4.2.0 2023-05-22 19:39:20 +02:00
Sasha Sorokin 19908fb197 Trigger test workflow on root pJson changes 2023-05-22 16:23:12 +02:00
Sasha Sorokin bfbcfd7c06 Add test workflow for pull requests 2023-05-22 16:03:21 +02:00
github-actions[bot]andSasha Sorokin d46362362d Version Packages 2023-05-12 20:55:47 +02:00
Sasha Sorokin 8f4ca76780 Move @nuxt/schema to devdeps 2023-05-12 17:14:52 +02:00
github-actions[bot]andSasha Sorokin 016c6938b8 Version Packages 2023-05-07 05:38:43 +02:00
Sasha Sorokin 25b5acfdd4 Don't require additionalImports to be a non-empty array 2023-05-07 05:36:36 +02:00
github-actions[bot]andSasha Sorokin 67168d2d2e Version Packages 2023-05-03 13:24:11 +02:00
Sasha Sorokin 71b900075f Fix object import sources not resolving by default 2023-05-03 13:06:40 +02:00
Sasha Sorokin 26354bacc9 Improve writing of warning about the descriptions in descriptors 2023-04-29 15:08:04 +02:00
Sasha Sorokin 566bf1561a Fix docs links after moving to Netlify 2023-04-29 14:56:09 +02:00
18 changed files with 1926 additions and 1548 deletions
+79
View File
@@ -0,0 +1,79 @@
name: Test pull request
on:
pull_request:
branches: [main, next, alpha, beta, rc]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Check changed files
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
shared: &shared
- .npmrc
- package.json
- pnpm-lock.yaml
nvintl:
- *shared
- 'packages/vintl-nuxt/**'
playground:
- *shared
- 'apps/playground/**'
- 'packages/translations/**'
docs:
- *shared
- 'apps/docs/**'
- name: Install pnpm via corepack
shell: bash
run: |
corepack enable
corepack prepare --activate
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Prepare everything
run: pnpm all:prepare
- name: Lint everything
run: pnpm all:lint
- name: Build module
if: steps.filter.outputs.nvintl == 'true'
run: pnpm mod:build
- name: Build playground
if: steps.filter.outputs.playground == 'true' || steps.filter.outputs.nvintl == 'true'
run: pnpm pg:build
- name: Build docs
if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.nvintl == 'true'
run: pnpm docs:build
+1 -1
View File
@@ -9,7 +9,7 @@ This monorepo hosts the VIntl for Nuxt module as well as other projects that hel
### Apps
- [Playground](https://github.com/vintl-dev/nuxt/tree/main/apps/playground) 🔒
- [Docs](https://github.com/vintl-dev/nuxt/tree/main/apps/docs) 🔒 [🌐](https://vintl-nuxt.vercel.app/)
- [Docs](https://github.com/vintl-dev/nuxt/tree/main/apps/docs) 🔒 [🌐](https://vintl-nuxt.netlify.app/)
### Packages
+1 -1
View File
@@ -2,7 +2,7 @@ export default defineAppConfig({
docus: {
title: 'VIntl for Nuxt',
description: 'Internationalization for your Nuxt apps',
url: 'http://vintl-nuxt.vercel.app',
url: 'https://vintl-nuxt.netlify.app',
// image: '/social-card-preview.png',
socials: {
github: 'vintl-dev/nuxt',
@@ -45,7 +45,8 @@ Message descriptors are objects that describe a message and its properties. The
- `description` (optional): A description of the message for translators.
::alert{type="warning"}
VIntl for Nuxt currently does not transpile the descriptors during the build, leaving `description` property as is, meaning they will pointlessly increase bundle size. If you really want to use them, look into wiring up [Babel plugin by FormatJS][babel_plugin].
Note that VIntl for Nuxt does not currently transpile code during the build process. This means that any `description` properties of message descriptors will remain unchanged, needlessly increasing the bundle size. If you must use `description` properties, we recommend using the [Babel plugin by FormatJS][babel_plugin] to remove them.
[babel_plugin]: https://formatjs.io/docs/tooling/babel-plugin
+7 -5
View File
@@ -13,13 +13,15 @@
"start": "node .output/server/index.mjs"
},
"devDependencies": {
"@formatjs/cli": "^6.0.4",
"@nuxt-themes/docus": "^1.10.1",
"@formatjs/cli": "^6.1.2",
"@nuxt-themes/docus": "^1.12.3",
"@nuxt/eslint-config": "^0.1.1",
"@vintl-dev/eslint-config-peony": "workspace:^",
"@vintl/nuxt": "workspace:^",
"eslint": "^8.39.0",
"nuxt": "^3.4.2",
"theme-colors": "^0.0.5"
"eslint": "^8.42.0",
"nuxi": "^3.5.3",
"nuxt": "^3.5.3",
"theme-colors": "^0.0.5",
"vue": "^3.3.4"
}
}
+3 -3
View File
@@ -17,8 +17,8 @@
"@vintl-dev/eslint-config-peony": "workspace:^",
"@vintl-dev/pg-messages": "workspace:^",
"@vintl/nuxt": "workspace:^",
"eslint": "^8.39.0",
"nuxi": "^3.4.2",
"nuxt": "^3.4.2"
"eslint": "^8.42.0",
"nuxi": "^3.5.3",
"nuxt": "^3.5.3"
}
}
+2 -5
View File
@@ -8,7 +8,7 @@
],
"devDependencies": {
"@changesets/cli": "^2.26.1",
"turbo": "^1.8.7"
"turbo": "^1.10.1"
},
"scripts": {
"pg:prepare": "turbo run --no-daemon @vintl-dev/pg#dev:prepare",
@@ -28,9 +28,6 @@
"_ci:publish": "changeset publish"
},
"pnpm": {
"patchedDependencies": {
"astring@1.8.4": "patches/astring@1.8.4.patch"
},
"packageExtensions": {
"@nuxt/kit": {
"dependencies": {
@@ -39,5 +36,5 @@
}
}
},
"packageManager": "pnpm@8.3.1"
"packageManager": "pnpm@8.6.1"
}
+7 -7
View File
@@ -26,14 +26,14 @@
"config.json"
],
"dependencies": {
"@rushstack/eslint-patch": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"eslint-plugin-vue": "^9.11.0",
"typescript": "^5.0.4"
"@rushstack/eslint-patch": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint-plugin-vue": "^9.14.1",
"typescript": "^5.1.3"
},
"devDependencies": {
"@types/eslint": "^8.37.0",
"eslint": "^8.38.0"
"@types/eslint": "^8.40.0",
"eslint": "^8.42.0"
}
}
+44
View File
@@ -1,5 +1,49 @@
# @vintl/nuxt
## 1.2.1
### Patch Changes
- f62ae92: Adapt to new export conditions of the parser
`@formatjs/icu-messageformat-parser` has been updated and now has export conditions, this change adapts and fixes the error caused by the previous direct import of the file for `no-parser` alias.
- 47f1739: Fix consola not being actually listed as a dependency or used
## 1.2.0
### Minor Changes
- 3d41dd1: Update VIntl to 4.2.0
Previously VIntl was depending on Vue directly, which caused issues, and wasn't correct, as Vue is not its implementation detail. 4.2.0 made Vue a peer dependency, fixing this issue. It also brought updates to other dependencies like `@formatjs/intl`.
### Patch Changes
- 9756d4a: Upgrade `import-meta-resolve` to v3
## 1.1.4
### Patch Changes
- 8f4ca76: Fix compatibility with newer versions of Nuxt
It seems that TypeScript has a trouble identifying similar types from different packages, which caused it to disregard any types from VIntl.
Now that the `@nuxt/schema` is moved to `devDependencies` (since it's used for types only anyway), and doesn't have to strictly match the version, this should be fixed.
## 1.1.3
### Patch Changes
- 25b5acf: Don't require additionalImports to be a non-empty array
## 1.1.2
### Patch Changes
- 71b9000: Fix object import sources not resolving by default
## 1.1.1
### Patch Changes
+1 -1
View File
@@ -36,7 +36,7 @@ Store your users preferences with cookies, localStorage, or with the custom stor
## Documentation
Check out the [VIntl for Nuxt documentation site](https://vintl-nuxt.vercel.app/) for detailed usage instructions and examples.
Check out the [VIntl for Nuxt documentation site](https://vintl-nuxt.netlify.app/) for detailed usage instructions and examples.
## Credits
+15 -14
View File
@@ -1,6 +1,6 @@
{
"name": "@vintl/nuxt",
"version": "1.1.1",
"version": "1.2.1",
"description": "Nuxt Module for VIntl integration",
"keywords": [
"i18n",
@@ -39,27 +39,28 @@
"prepack": "pnpm run -s lint && pnpm run -s build"
},
"devDependencies": {
"@nuxt/module-builder": "^0.3.0",
"@nuxt/module-builder": "^0.4.0",
"@nuxt/schema": "^3.5.3",
"@types/hash-sum": "^1.0.0",
"@types/node": "^18.15.12",
"@unhead/vue": "^1.1.26",
"@types/node": "^18.16.16",
"@unhead/vue": "^1.1.27",
"@vintl-dev/eslint-config-peony": "workspace:^",
"hookable": "^5.5.3",
"prettier-plugin-jsdoc": "^0.4.2",
"typescript": "^5.0.4"
"typescript": "^5.1.3"
},
"dependencies": {
"@formatjs/intl": "^2.7.1",
"@nuxt/kit": "^3.4.2",
"@nuxt/schema": "^3.4.2",
"@formatjs/intl": "^2.8.0",
"@nuxt/kit": "^3.5.3",
"@vintl/unplugin": "^1.2.1",
"@vintl/vintl": "^4.1.2",
"astring": "^1.8.4",
"@vintl/vintl": "^4.2.0",
"astring": "^1.8.6",
"hash-sum": "^2.0.0",
"import-meta-resolve": "^2.2.2",
"pathe": "^1.1.0",
"import-meta-resolve": "^3.0.0",
"pathe": "^1.1.1",
"picocolors": "^1.0.0",
"slash": "^5.0.0",
"zod": "^3.21.4"
"slash": "^5.1.0",
"zod": "^3.21.4",
"consola": "^3.1.0"
}
}
+12 -16
View File
@@ -21,7 +21,7 @@ import { moduleOptionsSchema } from './schemas/index.js'
import { PluginOptionsBank } from './parser-bank.js'
import { formatZodError } from './utils/zod-error.js'
import { OptionsError } from './errors.js'
import * as consola from 'console'
import { consola } from 'consola'
/** Path to the options file relative to `buildDir`. */
const optionsFilePath = 'i18n/options.mjs'
@@ -48,7 +48,7 @@ export default defineNuxtModule<InputModuleOptions>({
const resolveInRuntime = createDirResolver(runtimeDir)
addPlugin((await resolveInRuntime('./plugin.js')).path)
addPlugin(resolveInRuntime('./plugin.js').path)
if (!nuxt.options._prepare) {
let options: t.output<typeof moduleOptionsSchema>
@@ -86,16 +86,14 @@ export default defineNuxtModule<InputModuleOptions>({
const optionsFile = addTemplate({
filename: optionsFilePath,
write: true,
async getContents() {
getContents() {
const resolveInResDir = createDirResolver(
resolvePath(nuxt.options.srcDir, options.resolveDir ?? '.'),
)
return await generateOptions(options, {
async resolve(specifier) {
return (await resolveInResDir(specifier)).relativeTo(
optionsFile.dst,
)
return generateOptions(options, {
resolve(specifier) {
return resolveInResDir(specifier).relativeTo(optionsFile.dst)
},
registerMessagesFile(file, importPath) {
pluginOptionsBank.registerFile(
@@ -103,10 +101,8 @@ export default defineNuxtModule<InputModuleOptions>({
resolvePath(dirname(optionsFile.dst), importPath),
)
},
async resolveRuntimeModule(specifier) {
return (await resolveInRuntime(specifier)).relativeTo(
optionsFile.dst,
)
resolveRuntimeModule(specifier) {
return resolveInRuntime(specifier).relativeTo(optionsFile.dst)
},
state: {
parserlessModeEnabled,
@@ -161,12 +157,12 @@ export default defineNuxtModule<InputModuleOptions>({
if (Array.isArray(aliases)) {
aliases.push({
find: '@formatjs/icu-messageformat-parser',
replacement: '@formatjs/icu-messageformat-parser/lib/no-parser',
replacement: '@formatjs/icu-messageformat-parser/no-parser',
})
} else {
Object.assign(aliases, {
'@formatjs/icu-messageformat-parser':
'@formatjs/icu-messageformat-parser/lib/no-parser',
'@formatjs/icu-messageformat-parser/no-parser',
})
}
})
@@ -176,11 +172,11 @@ export default defineNuxtModule<InputModuleOptions>({
if (Array.isArray(aliases)) {
aliases.push({
name: '@formatjs/icu-messageformat-parser',
alias: '@formatjs/icu-messageformat-parser/lib/no-parser',
alias: '@formatjs/icu-messageformat-parser/no-parser',
})
} else {
aliases['@formatjs/icu-messageformat-parser'] =
'@formatjs/icu-messageformat-parser/lib/no-parser'
'@formatjs/icu-messageformat-parser/no-parser'
}
})
}
+10 -12
View File
@@ -616,7 +616,7 @@ interface GeneratorContext {
* @param specifier Module import specifier.
* @returns Path relative to the options file.
*/
resolve(specifier: string): Promise<string>
resolve(specifier: string): string
/**
* Analytical method that is called for every generated messages import.
@@ -635,7 +635,7 @@ interface GeneratorContext {
* @param specifier Module import specifier.
* @returns Path relative to the optons file.
*/
resolveRuntimeModule(specifier: string): Promise<string>
resolveRuntimeModule(specifier: string): string
/** Additional state to encode which is not included in the options. */
state: {
@@ -649,7 +649,7 @@ interface GeneratorContext {
* then renders it to actual JavaScript code. The resulting code can be written
* to a special file and read at runtime to retrieve the options.
*/
export async function generate(
export function generate(
opts: t.output<typeof moduleOptionsSchema>,
{
resolve,
@@ -697,7 +697,7 @@ export async function generate(
imports.push(
new ImportDeclaration(
new Literal(await resolveRuntimeModule('./utils/locale-loader.js')),
new Literal(resolveRuntimeModule('./utils/locale-loader.js')),
)
.addSpecifier(id$defineLocale)
.addSpecifier(id$rawValue),
@@ -780,7 +780,7 @@ export async function generate(
for (const messageFile of files) {
const { from: importPath, name: importKey } = messageFile
const resolvedPath = await resolve(messageFile.from)
const resolvedPath = resolve(messageFile.from)
registerMessagesFile(messageFile, resolvedPath)
if (isDefaultLocale) {
@@ -830,7 +830,7 @@ export async function generate(
for (const import_ of locale.additionalImports ?? []) {
const resolvedPath = import_.resolve
? await resolve(import_.from)
? resolve(import_.from)
: import_.from
if (isDefaultLocale) {
@@ -857,9 +857,7 @@ export async function generate(
resolve: shouldResolve,
} = dataImport
const resolvedPath = shouldResolve
? await resolve(importPath)
: importPath
const resolvedPath = shouldResolve ? resolve(importPath) : importPath
if (isDefaultLocale) {
// if import key is 'default' then:
@@ -984,11 +982,11 @@ export async function generate(
let storage = opts.storage
if (storage === 'localStorage') {
storage = await resolveRuntimeModule('./storage/local-storage.js')
storage = resolveRuntimeModule('./storage/local-storage.js')
} else if (storage === 'cookie') {
storage = await resolveRuntimeModule('./storage/cookie.js')
storage = resolveRuntimeModule('./storage/cookie.js')
} else {
storage = await resolve(storage)
storage = resolve(storage)
}
exports.push(
+1 -1
View File
@@ -16,7 +16,7 @@ export const importSourceObjectSchema = t.object({
.default('default'),
/** Whether to resolve the import to a path or import as is. */
resolve: t.boolean().optional(),
resolve: t.boolean().default(true),
})
/** A schema for the tuple consisting of an import path and a custom export name. */
@@ -68,7 +68,6 @@ export const localeDescriptorSchema = t
.describe(
'List of additional side-effect only imports (like polyfill data)',
)
.nonempty()
.optional(),
/**
+2 -2
View File
@@ -6,8 +6,8 @@ import slash from 'slash'
export function createDirResolver(dir: string) {
const pseudoParent = pathToFileURL(joinPaths(dir, '.resolve-root')).toString()
return async function resolve(specifier: string) {
const resolved = await rawResolve(specifier, pseudoParent)
return function resolve(specifier: string) {
const resolved = rawResolve(specifier, pseudoParent)
return {
/** A getter that returns resolved URL as is. */
-12
View File
@@ -1,12 +0,0 @@
diff --git a/package.json b/package.json
index 55da8ad891741382b793f105b328b77997fab1de..d714282fd3742d377fe05db58bc00460ae44cdb6 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"module": "./dist/astring.mjs",
"types": "./astring.d.ts",
"exports": {
+ "types": "./astring.d.ts",
"import": "./dist/astring.mjs",
"require": "./dist/astring.js",
"browser": "./dist/astring.min.js"
+1739 -1466
View File
File diff suppressed because it is too large Load Diff