endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
804 stars 71 forks source link

Document how to build SES distribution files #6

Open warner opened 4 years ago

warner commented 4 years ago

I saw the checked-in yarn.lock file, so I ran yarn install, which seemed to mostly work:

warner@agony:~/trees/SES-beta$ yarn install
yarn install v1.21.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "linux" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.11: The platform "linux" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "lerna-update-wizard > inquirer-autocomplete-prompt@1.0.1" has incorrect peer dependency "inquirer@^5.0.0 || ^6.0.0".
warning "workspace-aggregator-6f1d24a7-7efe-4e0c-827f-55bc3601c77a > @agoric/harden > rollup-plugin-node-resolve@5.2.0" has unmet peer dependency "rollup@>=1.11.0".
warning "workspace-aggregator-6f1d24a7-7efe-4e0c-827f-55bc3601c77a > ses > @rollup/plugin-node-resolve@6.1.0" has unmet peer dependency "rollup@^1.20.0".
warning "workspace-aggregator-6f1d24a7-7efe-4e0c-827f-55bc3601c77a > ses > rollup-plugin-terser@5.1.3" has unmet peer dependency "rollup@>=0.66.0 <2".
warning "workspace-aggregator-6f1d24a7-7efe-4e0c-827f-55bc3601c77a > ses > @rollup/plugin-node-resolve > @rollup/pluginutils@3.0.2" has unmet peer dependency "rollup@^1.20.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 4.67s.

and then yarn build, which did not:

$ yarn build
yarn run v1.21.1
$ lerna run build
lerna notice cli v3.19.0
lerna info Executing command in 5 packages: "npm run build"
lerna ERR! npm run build exited 1 in '@agoric/make-hardener'
lerna ERR! npm run build stdout:

> @agoric/make-hardener@0.0.6 build /home/warner/bindmounts/trees/SES-beta/packages/make-hardener
> rollup -c rollup.config.js

lerna ERR! npm run build stderr:

src/index.js → dist/make-hardener.umd.js, dist/make-hardener.cjs.js...
[!] Error: Could not resolve entry module (src/index.js).
Error: Could not resolve entry module (src/index.js).
    at error (/home/warner/bindmounts/trees/SES-beta/node_modules/rollup/dist/rollup.js:5363:30)
    at /home/warner/bindmounts/trees/SES-beta/node_modules/rollup/dist/rollup.js:12034:20
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async Promise.all (index 0)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @agoric/make-hardener@0.0.6 build: `rollup -c rollup.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @agoric/make-hardener@0.0.6 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/warner/.npm/_logs/2020-02-03T22_15_55_154Z-debug.log

lerna ERR! npm run build exited 1 in '@agoric/make-hardener'
lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What commands should I be using to build the SES dist file?

warner commented 4 years ago

Once thing I noticed: the workspaces in package.json is in nearly alphabetic order (whitelist-intrinsics being the only one out of place). In agoric-sdk I sorted these by dependency order, so that a yarn build (which runs npm build in the given order) will produce all the generated/bundled dist files for the packages that need them ahead of time.

I see that make-hardener appears after harden, whereas I think harden depends upon make-hardener. Maybe part of my build problem is that things are happening in the wrong order, and in a clean checkout, this matters.

I'll experiment with changing the order and see if that helps.

warner commented 4 years ago

Short answer for now:

cd packages/ses && yarn && yarn build

and then copy the generated packages/ses/dist/ses.{esm,cjs}.js files out of there.

kriskowal commented 4 years ago

The short answer here remains the definitive answer. I will keep this open as a documentation gap.