Skip to content

Commit

Permalink
feat: add edge-light export condition (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan authored Mar 28, 2023
1 parent a72a2b0 commit 501e7b6
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ An important note on this approach is that you cannot call `commit()` on transac
Assets can be uploaded using the `client.assets.upload(...)` method.

```
client.assets.upload(type: 'file' | image', body: File | Blob | Buffer | NodeStream, options = {}): Promise<AssetDocument>
client.assets.upload(type: 'file' | image', body: File | Blob | Buffer | NodeJS.ReadableStream, options = {}): Promise<AssetDocument>
```

👉 Read more about [assets in Sanity](https://sanity.io/docs/assets)
Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

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

23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"import": "./dist/index.browser.js"
},
"deno": "./dist/index.browser.js",
"edge-light": "./dist/index.browser.js",
"worker": "./dist/index.browser.js",
"source": "./src/index.ts",
"require": "./dist/index.cjs",
Expand Down Expand Up @@ -89,7 +90,7 @@
},
"dependencies": {
"@sanity/eventsource": "5",
"get-it": "8",
"get-it": "^8.1",
"rxjs": "7"
},
"devDependencies": {
Expand All @@ -98,11 +99,11 @@
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@sanity/pkg-utils": "^2.2.13",
"@sanity/semantic-release-preset": "^4.0.1",
"@types/node": "^18.15.3",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@vitest/coverage-c8": "^0.29.5",
"@sanity/semantic-release-preset": "^4.1.0",
"@types/node": "^18.15.10",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"@vitest/coverage-c8": "^0.29.8",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
Expand All @@ -111,14 +112,14 @@
"happy-dom": "^8.9.0",
"ls-engines": "^0.9.0",
"nock": "^13.3.0",
"prettier": "^2.8.5",
"prettier": "^2.8.7",
"prettier-plugin-packagejson": "^2.4.3",
"rimraf": "^4.4.0",
"rollup": "^3.20.0",
"rimraf": "^4.4.1",
"rollup": "^3.20.2",
"sse-channel": "^4.0.0",
"terser": "^5.16.6",
"terser": "^5.16.8",
"typescript": "^5.0.2",
"vitest": "^0.29.6",
"vitest": "^0.29.8",
"vitest-github-actions-reporter": "^0.10.0"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions runtimes/node/test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ test('top-level imports', async (t) => {
})

await t.test('the same named exports are used as ESM', async () => {
const cjs = Object.keys(require('@sanity/client'))
const esm = Object.keys(await import('@sanity/client'))
const cjs = Object.keys(require('@sanity/client')).sort()
const esm = Object.keys(await import('@sanity/client')).sort()
assert.deepEqual(cjs, esm)
})

Expand Down
2 changes: 1 addition & 1 deletion src/assets/AssetsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function _upload(
}

function optionsFromFile(opts: Record<string, Any>, file: Any) {
if (typeof window === 'undefined' || !(file instanceof window.File)) {
if (typeof File === 'undefined' || !(file instanceof File)) {
return opts
}

Expand Down
3 changes: 3 additions & 0 deletions src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ export default function deprecatedCreateClient(config: ClientConfig) {
printNoDefaultExport()
return new SanityClient(httpRequest, config)
}

/** @alpha */
export {adapter as unstable__adapter, environment as unstable__environment} from 'get-it'
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ export default function deprecatedCreateClient(config: ClientConfig) {
printNoDefaultExport()
return new SanityClient(httpRequest, config)
}

/** @alpha */
export {adapter as unstable__adapter, environment as unstable__environment} from 'get-it'
2 changes: 1 addition & 1 deletion vitest.browser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export default defineConfig({
alias: {'@sanity/client': pkg.exports['.'].browser.source},
},
resolve: {
conditions: ['browser'],
conditions: ['browser', 'module', 'import'],
},
})
3 changes: 2 additions & 1 deletion vitest.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig({
alias: {'@sanity/client': pkg.exports['.'].browser.source},
},
resolve: {
conditions: ['worker', 'browser'],
// https://github.com/vercel/next.js/blob/95322649ffb2ad0d6423481faed188dd7b1f7ff2/packages/next/src/build/webpack-config.ts#L1079-L1084
conditions: ['edge-light', 'worker', 'browser', 'module', 'import', 'node'],
},
})

0 comments on commit 501e7b6

Please sign in to comment.