Skip to content

Commit

Permalink
feat: make package hybrid ESM/CJS closes #192 (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Feb 18, 2023
1 parent 4302ba1 commit cb79d67
Show file tree
Hide file tree
Showing 37 changed files with 945 additions and 2,479 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
.idea
dist
build
.DS_Store
*.log
coverage
coverage
2 changes: 0 additions & 2 deletions .npmignore

This file was deleted.

3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
build
pnpm-lock.yaml
coverage
2 changes: 1 addition & 1 deletion examples/authentication-via-http-header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphQLClient } from '../src'
import { GraphQLClient } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/batching-requests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { batchRequests } from '../src'
import { batchRequests } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.spacex.land/graphql/'

Expand Down
2 changes: 1 addition & 1 deletion examples/cookie-support-for-node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;(global as any).fetch = require('fetch-cookie/node-fetch')(require('node-fetch'))

import { GraphQLClient } from '../src'
import { GraphQLClient } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/custom-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from 'cross-fetch'
import { GraphQLClient } from '../src'
import { GraphQLClient } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/error-handling.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { request } from '../src'
import { request } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/passing-custom-header-per-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphQLClient } from '../src'
import { GraphQLClient } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/passing-more-options-to-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphQLClient } from '../src'
import { GraphQLClient } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/receiving-a-raw-response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rawRequest } from '../src'
import { rawRequest } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
2 changes: 1 addition & 1 deletion examples/typed-document-node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TypedDocumentNode } from '@graphql-typed-document-node/core'
import { parse } from 'graphql'

import { request, GraphQLClient } from '../src'
import { request, GraphQLClient } from '../src/index.js'
;(async function () {
const endpoint = 'https://graphql-yoga.com/api/graphql'

Expand Down
2 changes: 1 addition & 1 deletion examples/using-variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { request } from '../src'
import { request } from '../src/index.js'
;(async function () {
const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'

Expand Down
32 changes: 21 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
{
"name": "graphql-request",
"version": "0.0.0-dripip",
"type": "module",
"exports": {
".": {
"require": {
"types": "./build/cjs/index.d.ts",
"default": "./build/cjs/index.js"
},
"import": {
"types": "./build/esm/index.d.ts",
"default": "./build/esm/index.js"
}
}
},
"types": "./build/esm/index.d.ts",
"packageManager": "pnpm@7.27.0",
"main": "dist/index.js",
"files": [
"dist",
"build",
"src"
],
"bundlesize": [
{
"path": "./dist/index.js",
"maxSize": "15 kB"
}
],
"repository": {
"type": "git",
"url": "https://github.com/jasonkuhrt/graphql-request.git"
Expand All @@ -21,8 +28,7 @@
"graphql",
"request",
"fetch",
"graphql-client",
"apollo"
"graphql-client"
],
"author": {
"name": "Jason Kuhrt",
Expand All @@ -41,7 +47,10 @@
"check:types": "pnpm tsc --noEmit",
"check:format": "prettier --check .",
"prepublishOnly": "pnpm build",
"build": "rm -rf dist && tsc --project tsconfig.build.json",
"build": "pnpm clean && pnpm build:cjs && pnpm build:esm",
"build:cjs": "pnpm tsc --project tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > build/cjs/package.json",
"build:esm": "pnpm tsc --project tsconfig.esm.json",
"clean": "tsc --build --clean && rm -rf build",
"test": "vitest",
"test:coverage": "pnpm test -- --coverage",
"release:stable": "dripip stable",
Expand All @@ -59,6 +68,7 @@
},
"devDependencies": {
"@prisma-labs/prettier-config": "^0.1.0",
"@tsconfig/node16": "^1.0.3",
"@types/body-parser": "^1.19.2",
"@types/express": "^4.17.16",
"@types/extract-files": "^8.1.1",
Expand Down
Loading

0 comments on commit cb79d67

Please sign in to comment.