Compare commits

...
13 changed files with 1515 additions and 1346 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
+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.1",
"@nuxt-themes/docus": "^1.12.0",
"@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.41.0",
"nuxi": "^3.5.1",
"nuxt": "^3.5.1",
"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.41.0",
"nuxi": "^3.5.1",
"nuxt": "^3.5.1"
}
}
+2 -5
View File
@@ -8,7 +8,7 @@
],
"devDependencies": {
"@changesets/cli": "^2.26.1",
"turbo": "^1.8.7"
"turbo": "^1.9.8"
},
"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.5.1"
}
+4 -4
View File
@@ -27,13 +27,13 @@
],
"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-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"eslint-plugin-vue": "^9.13.0",
"typescript": "^5.0.4"
},
"devDependencies": {
"@types/eslint": "^8.37.0",
"eslint": "^8.38.0"
"eslint": "^8.41.0"
}
}
+28
View File
@@ -1,5 +1,33 @@
# @vintl/nuxt
## 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
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@vintl/nuxt",
"version": "1.1.2",
"version": "1.2.0",
"description": "Nuxt Module for VIntl integration",
"keywords": [
"i18n",
@@ -39,27 +39,27 @@
"prepack": "pnpm run -s lint && pnpm run -s build"
},
"devDependencies": {
"@nuxt/module-builder": "^0.3.0",
"@nuxt/module-builder": "^0.3.1",
"@nuxt/schema": "^3.5.0",
"@types/hash-sum": "^1.0.0",
"@types/node": "^18.15.12",
"@unhead/vue": "^1.1.26",
"@types/node": "^18.16.13",
"@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"
},
"dependencies": {
"@formatjs/intl": "^2.7.1",
"@nuxt/kit": "^3.4.2",
"@nuxt/schema": "^3.4.2",
"@formatjs/intl": "^2.7.2",
"@nuxt/kit": "^3.5.0",
"@vintl/unplugin": "^1.2.1",
"@vintl/vintl": "^4.1.2",
"astring": "^1.8.4",
"@vintl/vintl": "^4.2.0",
"astring": "^1.8.5",
"hash-sum": "^2.0.0",
"import-meta-resolve": "^2.2.2",
"import-meta-resolve": "^3.0.0",
"pathe": "^1.1.0",
"picocolors": "^1.0.0",
"slash": "^5.0.0",
"slash": "^5.1.0",
"zod": "^3.21.4"
}
}
+7 -11
View File
@@ -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,
+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(
@@ -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"
+1362 -1280
View File
File diff suppressed because it is too large Load Diff