{"action":"created","issue":{"url":"https://api.github.com/repos/gcanti/fp-ts/issues/747","repository_url":"https://api.github.com/repos/gcanti/fp-ts","labels_url":"https://api.github.com/repos/gcanti/fp-ts/issues/747/labels{/name}","comments_url":"https://api.github.com/repos/gcanti/fp-ts/issues/747/comments","events_url":"https://api.github.com/repos/gcanti/fp-ts/issues/747/events","html_url":"https://github.com/gcanti/fp-ts/pull/747","id":413426273,"node_id":"MDExOlB1bGxSZXF1ZXN0MjU1NDEyNTIw","number":747,"title":"break circular references by splitting some files into two","user":{"login":"leemhenson","id":515,"node_id":"MDQ6VXNlcjUxNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/515?v=4","gravatar_id":"","url":"https://api.github.com/users/leemhenson","html_url":"https://github.com/leemhenson","followers_url":"https://api.github.com/users/leemhenson/followers","following_url":"https://api.github.com/users/leemhenson/following{/other_user}","gists_url":"https://api.github.com/users/leemhenson/gists{/gist_id}","starred_url":"https://api.github.com/users/leemhenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leemhenson/subscriptions","organizations_url":"https://api.github.com/users/leemhenson/orgs","repos_url":"https://api.github.com/users/leemhenson/repos","events_url":"https://api.github.com/users/leemhenson/events{/privacy}","received_events_url":"https://api.github.com/users/leemhenson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2019-02-22T14:25:15Z","updated_at":"2019-02-27T13:32:25Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/gcanti/fp-ts/pulls/747","html_url":"https://github.com/gcanti/fp-ts/pull/747","diff_url":"https://github.com/gcanti/fp-ts/pull/747.diff","patch_url":"https://github.com/gcanti/fp-ts/pull/747.patch"},"body":"Hi\r\n\r\nI've been encountering an issue which occurs when using fp-ts on a large codebase, where one package using fp-ts imports from another package also using fp-ts. The sympton is that `tsc` crashes with an out of memory error. It is definitely linked to fp-ts, as compiling the project without fp-ts does not crash. I believe it is due to the circular references that exist in the codebase. Sadly the issue is not reproducible using a small repo (https://github.com/leemhenson/fp-ts-oom-repro), it only manifests when the codebase is large enough. My guess is that the size of the codebase trips `tsc` into some other mode.\r\n\r\nTo fix it, I have branched off 1.14.2 and:\r\n\r\n- added a tslint circular reference rule\r\n- fixed all the circular reference violations by splitting those files into two, e.g. `Option.ts` and `Option_.ts`. The underscore version contains the \"meat\" of the type without imports that cause the circular references, while the non-underscored version has those imports and the functions that use them, and also re-exports from the non-underscored file. This helps to preserve the same interface to anyone currently importing from, say, `Option.ts`.\r\n\r\nUsing a git reference in the package.json to a compiled version of my branch seems to resolve the issue. \r\n\r\nI fully expect you will have preferences in how you would like to structure the code rather than the underscore approach I've used, this is just a proof of concept that shows it is possible to break the cycles."},"comment":{"url":"https://api.github.com/repos/gcanti/fp-ts/issues/comments/467862804","html_url":"https://github.com/gcanti/fp-ts/pull/747#issuecomment-467862804","issue_url":"https://api.github.com/repos/gcanti/fp-ts/issues/747","id":467862804,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2Nzg2MjgwNA==","user":{"login":"leemhenson","id":515,"node_id":"MDQ6VXNlcjUxNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/515?v=4","gravatar_id":"","url":"https://api.github.com/users/leemhenson","html_url":"https://github.com/leemhenson","followers_url":"https://api.github.com/users/leemhenson/followers","following_url":"https://api.github.com/users/leemhenson/following{/other_user}","gists_url":"https://api.github.com/users/leemhenson/gists{/gist_id}","starred_url":"https://api.github.com/users/leemhenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leemhenson/subscriptions","organizations_url":"https://api.github.com/users/leemhenson/orgs","repos_url":"https://api.github.com/users/leemhenson/repos","events_url":"https://api.github.com/users/leemhenson/events{/privacy}","received_events_url":"https://api.github.com/users/leemhenson/received_events","type":"User","site_admin":false},"created_at":"2019-02-27T13:32:25Z","updated_at":"2019-02-27T13:32:25Z","author_association":"CONTRIBUTOR","body":"Having done some more digging, I am leaning towards this being the same issue as:\r\n\r\nhttps://github.com/Microsoft/TypeScript/issues/30050\r\n\r\nThe nested node_modules is the common trigger, I believe. \r\n\r\nI have modified my `fp-ts-oom-repro` project mentioned above to use a circular-ref-free 1.14.1 in the outer project and a circular-ref-free 1.14.2 in the inner project. *Compiling the outer project still causes the oom.*\r\n\r\nDigging further, I was wondering if the multi-version crash we know about is maybe due to the `declare module` statements that reopen the `HKT` declarations conflicting across versions. I tried changing the `HKT.ts` file to `HKTv14_1.ts` in the circular-ref-free 1.141. I then opened _just the inner project that uses 1.14.2_ in VS Code and added:\r\n\r\n```ts\r\nimport { URI2HKT2 } from \"fp-ts/lib/HKTv14_1\";\r\n```\r\n\r\nIt does not believe that to be an error, despite the version of fp-ts installed locally not having an `HKTv14_1` export. The intellisense offers me two entries for every export from `fp-ts`, and for `HKT` I can import `HKT` or `HKTv14_1`. It looks like, for some reason, TS is discovering the node_modules from the parent directory even though it's happily already parsed the node_modules in the local directory. \r\n\r\nI can't imagine this is intended module resolution behaviour for TS, so I'll open an issue over there."}}
{"actor":{"display_login":"leemhenson"}}