Skip to content

Commit

Permalink
Make it work with both ESM and CJS
Browse files Browse the repository at this point in the history
  • Loading branch information
koresar committed Aug 3, 2023
1 parent 7bc85eb commit 8c7990e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "mini-graphql-http-client",
"version": "1.1.0",
"description": "Minimalistic (0 dependencies, 1Kb) GraphQL client for browsers and node.js with memory caching support",
"type": "module",
"source": "src/mini-graphql-http-client.js",
"main": "dist/mini-graphql-http-client.js",
"exports": "./dist/mini-graphql-http-client.modern.js",
"module": "dist/mini-graphql-http-client.module.js",
"unpkg": "dist/mini-graphql-http-client.umd.js",
"umd:main": "dist/mini-graphql-http-client.umd.js",
"exports": {
"require": "./dist/mini-graphql-http-client.cjs",
"default": "./dist/mini-graphql-http-client.modern.js"
},
"main": "./dist/mini-graphql-http-client.cjs",
"module": "./dist/mini-graphql-http-client.module.js",
"unpkg": "./dist/mini-graphql-http-client.umd.js",
"scripts": {
"prepublishOnly": "npm run build",
"ci": "npm i && npm t",
Expand All @@ -25,6 +28,7 @@
"http",
"minimal",
"mini",
"tiny",
"small"
],
"author": "",
Expand All @@ -37,9 +41,8 @@
"chai": "^4.2.0",
"esm": "^3.2.25",
"micro": "^9.3.4",
"microbundle": "^0.13.0",
"mocha": "^8.2.1",
"node-fetch": "^2.6.1",
"microbundle": "^0.15.1",
"mocha": "^10.2.0",
"prettier": "^2.2.1",
"test-listen": "^1.1.0"
},
Expand Down
7 changes: 4 additions & 3 deletions test/mini-graphql-http-client.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const { expect } = require("chai");
import MiniGraphqlHttpClient from "../src/mini-graphql-http-client";
import chai from "chai";
const expect = chai.expect;
import MiniGraphqlHttpClient from "../src/mini-graphql-http-client.js";

describe("MiniGraphqlHttpClient tests", () => {
describe("creating instance", () => {
it("should throw if URI or fetch was not provided", () => {
expect(() => MiniGraphqlHttpClient()).to.throw();
expect(() => MiniGraphqlHttpClient({ fetch: () => {} })).to.throw(/uri/);
expect(() => MiniGraphqlHttpClient({ uri: "a" })).to.throw(/fetch/);
expect(() => MiniGraphqlHttpClient({ uri: "a", fetch: null })).to.throw(/fetch/);
expect(() => MiniGraphqlHttpClient({ uri: "a", fetch: "not a function" })).to.throw(/fetch/);
expect(() => MiniGraphqlHttpClient({ uri: /not a string/, fetch: () => {} })).to.throw(/uri/);
expect(() => MiniGraphqlHttpClient({ uri: "my string", fetch: () => {} })).to.not.throw();
Expand Down

0 comments on commit 8c7990e

Please sign in to comment.