Do you want to request a _feature_ or report a _bug_?
bug
What is the current behavior?
If I import a module from fp-ts/es6 and also another module that indirectly imports the same module but from fp-ts/lib, the tsc compiler goes crazy and eventually crashes with a heap allocation failure (often after several minutes).
I've found this when using both io-ts and fp-ts-rxjs.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://codesandbox.io/ or similar.
import {observable} from 'fp-ts-rxjs/lib/Observable'
import {right} from 'fp-ts/es6/Either'
What is the expected behavior?
not to crash!
Which versions of fp-ts, and which browser and OS are affected by this issue? Did this work in previous versions of fp-ts?
fp-ts: 1.17.3
fp-ts-rxjs: 0.5.1
io-ts: 1.8.5
I think i may have found a work-around, by setting a path in the tsconfig...
{
"compilerOptions": {
"paths": {
"fp-ts/lib/*": [ "node_modules/fp-ts/es6/*" ],
"*": [ "node_modules/*" ]
}
}
I'll see how it goes with this and report back.
So, i can confirm this fixes all the crashes i had when mixing io-ts or fp-ts-rxjs with fp-ts/es6 modules.
Maybe it's something that could be added to the caveats of the es6 module usage in case anyone hits the problem.
Oh, and on the issue of es6 caveats, regarding jest, you need to add the follow jest config...
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!(fp-ts/es6)/)"
],
@jollytoad Thanks for your tsconfig.json work-around ("fp-ts/lib/*": [ "node_modules/fp-ts/es6/*" ]).
This in fact, fixes much more than the tsc crashing that you experienced. In my app which uses webpack to bundle, it also fixes inconsistencies which otherwise end up in the bundle!
For example, if I have a project that uses io-ts, and I import from io-ts/es6 and call the decode method on a runtime type, I get an Either return type. When I analyse this with webpack-bundle-analyzer, I see this (io-ts v1):

Ouch! I'm importing from io-ts/es6 but am getting fp-ts/lib in the bundle. After your fix, I see

Much better!
Similar with io-ts v2. Before:

After:

Also much better!
This says to me that something is somewhere wrong with the es6 bundling in the fp-ts ecosystem, but at this moment I've no idea how it can be resolved. All I know is that if I import from io-ts/es6, I'd ideally like fp-ts/es6 in my bundle.
Your work-around works well enough for me though ;-)
So, i can confirm this fixes all the crashes i had when mixing io-ts or fp-ts-rxjs with fp-ts/es6 modules.
Maybe it's something that could be added to the caveats of the es6 module usage in case anyone hits the problem.
Oh, and on the issue of es6 caveats, regarding jest, you need to add the follow jest config...
"transformIgnorePatterns": [ "<rootDir>/node_modules/(?!(fp-ts/es6)/)" ],
Thanks a ton for this, was pulling my hair out trying to get this to work with jest!
Edit: It actually didn't work for me...
Most helpful comment
So, i can confirm this fixes all the crashes i had when mixing io-ts or fp-ts-rxjs with fp-ts/es6 modules.
Maybe it's something that could be added to the caveats of the es6 module usage in case anyone hits the problem.
Oh, and on the issue of es6 caveats, regarding jest, you need to add the follow jest config...