Skip to content

Commit

Permalink
Merge pull request #180 from hckrnews/feature/commonjs
Browse files Browse the repository at this point in the history
Fix exports and imports
  • Loading branch information
w3nl authored Dec 2, 2022
2 parents bd5bcee + 329cbe9 commit aad476a
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For all posibilities, check the validation package readme.

Example usage:
```javascript
import Obj from '@hckrnews/objects'
import { Obj } from '@hckrnews/objects'

const addressSchema = {
street: String,
Expand Down Expand Up @@ -64,7 +64,7 @@ console.log(myAddress)
You can also define sub schemas:

```javascript
import Obj from '@hckrnews/objects'
import { Obj } from '@hckrnews/objects'

const filterSchema = {
key: String,
Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hckrnews/objects",
"description": "Create valid JavaScript objects",
"version": "6.0.0",
"version": "6.0.1",
"author": {
"name": "Pieter Wigboldus",
"url": "https://hckr.news/"
Expand Down Expand Up @@ -31,18 +31,19 @@
"dist/objects.umd.cjs",
"dist/objects.umd.cjs.map"
],
"main": "dist/objects.js",
"main": "dist/objects.umd.cjs",
"source": "src/objects.js",
"module": "dist/objects.module.mjs",
"unpkg": "dist/objects.umd.cjs",
"umd:main": "dist/objects.umd.cjs",
"exports": {
"node": {
"default": "./dist/objects.umd.cjs",
"module": "./src/objects.js",
"require": "./dist/objects.umd.cjs"
},
"require": "./dist/objects.umd.cjs",
"default": "./src/objects.js"
"default": "./dist/objects.umd.cjs"
},
"devDependencies": {
"@hckrnews/eslint-config": "^2.1.2",
Expand Down Expand Up @@ -70,8 +71,8 @@
"flat"
],
"dependencies": {
"@hckrnews/error": "^1.0.0",
"@hckrnews/validator": "^8.0.1"
"@hckrnews/error": "^1.0.1",
"@hckrnews/validator": "^8.0.5"
},
"funding": {
"type": "github",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/create-all.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const schema = {
sku: String,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/every-object.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const testSchema = {
a: Number,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/filter-objects.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const testSchema = {
a: Number,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/int.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-new */
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import Int from '../int.js';

test('Test int.js', async (t) => {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/map-objects.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const testSchema = {
a: Number,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/new-objects.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const ObjectWithoutSchema = Obj();

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/parse-all.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const schema = {
sku: Number,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/parse-object.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';
import Int from '../int.js';

const subSchema = {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/parser.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-new */
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import Parser from '../parser.js';

const testSchema = {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/some-object.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

const testSchema = {
a: Number,
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/validate-objects.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable max-statements */
/* eslint-disable no-new */
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';
import test1Schema from '../schemas/test1.js';
import Test2 from '../schemas/test2.js';

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/validate-sub-objects.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'assert';
import Obj from '../objects.js';
import assert from 'node:assert';
import { Obj } from '../objects.js';

test('Object test', async (t) => {
const CountrySchema = {
Expand Down
4 changes: 2 additions & 2 deletions src/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,5 +603,5 @@ const ObjectGenerator = ({ schema } = {}) =>
return data.map((item) => Obj.parse(item));
}
};
export default ObjectGenerator;
export { Parser, Int };

export { ObjectGenerator as Obj, Parser, Int };

0 comments on commit aad476a

Please sign in to comment.