Skip to content

Commit

Permalink
feat(swingset-vat): Thread dev dependencies explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Sep 10, 2021
1 parent f0359e1 commit f55982f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/SwingSet/src/initializeSwingset.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function byName(a, b) {
* 'bootstrap.js'.
*
* @param {string} basedir The directory to scan
*
* @param {Object} [options]
* @param {boolean} [options.dev] whether to include devDependencies
* @returns {SwingSetConfig} a swingset config object: {
* bootstrap: "bootstrap",
* vats: {
Expand All @@ -87,7 +88,8 @@ function byName(a, b) {
*
* Swingsets defined by scanning a directory in this manner define no devices.
*/
export function loadBasedir(basedir) {
export function loadBasedir(basedir, options = {}) {
const { dev = false } = options;
/** @type { SwingSetConfigDescriptor } */
const vats = {};
const subs = fs.readdirSync(basedir, { withFileTypes: true });
Expand Down Expand Up @@ -120,7 +122,7 @@ export function loadBasedir(basedir) {
// scanning thing is something we decide we want to have long term.
bootstrapPath = undefined;
}
const config = { vats };
const config = { vats, dev };
if (bootstrapPath) {
vats.bootstrap = {
sourceSpec: bootstrapPath,
Expand Down Expand Up @@ -385,7 +387,9 @@ export async function initializeSwingset(
validateBundleDescriptor(desc, groupName, name);
if (desc.sourceSpec) {
names.push(name);
presumptiveBundles.push(bundleSource(desc.sourceSpec));
presumptiveBundles.push(
bundleSource(desc.sourceSpec, { dev: config.dev }),
);
} else if (desc.bundleSpec) {
names.push(name);
presumptiveBundles.push(fs.readFileSync(desc.bundleSpec));
Expand Down
2 changes: 2 additions & 0 deletions packages/SwingSet/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
/**
* @typedef {Object} SwingSetConfig a swingset config object
* @property {string} [bootstrap]
* @property {boolean} [dev] indicates that `devDependencies` of the
* surrounding `package.json` should be accessible to bundles.
* @property { ManagerType } [defaultManagerType]
* @property {SwingSetConfigDescriptor} [vats]
* @property {SwingSetConfigDescriptor} [bundles]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const dirname = path.dirname(filename);

async function main(basedir, argv) {
const dir = path.resolve(`${dirname}/..`, basedir);
const config = await loadBasedir(dir);
const config = await loadBasedir(dir, { dev: true });
config.defaultManagerType = 'xs-worker';
const controller = await buildVatController(config, argv);
await controller.run();
Expand Down

0 comments on commit f55982f

Please sign in to comment.