{"action":"created","issue":{"url":"https://api.github.com/repos/standard-things/esm/issues/282","repository_url":"https://api.github.com/repos/standard-things/esm","labels_url":"https://api.github.com/repos/standard-things/esm/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/standard-things/esm/issues/282/comments","events_url":"https://api.github.com/repos/standard-things/esm/issues/282/events","html_url":"https://github.com/standard-things/esm/issues/282","id":297315306,"number":282,"title":"Cannot load another esm package/ esm's require() returns empty","user":{"login":"rektide","id":53243,"avatar_url":"https://avatars1.githubusercontent.com/u/53243?v=4","gravatar_id":"","url":"https://api.github.com/users/rektide","html_url":"https://github.com/rektide","followers_url":"https://api.github.com/users/rektide/followers","following_url":"https://api.github.com/users/rektide/following{/other_user}","gists_url":"https://api.github.com/users/rektide/gists{/gist_id}","starred_url":"https://api.github.com/users/rektide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rektide/subscriptions","organizations_url":"https://api.github.com/users/rektide/orgs","repos_url":"https://api.github.com/users/rektide/repos","events_url":"https://api.github.com/users/rektide/events{/privacy}","received_events_url":"https://api.github.com/users/rektide/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-15T02:53:52Z","updated_at":"2018-02-15T05:15:10Z","closed_at":null,"author_association":"NONE","body":"Hello.\r\nI've been working on [package-depends](https://github.com/rektide/package-depends), a script to go through a dependency tree. When I run `node --harmony_async_iteration ./index.js`, which is a short esm wrapper script as per the esm usage docs, I get some very odd behavior: [the returned value](https://github.com/rektide/package-depends/blob/master/index.js#L6) from esm's require() is an empty object instead of the various exports in the asked for module. That causes `TypeError: Object.defineProperties called on non-object` [a couple lines later](https://github.com/rektide/package-depends/blob/a6b4d11d42a3a02962db440e23a5f42f2f3225d3/index.js#L10), when it should have the exports from the module it just required.\r\n\r\nIf I [comment out one specific `import` in the script I am attempting to load](https://github.com/rektide/package-depends/blob/a6b4d11d42a3a02962db440e23a5f42f2f3225d3/package-depends.js#L2), I get the expected exports. This one change alone swaps between getting an empty object from esm's require, and getting the expected exports (however without that `import`, trying to use the code fails).\r\n\r\nThat alone is an adequate and sufficient statement of cause, demonstrates something that should not be. I've tried putting \"debug\": true, \"warn\": true  in my `pkg.@std/esm`, but it does not generate any additional info.\r\n\r\nI also noted, from some time with the Linux utility `strace` looking at what files get accessed, that I can't seem to get the depended on `async-iterator-muxer` module to load as an ESM module. I peppered the package.json with [every directive I could](https://github.com/rektide/async-iterator-muxer/blob/c1779e13b14eda867d27f0adfb761d7ecd32c383/package.json#L6-L9) to try to get std/esm to depend on it as a module, but to no avail. At every attempt, the dependency is being loaded as CJS, via it's std/esm CJS index.js wrapper as specified in `pkg.main`. I've tried a lot of permutations including removing the index.js wrapper and making the depended module have ONLY esm but std/esm didn't like that it has `import`'s, even though it's pkg.esm= true & pkg.module & everything else. This was very unexpected. I tend to believe whatever is happening here could well be related to std/esm trying to load this other module as CJS, and creating another std/esm.\r\n\r\nAh ha! I tried a fresh download of my `package-depends` with an npm install, rather than using npm link, like I do in development. Everything works, in this situation, because there is only a single std/esm in use. I believe the issue is that the `async-iterator-muxer` dependency is loading it's own std/esm, because it is going through the index.js wrapper.\r\n\r\nHow can I develop a library in a manner such that std/esm will see and load it's ESM form, rather than it's wrapper?"},"comment":{"url":"https://api.github.com/repos/standard-things/esm/issues/comments/365827711","html_url":"https://github.com/standard-things/esm/issues/282#issuecomment-365827711","issue_url":"https://api.github.com/repos/standard-things/esm/issues/282","id":365827711,"user":{"login":"jdalton","id":4303,"avatar_url":"https://avatars2.githubusercontent.com/u/4303?v=4","gravatar_id":"","url":"https://api.github.com/users/jdalton","html_url":"https://github.com/jdalton","followers_url":"https://api.github.com/users/jdalton/followers","following_url":"https://api.github.com/users/jdalton/following{/other_user}","gists_url":"https://api.github.com/users/jdalton/gists{/gist_id}","starred_url":"https://api.github.com/users/jdalton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdalton/subscriptions","organizations_url":"https://api.github.com/users/jdalton/orgs","repos_url":"https://api.github.com/users/jdalton/repos","events_url":"https://api.github.com/users/jdalton/events{/privacy}","received_events_url":"https://api.github.com/users/jdalton/received_events","type":"User","site_admin":false},"created_at":"2018-02-15T05:15:10Z","updated_at":"2018-02-15T05:15:10Z","author_association":"OWNER","body":"With those fixes when I run as per your instructions I'm getting\r\n```\r\n➜ node --harmony_async_iteration index.js\r\n{ AsyncIteratorMuxer: { AsyncIteratorMuxer: [Getter], default: [Getter] },\r\n  bad: true,\r\n  'async-iterator-muxer': 'what' }\r\n{ ex: [Function: AsyncIteratorMuxer] }\r\n{ PackageDepends: [Function: PackageDepends] }\r\n{ dep: '@std/esm' }\r\n{ dep: 'async-iterator-muxer' }\r\n{ dep: 'pn' }\r\n{ dep: 'promise-race-predicated' }\r\n{ dep: 'unknown-filter' }\r\n```"}}
{"actor":{"display_login":"jdalton"}}