-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: The package is now exported as ESM module.
- Loading branch information
Showing
10 changed files
with
160 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
jest-*.ts | ||
docs | ||
jest.config.js | ||
rollup.config.js | ||
dist | ||
coverage | ||
__tests__/bench.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
/* eslint-disable import/dynamic-import-chunkname */ | ||
import Fs from 'fs'; | ||
import { resolve, extname } from 'path'; | ||
import Path, { resolve, extname } from 'path'; | ||
import Url from 'url'; | ||
|
||
describe('check exports', () => { | ||
describe('validators', () => { | ||
const validatorsDir = Fs.readdirSync(resolve(__dirname, '..', 'src', 'validators')); | ||
const validatorsDir = Fs.readdirSync( | ||
resolve(Path.dirname(Url.fileURLToPath(import.meta.url)), '..', 'src', 'validators'), | ||
); | ||
const validators = validatorsDir | ||
.filter((filename) => !filename.startsWith('__')) | ||
.map((name) => (extname(name).length ? name.slice(0, -extname(name).length) : name)); | ||
|
||
validators.forEach((v) => { | ||
it(`${v} should be exported from index.ts`, async () => | ||
expect(Object.keys(await import('../src/index'))).toContain(v)); | ||
}); | ||
it.each(validators)(`%s should be exported from index.ts`, async (v) => | ||
expect(Object.keys(await import('../src/index'))).toContain(v), | ||
); | ||
}); | ||
|
||
describe('modifiers', () => { | ||
const modifiersDir = Fs.readdirSync(resolve(__dirname, '..', 'src', 'modifiers')); | ||
const modifiersDir = Fs.readdirSync( | ||
resolve(Path.dirname(Url.fileURLToPath(import.meta.url)), '..', 'src', 'modifiers'), | ||
); | ||
const modifiers = modifiersDir | ||
.filter((filename) => !filename.startsWith('__')) | ||
.map((name) => (extname(name).length ? name.slice(0, -extname(name).length) : name)); | ||
|
||
modifiers.forEach((v) => { | ||
it(`${v} should be exported from index.ts`, async () => | ||
expect(Object.keys(await import('../src/index'))).toContain(v)); | ||
}); | ||
it.each(modifiers)(`%s should be exported from index.ts`, async (v) => | ||
expect(Object.keys(await import('../src/index'))).toContain(v), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { jest } from '@jest/globals'; | ||
import Qs from 'qs'; | ||
|
||
import type { SomeSchema } from '../src'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
module.exports = { | ||
export default { | ||
roots: ['<rootDir>'], | ||
setupFiles: ['<rootDir>/jest.setup.js'], | ||
moduleFileExtensions: ['js', 'ts', 'json'], | ||
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules)[/\\\\]'], | ||
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
// '^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'], | ||
setupFiles: ['./jest-setup.ts'], | ||
setupFilesAfterEnv: ['./jest-setup-after-env.ts'], | ||
extensionsToTreatAsEsm: ['.ts'], | ||
preset: 'ts-jest/presets/default-esm', | ||
globals: { | ||
'ts-jest': { | ||
useESM: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
{ | ||
"name": "@typeofweb/schema", | ||
"version": "0.8.0-2", | ||
"main": "dist/index.common.js", | ||
"module": "dist/index.esm.js", | ||
"type": "module", | ||
"exports": { | ||
"import": "./dist/index.mjs", | ||
"default": "./dist/index.mjs", | ||
"require": "./dist/index.cjs", | ||
"browser": "./dist/index.umd.js" | ||
}, | ||
"main": "./dist/index.cjs", | ||
"browser": "dist/index.umd.js", | ||
"unpkg": "dist/index.umd.js", | ||
"types": "dist/index.d.ts", | ||
|
@@ -15,7 +21,7 @@ | |
"author": "Michał Miszczyszyn - Type of Web <[email protected]> (https://typeofweb.com/)", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">12.0.0" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
|
@@ -41,6 +47,7 @@ | |
"@tsconfig/node12": "1.0.7", | ||
"@tsconfig/node14": "1.0.0", | ||
"@types/jest": "26.0.23", | ||
"@types/node": "12", | ||
"@types/qs": "6.9.6", | ||
"@types/ramda": "0.27.40", | ||
"@typescript-eslint/eslint-plugin": "4.26.1", | ||
|
@@ -50,6 +57,7 @@ | |
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-functional": "3.2.1", | ||
"eslint-plugin-import": "2.23.4", | ||
"eslint-plugin-unicorn": "33.0.1", | ||
"fast-check": "2.16.0", | ||
"husky": "6.0.0", | ||
"jest": "27.0.4", | ||
|
@@ -71,8 +79,8 @@ | |
}, | ||
"scripts": { | ||
"prejest": "yarn build", | ||
"jest": "jest", | ||
"test": "yarn jest --detectOpenHandles --forceExit --passWithNoTests --coverage", | ||
"jest": "NODE_OPTIONS=--experimental-vm-modules jest", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules yarn jest --detectOpenHandles --forceExit --passWithNoTests --coverage", | ||
"test:dev": "yarn jest --watch", | ||
"build": "rimraf dist && rollup --config", | ||
"build:watch": "rollup --config --watch", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
d88685b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: