Skip to content

Commit

Permalink
feat: 🎸 add runtime typings
Browse files Browse the repository at this point in the history
✅ Closes: Closes #43
  • Loading branch information
kaisermann committed Jan 23, 2020
1 parent 107eec0 commit dadeaa2
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
*.log
dist/
coverage/
coverage/
types/
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "svelte-i18n",
"version": "2.2.4",
"main": "dist/i18n.cjs.js",
"module": "dist/i18n.esm.js",
"main": "dist/runtime.cjs.js",
"module": "dist/runtime.esm.js",
"types": "types/runtime/index.d.ts",
"bin": {
"svelte-i18n": "dist/cli.js"
},
Expand All @@ -21,21 +22,26 @@
"node": ">= 11.15.0"
},
"scripts": {
"clean": "rm -rf dist/ types/",
"build": "rollup -c",
"build:types": "tsc -p src/runtime --emitDeclarationOnly",
"dev": "rollup -c -w",
"pretest": "npm run build",
"test": "jest",
"test:ci": "jest --silent",
"test:watch": "jest --verbose --watchAll",
"lint": "eslint \"src/**/*.ts\"",
"format": "prettier --loglevel silent --write \"src/**/*.ts\" && eslint --fix \"src/**/*.ts\"",
"prerelease": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1 && git add CHANGELOG.md",
"release": " git add package.json && git commit -m \"chore(release): v$npm_package_version :tada:\"",
"pretest": "npm run build",
"prebuild": "yarn clean",
"postbuild": "yarn build:types",
"prerelease": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1 && git add CHANGELOG.md",
"postrelease": "git tag -a v$npm_package_version -m 'Release v$npm_package_version'",
"prepublishOnly": "run-s test:ci build release"
},
"files": [
"dist/"
"dist/",
"types/"
],
"jest": {
"collectCoverage": true,
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const PROD = !process.env.ROLLUP_WATCH

export default [
{
input: 'src/client/index.ts',
input: 'src/runtime/index.ts',
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
Expand Down
66 changes: 0 additions & 66 deletions src/client/types/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions src/runtime/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "../../types/runtime"
},
"include": ["."]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
getOptions,
defaultOptions,
defaultFormats,
} from '../../src/client/configs'
import { $locale } from '../../src/client/stores/locale'
} from '../../src/runtime/configs'
import { $locale } from '../../src/runtime/stores/locale'

beforeEach(() => {
init(defaultOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getTimeFormatter,
getMessageFormatter,
init
} from '../../../src/client'
} from '../../../src/runtime'

beforeEach(() => {
init({ fallbackLocale: undefined })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
flush,
registerLocaleLoader,
resetQueues,
} from '../../../src/client/includes/loaderQueue'
import { getMessageFromDictionary } from '../../../src/client/stores/dictionary'
import { $isLoading } from '../../../src/client/stores/loading'
import { getOptions } from '../../../src/client/configs'
} from '../../../src/runtime/includes/loaderQueue'
import { getMessageFromDictionary } from '../../../src/runtime/stores/dictionary'
import { $isLoading } from '../../../src/runtime/stores/loading'
import { getOptions } from '../../../src/runtime/configs'

beforeEach(() => {
resetQueues()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lookup, lookupCache } from '../../../src/client/includes/lookup'
import { $dictionary, addMessages } from '../../../src/client/stores/dictionary'
import { lookup, lookupCache } from '../../../src/runtime/includes/lookup'
import { $dictionary, addMessages } from '../../../src/runtime/stores/dictionary'

beforeEach(() => {
$dictionary.set({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
upper,
lower,
flatObj,
} from '../../../src/client/includes/utils'
} from '../../../src/runtime/includes/utils'

describe('getting client locale', () => {
beforeEach(() => {
Expand Down
10 changes: 5 additions & 5 deletions test/client/index.test.ts → test/runtime/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineMessages, waitLocale, register, init } from '../../src/client'
import { $locale } from '../../src/client/stores/locale'
import { hasLocaleQueue } from '../../src/client/includes/loaderQueue'
import { defineMessages, waitLocale, register, init } from '../../src/runtime'
import { $locale } from '../../src/runtime/stores/locale'
import { hasLocaleQueue } from '../../src/runtime/includes/loaderQueue'
import {
getLocaleDictionary,
$dictionary,
} from '../../src/client/stores/dictionary'
import { $format } from '../../src/client/stores/format'
} from '../../src/runtime/stores/dictionary'
import { $format } from '../../src/runtime/stores/format'

test('defineMessages returns the identity of its first argument', () => {
const obj = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
$dictionary,
$locales,
getLocaleDictionary,
} from '../../../src/client/stores/dictionary'
} from '../../../src/runtime/stores/dictionary'

beforeEach(() => {
$dictionary.set({})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Formatter } from '../../../src/client/types/index'
import { $format } from '../../../src/client/stores/format'
import { init } from '../../../src/client/configs'
import { addMessages } from '../../../src/client/stores/dictionary'
import { $locale } from '../../../src/client/stores/locale'
import { Formatter } from '../../../src/runtime/types/index'
import { $format } from '../../../src/runtime/stores/format'
import { init } from '../../../src/runtime/configs'
import { addMessages } from '../../../src/runtime/stores/dictionary'
import { $locale } from '../../../src/runtime/stores/locale'

let format: Formatter
$format.subscribe(f => (format = f))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { get } from 'svelte/store'

import { lookup } from '../../../src/client/includes/lookup'
import { lookup } from '../../../src/runtime/includes/lookup'
import {
isFallbackLocaleOf,
getFallbackOf,
getRelatedLocalesOf,
getCurrentLocale,
$locale,
isRelatedLocale,
} from '../../../src/client/stores/locale'
import { getOptions, init } from '../../../src/client/configs'
import { register } from '../../../src/client'
import { hasLocaleQueue } from '../../../src/client/includes/loaderQueue'
} from '../../../src/runtime/stores/locale'
import { getOptions, init } from '../../../src/runtime/configs'
import { register } from '../../../src/runtime'
import { hasLocaleQueue } from '../../../src/runtime/includes/loaderQueue'

beforeEach(() => {
init({ fallbackLocale: undefined })
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
"lib": ["es2018", "dom", "esnext"],
"outDir": "dist",
"types": ["svelte", "jest"]
},
"exclude": ["node_modules/**/*", "dist"]
}
}

0 comments on commit dadeaa2

Please sign in to comment.