-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to import or require 0.7.1 under -r esm
#214
Comments
Interesting: if I rename This doesn't help me use module-style imports yet, though. |
Changing SES's package.json to say |
My best situation so far is when SES's package.json says:
in which case:
|
For reference, https://github.com/nodejs/node/blob/master/doc/api/esm.md#conditional-exports describes how |
Fixing with #217 |
We’ve addressed this issue with a cocktail of adjustments to how leaves on the dependency graph provide hybrid support for CJS, RESM, and ESM. rollup config:
package.json:
This seems to cover all the bases. |
All of the agoric-sdk code is still using
-r esm
(we useimport
andexport
as if we were writing modules, but thepackage.json
do not declare them as such, and we rely upon-r esm
to let us load module-ish code anyways).I tried to import
ses
as usual, and got an error which I don't know how to work around. The minimal test case looks like:I know that
-r esm
is a crutch, and that it doesn't play nicely with real modules: I compiled a list of rules in Agoric/agoric-sdk#527 (comment) , and I think we're running afoul of at least one of them here. But I'm not prepared to change all ofagoric-sdk
yet, it's a big project. I was hoping the boundary between agoric-sdk and SES-shim would let me avoid doing that.I think
esm
is rewriting myt.js
into CommonJS format, into something likeconst { lockdown } = require('ses');
. If I write that intot2.js
, I get a slightly different error:Note that
t.js
failed as it tried to requireses/src/lockdown-shim.js
(which is listed inses
's package.json as bothmain:
andexports.import
), whilet2.js
failed as it tried to requiredist/ses.cjs.js
(which is listed asexports.require
).If I run
node -r esm t2.js
, I get the same error asnode -r esm t.js
: unable to requiresrc/lockdown-shim.js
.Any ideas?
The text was updated successfully, but these errors were encountered: