Replies: 6 comments 5 replies
-
yarn addThe normal thing is $ yarn add xyz
...edit your code to import / use xyz
$ yarn test # to confirm that it works workspacesYes, dapp-offer-up and such use yarn workspaces. "workspaces": [
"contract",
"ui"
], So if this is a contract dependency, Note: they share a lockfile. Sometimes that's wonderful, sometimes not. |
Beta Was this translation helpful? Give feedback.
-
Troubleshooting SES_IMPORT_REJECTEDSES_IMPORT_REJECTED explains why they're not allowed. IOU info about how to trouble-shoot and what to do about it... for example, how to patch with patch-package or yarn 4's built-in support for patching. |
Beta Was this translation helpful? Give feedback.
-
troubleshooting lodash?I'm not sure what's up here.
All I did was diff --git a/contract/package.json b/contract/package.json
index a9db991..7929b38 100644
--- a/contract/package.json
+++ b/contract/package.json
@@ -50,7 +50,8 @@
"@agoric/zoe": "^0.26.3-u12.0",
"@endo/far": "^0.2.22",
"@endo/marshal": "^0.8.9",
- "@endo/patterns": "^0.2.5"
+ "@endo/patterns": "^0.2.5",
+ "lodash": "^4.17.21"
},
diff --git a/contract/src/offer-up.contract.js b/contract/src/offer-up.contract.js
index e24f7d7..b0b11c6 100644
--- a/contract/src/offer-up.contract.js
+++ b/contract/src/offer-up.contract.js
@@ -25,6 +25,9 @@ import { AssetKind } from '@agoric/ertp/src/amountMath.js';
import { AmountShape } from '@agoric/ertp/src/typeGuards.js';
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
import '@agoric/zoe/exported.js';
+import _ from 'lodash';
+
+console.log(_.defaults({ 'a': 1 }, { 'a': 3, 'b': 2 }));
const { Fail, quote: q } = assert |
Beta Was this translation helpful? Give feedback.
-
I figured out a lot about the problem, but not enough to know how to fix it. The problem seems to only happen during bundling which is consistent with your stack trace above. Further, it might have something to do with our bundler's cjs support, but I'm not sure. Attn @kriskowal @naugtur A separate experiment at endojs/endo#2437 demonstrates that, aside from bundling, lodash and the ses-shim seem to play well together. It is indeed a problem in the lodash code we're running during bundling, as seen in the debugger: /** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')(); Under Hardened JS (including the ses-shim), the But the closest I could find within the lodash sources is already a corrected version that would work instead. But even after cloning lodash and grepping, I could not figure out where in the lodash sources the bad version occurs. Googling, I found https://git.fluig.com/users/csouza/repos/json-server/browse/node_modules/lodash/_freeGlobal.js?at=e658d6d I tried changing the package.json dependency from Could you please change the title of this issue to be specific to bundling+lodash, so I can link to it from the tracking issue endojs/endo#2037 without confusion? Thanks. Hopefully, with these clues, someone can pick it up from here. Please? |
Beta Was this translation helpful? Give feedback.
-
I also found https://gist.github.com/Thinkscape/ca9a7e47e3b44a5cc92d8e552f455eb6 , which seems relevant. |
Beta Was this translation helpful? Give feedback.
-
But lodash already has source code for the correct version, that also
checks globalThis. Why isn’t it using that one?
Cheers,
--MarkM
…On Thu, Aug 29, 2024 at 1:37 AM Zbyszek Tenerowicz ***@***.***> wrote:
I don't think lodash would be willing to give up that trick, but maybe we
could try to persuade them it's no longer needed. Anyway - endo needs to
emulate self
—
Reply to this email directly, view it on GitHub
<#9986 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACC3THYJBGOB46NKWXJJDTZT3MU7AVCNFSM6AAAAABNIUVXKWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANBYGQZDQNQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Suppose I want to use moment or lodash or the like in a contract? Is there any trick to it? Any gotchas to watch out for?
something about workspaces...
patches...
Beta Was this translation helpful? Give feedback.
All reactions