Closed dckc closed 4 days ago
I tried adapting the test to the endo source tree, but I get a different error there:
import test from '@endo/ses-ava/prepare-endo.js';
import { createRequire } from 'node:module';
import { makeNodeBundleCache } from '../cache.js';
const nodeRequire = createRequire(import.meta.url);
const entry = nodeRequire.resolve('../demo/meaning.js');
test('save to endoSync bundleCache', async t => {
const cache = await makeNodeBundleCache(
'/tmp',
{ format: 'endoScript' },
s => import(s),
);
const bundle = await cache.load(entry);
t.like(bundle, { foo: 'xx' });
});
SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1281:20)
at Module._compile (node:internal/modules/cjs/loader:1321:27)
at Object..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function._load (node:internal/modules/cjs/loader:1024:12)
at cjsLoader (node:internal/modules/esm/translators:348:17)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:297:7)
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async Object.load (file:///home/connolly/projects/endo/packages/bundle-source/cache.js:369:20)
at async file:///home/connolly/projects/endo/packages/bundle-source/test/bundle1.test.js:14:18
2024-04-30 12:23 4406f5dde feat(trampoline): create @endo/trampoline
I tried adapting the test to the endo source tree, but I get a different error there:
import test from '@endo/ses-ava/prepare-endo.js'; import { createRequire } from 'node:module'; import { makeNodeBundleCache } from '../cache.js'; const nodeRequire = createRequire(import.meta.url); const entry = nodeRequire.resolve('../demo/meaning.js'); test('save to endoSync bundleCache', async t => { const cache = await makeNodeBundleCache( '/tmp', { format: 'endoScript' }, s => import(s), ); const bundle = await cache.load(entry); t.like(bundle, { foo: 'xx' }); });
SyntaxError: Unexpected token 'export' at wrapSafe (node:internal/modules/cjs/loader:1281:20) at Module._compile (node:internal/modules/cjs/loader:1321:27) at Object..js (node:internal/modules/cjs/loader:1416:10) at Module.load (node:internal/modules/cjs/loader:1208:32) at Function._load (node:internal/modules/cjs/loader:1024:12) at cjsLoader (node:internal/modules/esm/translators:348:17) at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:297:7) at ModuleJob.run (node:internal/modules/esm/module_job:222:25) at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) at async Object.load (file:///home/connolly/projects/endo/packages/bundle-source/cache.js:369:20) at async file:///home/connolly/projects/endo/packages/bundle-source/test/bundle1.test.js:14:18
2024-04-30 12:23 4406f5d feat(trampoline): create @endo/trampoline
This symptom usually means you need to add "type": "module"
to the surrounding package.json
.
packages/bundle-source/package.json
has "type": "module"
. I don't get it.
ugh... now never mind a cache: I can't get bundleSource
to work.
I suspect something goofy about this dapp environment. I'm inclined to try in a fresh npm project.
Meanwhile, here's the stack trace:
$ rm -rf dist; LOCKDOWN_OPTIONS='{"errorTaming":"unsafe","stackFiltering":"verbose"}' node tools/core-eval-gen.js src/sell-concert-tickets.contract
.js ; less dist/sell*.mjs
'@endo/lockdown' sniffed and found a 'LOCKDOWN_OPTIONS' environment variable
writing entry dist/sell-concert-tickets.deploy.mjs
(TypeError#1)
TypeError#1: Compartment must be constructed with an importHook and a resolveHook for it to be able to load modules
at assertModuleHooks (file:///home/connolly/projects/dapp-agoric-basics/node_modules/ses/src/compartment.js:52:11)
at Compartment.load (file:///home/connolly/projects/dapp-agoric-basics/node_modules/ses/src/compartment.js:152:5)
at makeBundle (file:///home/connolly/projects/dapp-agoric-basics/node_modules/@endo/compartment-mapper/src/bundle.js:292:21)
at async bundleScript (file:///home/connolly/projects/dapp-agoric-basics/node_modules/@endo/bundle-source/src/script.js:75:18)
at async codeGen (file:///home/connolly/projects/dapp-agoric-basics/contract/tools/core-eval-gen.js:39:24)
at async main (file:///home/connolly/projects/dapp-agoric-basics/contract/tools/core-eval-gen.js:55:3)
In a fresh project, it works fine. I don't suppose I found an endo issue after all.
$ node src/core-eval-gen.js src/hello.contract.js
>dist/hello.deploy.mjs : writing entry module with length 1342
>dist : copying [ 'objectTools.js' ]
>dist/platform-goals : copying [ 'start-contract.js' ]
<dist/hello.deploy.mjs : making endoScript bundle
>dist/hello.bundle.js : source length 146399
$ git log10
2024-09-12 15:03 bde186c build: lock packages
2024-09-12 15:03 2eab73f feat: instantiate, bundle core-eval template
2024-09-12 15:03 68ef623 chore: hello world contract for deployment testing
2024-09-12 15:02 b29cd23 core: core-eval template, utility modules
2024-09-12 15:02 3d8f70e build: package dependencies, tsc config
Describe the bug
A bundle cache created with
{ format: 'endoScript' }
fails when.load(...)
is called.Steps to reproduce
yarn test test/bundle1.test.js
TypeError { message: 'Compartment must be constructed with an importHook and a resolveHook for it to be able to load modules' }
Expected behavior
makeNodeBundleCache
supportsendoScript
.Platform environment
yarn why @endo/bundle-source
says@endo/bundle-source@npm:3.4.0
Additional context
Trying to use endoScript instead of rollup...