diff --git a/packages/SwingSet/src/initializeSwingset.js b/packages/SwingSet/src/initializeSwingset.js index f7db7c05468..83491bd8717 100644 --- a/packages/SwingSet/src/initializeSwingset.js +++ b/packages/SwingSet/src/initializeSwingset.js @@ -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: { @@ -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 }); @@ -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, @@ -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)); diff --git a/packages/SwingSet/src/types.js b/packages/SwingSet/src/types.js index bc65ed970fc..24862413e52 100644 --- a/packages/SwingSet/src/types.js +++ b/packages/SwingSet/src/types.js @@ -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] diff --git a/packages/sharing-service/test/swingsetTests/sharingService/test-sharing.js b/packages/sharing-service/test/swingsetTests/sharingService/test-sharing.js index d32b55baefc..b2f65490eb4 100644 --- a/packages/sharing-service/test/swingsetTests/sharingService/test-sharing.js +++ b/packages/sharing-service/test/swingsetTests/sharingService/test-sharing.js @@ -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();