Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: issue with isolateModules flag (#3495)
Browse files Browse the repository at this point in the history
Fixes #3494
Fixes #3498

It appears that `react-scripts` swaps `isolateModules` which [causes problems in webui](ipfs/ipfs-webui#1655 (comment)) because according to TS:

> Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.  TS1205

Changes here address that problem as follows:

- `export type {...}` is used as per TS error.
- `isolateModules` flag is set to `true` so that such issues can be caught locally.
- Setting flags seems to have triggered problems in `ipfs-client`, so I had to add some type annotations to fix that.
- Added `references` in `ipfs-client/tsconfig.json`, otherwise it does not pick up changes in the dependencies unless they are manually rebuild.
  • Loading branch information
Gozala committed Jan 22, 2021
1 parent 43d5bb0 commit 839e190
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/ipfs-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
]
}
},
"eslintConfig": {
"extends": "ipfs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/js-ipfs.git"
Expand Down
8 changes: 8 additions & 0 deletions packages/ipfs-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ const httpClient = require('ipfs-http-client')
const grpcClient = require('ipfs-grpc-client')
const mergeOptions = require('merge-options')

/**
* @typedef {import('ipfs-http-client/src/lib/core').ClientOptions} HTTPOptions
* @typedef {import('ipfs-grpc-client/src/index').Options} GRPCOptions
* @typedef {string|URL|import('multiaddr')} Address
* @typedef {{http?: Address, grpc?: Address} & Partial<HTTPOptions & GRPCOptions>} Options
*
* @param {Options} [opts]
*/
module.exports = function createClient (opts = {}) {
const clients = []

Expand Down
8 changes: 8 additions & 0 deletions packages/ipfs-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
"compilerOptions": {
"outDir": "dist"
},
"references": [
{
"path": "../ipfs-http-client"
},
{
"path": "../ipfs-grpc-client"
}
],
"include": [
"src",
"package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-core-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RootAPI } from './root'
import { AbortOptions, Await, AwaitIterable } from './basic'

export {
export type {
RootAPI,

AbortOptions,
Expand Down
3 changes: 3 additions & 0 deletions packages/ipfs-grpc-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@
"rimraf": "^3.0.2",
"sinon": "^9.0.3",
"typescript": "4.0.x"
},
"eslintConfig": {
"extends": "ipfs"
}
}
8 changes: 5 additions & 3 deletions packages/ipfs-grpc-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ function normaliseUrls (opts) {
* @typedef {import('http').Agent} HttpAgent
* @typedef {import('https').Agent} HttpsAgent
*
* @param {object} opts
* @param {string} opts.url - The URL to connect to as a URL or Multiaddr
* @param {HttpAgent|HttpsAgent} [opts.agent] - http.Agent used to control HTTP client behaviour (node.js only)
* @typedef {Object} Options
* @property {string|URL|import('multiaddr')} url - The URL to connect to as a URL or Multiaddr
* @property {HttpAgent|HttpsAgent} [agent] - http.Agent used to control HTTP client behaviour (node.js only)
*
* @param {Options} [opts]
*/
module.exports = function createClient (opts = { url: '' }) {
opts.url = toUrlString(opts.url)
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"stripInternal": true,
"resolveJsonModule": true,
"incremental": true,
"isolatedModules": true,
"baseUrl": ".",
"paths": {
"interface-ipfs-core/*": [
Expand Down

0 comments on commit 839e190

Please sign in to comment.