Skip to content
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

fix: Remove remaining uses of -r esm #3710

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/SwingSet/docs/how-to-replay.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ By modifying the replay tool, you can control how the replay is performed:
Suppose you have an agoric chain node (validator or non-voting fullnode) that keeps its state in `~/.ag-chain-cosmos/`. After stopping the node (so the database is not being modified during read), the following invocation will extract a list of vatIDs to choose from:

```
$ node -r esm extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state
$ node extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state

all vats:
v1 : bank (26464 deliveries)
Expand Down Expand Up @@ -55,7 +55,7 @@ v24 : (dynamic) {"managerType":"xs-worker"} (1 deliveries)
To replay the "zoe" vat, first extract the transcript:

```
$ node -r esm extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state zoe
$ node extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state zoe

extracting transcript for vat v11 into transcript-v11.sst
29905 transcript entries
Expand Down
4 changes: 1 addition & 3 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ export async function makeSwingsetController(

// this launches a worker in a Node.js thread (aka "Worker")
function makeNodeWorker() {
// TODO: after we move away from `-r esm` and use real ES6 modules, point
// this at nodeWorkerSupervisor.js instead of the CJS intermediate
const supercode = new URL(
'kernel/vatManager/supervisor-nodeworker.js',
import.meta.url,
Expand All @@ -242,7 +240,7 @@ export async function makeSwingsetController(
'kernel/vatManager/supervisor-subprocess-node.js',
import.meta.url,
).pathname;
const args = ['-r', 'esm', supercode];
const args = [supercode];
return startSubprocessWorker(process.execPath, args);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/db-delete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/db-get.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/db-set.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/replace-bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
8 changes: 4 additions & 4 deletions packages/eventual-send/integration-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"main": "index.js",
"private": true,
"scripts": {
"test": "tape -r esm test/*.js",
"test": "tape test/*.js",
"create-test-file-no-lib-cjs": "rollup -c transform-tests/config/rollup.config.no-lib.js",
"test:pre-release": "tape -r esm test/test-pre-release.js",
"test:post-release": "tape -r esm test/test-post-release.js",
"test:pre-release": "tape test/test-pre-release.js",
"test:post-release": "tape test/test-post-release.js",
"create-test-file-esm": "rollup -c transform-tests/config/rollup.config.esm.js",
"create-test-file-cjs": "rollup -c transform-tests/config/rollup.config.cjs.js",
"create-test-file-browserified-tape": "browserify transform-tests/output/test.no-lib.cjs.js > transform-tests/output/test.tape-no-lib.js --exclude @agoric/eventual-send",
"build:webpack": "webpack -r esm --display-error-details --config pre-release-browser-tests/webpack/webpack.config.js",
"build:webpack": "webpack --display-error-details --config pre-release-browser-tests/webpack/webpack.config.js",
"build:browserify": "browserify transform-tests/output/test.cjs.js > bundles/browserify.js",
"build:rollup": "rollup -c pre-release-browser-tests/rollup/rollup.config.test.js",
"build:parcel": "parcel build pre-release-browser-tests/parcel/index.html --public-url ./ -d bundles/parcel"
Expand Down
21 changes: 10 additions & 11 deletions packages/xsnap/src/replay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Replay usage:
* node -r esm replay.js <folder>...
* node replay.js <folder>...
*
* In case of more than one folder:
* 1. Spawn based on 00000-options.json in the first folder
Expand All @@ -10,6 +10,9 @@
*/
// @ts-check

import childProcessPowers from 'child_process';
import osPowers from 'os';
import fsPowers from 'fs';
import { xsnap, DEFAULT_CRANK_METERING_LIMIT } from './xsnap.js';
import { queue } from './stream.js';

Expand Down Expand Up @@ -293,17 +296,13 @@ export async function main(argv, { spawn, osType, readdirSync, readFileSync }) {
await replayXSnap(options, folders, { readdirSync, readFileSync });
}

/* global require, module, process, require */
if (typeof require !== 'undefined' && require.main === module) {
/* global process */
if (process.argv[1] === new URL(import.meta.url).pathname) {
main([...process.argv.slice(2)], {
// eslint-disable-next-line global-require
spawn: require('child_process').spawn,
// eslint-disable-next-line global-require
osType: require('os').type,
// eslint-disable-next-line global-require
readdirSync: require('fs').readdirSync,
// eslint-disable-next-line global-require
readFileSync: require('fs').readFileSync,
spawn: childProcessPowers.spawn,
osType: osPowers.type,
readdirSync: fsPowers.readdirSync,
readFileSync: fsPowers.readFileSync,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I found an if __name__ == '__main__' idiom for NESM, but even then, I struggled to preserve your intent of limiting the scope of powers to the entrypoint, forcing a certain discipline to thread them through. One of the troubles was having to find names that would not run afoul of eslint name shadowing prohibitions. I arrived at this convention, with *Powers module names, which is mildly dissatisfying but got the job done surgically. It might be worthwhile to factor out a replay-entrypoint.js that imports this module and the powers instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GMTA... I did the same thing recently... Modulo Powers vs Top

}).catch(err => {
console.error(err);
process.exit(err.code || 1);
Expand Down
2 changes: 1 addition & 1 deletion packages/xsnap/src/xsrepl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
real0=$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")
thisdir=$(cd "$(dirname -- "$real0")" > /dev/null && pwd -P)
node -r esm "$thisdir/xsrepl.js" "$*"
node "$thisdir/xsrepl.js" "$*"