From ab7aceac9b4ff11145fa9780014d418dbbd72bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20S=C3=A1ros?= Date: Wed, 1 Jul 2026 16:49:07 +0200 Subject: [PATCH] fix(pkg-utils): make named exports detectable by cjs-module-lexer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hoist the inline `require()` calls out of the `module.exports` object literal. Inline requires in the literal defeat cjs-module-lexer's static analysis, so ESM consumers doing `import * as pkgUtils from '@instructure/pkg-utils'` only saw `getPackages` and got `undefined` for the rest — breaking `ui-scripts` publish/bump/tag/deprecate with "pkgUtils.getPackageJSON is not a function" after ui-scripts was converted to ESM/TypeScript. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/pkg-utils/lib/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/pkg-utils/lib/index.js b/packages/pkg-utils/lib/index.js index 30da176ae5..412a67a98e 100644 --- a/packages/pkg-utils/lib/index.js +++ b/packages/pkg-utils/lib/index.js @@ -28,11 +28,18 @@ const { getPackageJSON, getPackagePath } = require('./get-package') +// Keep these `require`s out of the `module.exports` object literal below. +// Inline `require()` calls in the literal defeat cjs-module-lexer's static +// analysis, so ESM consumers doing `import * as pkgUtils` only see the first +// export and get `undefined` for the rest (e.g. getPackageJSON). +const getPackages = require('./get-packages') +const getChangedPackages = require('./get-changed-packages') +const readPkgUp = require('read-pkg-up') module.exports = { - getPackages: require('./get-packages'), - getChangedPackages: require('./get-changed-packages'), - readPkgUp: require('read-pkg-up'), + getPackages, + getChangedPackages, + readPkgUp, readPkg: getPackageJSON, readPackage, getPackage,