Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/mrt-utilities-strip-dev-exports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@salesforce/mrt-utilities': patch
---

Fix package export resolution for consumers by stripping `development` export conditions during `prepack`, so published tarballs always resolve to shipped `dist` files.
4 changes: 3 additions & 1 deletion packages/mrt-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
"test": "c8 mocha --forbid-only \"test/**/*.test.ts\"",
"test:ci": "c8 mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
"test:agent": "mocha --forbid-only --reporter min \"test/**/*.test.ts\"",
"test:watch": "mocha --watch \"test/**/*.test.ts\""
"test:watch": "mocha --watch \"test/**/*.test.ts\"",
"prepack": "node scripts/strip-dev-exports.cjs",
"postpack": "git checkout package.json"
},
"dependencies": {
"@aws-sdk/client-cloudwatch": "3.952.0",
Expand Down
37 changes: 37 additions & 0 deletions packages/mrt-utilities/scripts/strip-dev-exports.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2025, Salesforce, Inc.
* SPDX-License-Identifier: Apache-2
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
*/

/**
* Strips "development" conditions from package.json exports before packing.
*
* The "development" condition maps to TypeScript source files (./src/...)
* which are not included in the published package. This prevents
* MODULE_NOT_FOUND errors when consumers install the package from npm.
*
* Called by the "prepack" script; "postpack" restores via git checkout.
*/
/* eslint-disable @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');

const pkgPath = path.join(__dirname, '..', 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

let stripped = 0;

if (pkg.exports) {
for (const [, value] of Object.entries(pkg.exports)) {
if (value && typeof value === 'object' && 'development' in value) {
delete value.development;
stripped++;
}
}
}

if (stripped > 0) {
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
console.log(`Stripped "development" condition from ${stripped} export(s)`);
}
Loading