Skip to content

Commit 73b74ce

Browse files
authored
feat: dynamic import, dual module (#149)
BREAKING CHANGE: must always call `await validator.init()` prior to first use, no path to sync usage remains. Furthermore instead of using require() + cache busting via delete it will now use dynamic import * feat: dynamic import for schema files, only async init * feat: dual-module * chore: increase node version for CI
1 parent ae413cc commit 73b74ce

File tree

17 files changed

+658
-3141
lines changed

17 files changed

+658
-3141
lines changed
File renamed without changes.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ lib
3434
.vscode
3535
.DS_Store
3636

37+
.tsimp
38+
.tshy
39+
.tshy-build

.semaphore/semaphore.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ global_job_config:
1414
prologue:
1515
commands:
1616
- set -e
17-
- sem-version node 18
18-
- npm i -g pnpm@8
17+
- sem-version node 20.10
18+
- corepack enable
19+
- corepack install --global [email protected]
1920
- checkout
2021
- cache restore node-$(checksum pnpm-lock.yaml)
2122
- pnpm i --frozen-lockfile --prefer-offline

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Based on the bluebird promises.
99

1010
## Installation
1111

12-
`yarn add @microfleet/validation`
12+
`npm i @microfleet/validation`
1313

1414
## Usage
1515

@@ -26,6 +26,8 @@ import Errors = require('common-errors');
2626
import Validator, { HttpStatusError } from '@microfleet/validation';
2727
const validator = new Validator('./schemas');
2828

29+
await validator.init()
30+
2931
// some logic here
3032
validator.validate('config', {
3133
configuration: 'string'

__tests__/fixtures/cjs/cjs-01.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
"$id": "cjs-01.cjs"
3+
}

__tests__/fixtures/cjs/cjs-02.cts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const $id = "cjs-02.cts"

__tests__/fixtures/cjs/cjs-03.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const $id = "cjs-03.ts"

__tests__/fixtures/esm/esm-01.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const $id = "esm-01.mjs"

__tests__/fixtures/esm/esm-02.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const $id = "esm-02.mts"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
$id: 'esm-03-defaults.mts',
3+
type: 'string'
4+
}

0 commit comments

Comments
 (0)