Skip to content

Commit c89e045

Browse files
authored
Initial Commit (#379)
1 parent 3ffd72d commit c89e045

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@salesforce/mrt-utilities': patch
3+
---
4+
5+
Fix package export resolution for consumers by stripping `development` export conditions during `prepack`, so published tarballs always resolve to shipped `dist` files.

packages/mrt-utilities/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@
102102
"test": "c8 mocha --forbid-only \"test/**/*.test.ts\"",
103103
"test:ci": "c8 mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
104104
"test:agent": "mocha --forbid-only --reporter min \"test/**/*.test.ts\"",
105-
"test:watch": "mocha --watch \"test/**/*.test.ts\""
105+
"test:watch": "mocha --watch \"test/**/*.test.ts\"",
106+
"prepack": "node scripts/strip-dev-exports.cjs",
107+
"postpack": "git checkout package.json"
106108
},
107109
"dependencies": {
108110
"@aws-sdk/client-cloudwatch": "3.952.0",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2025, Salesforce, Inc.
3+
* SPDX-License-Identifier: Apache-2
4+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
7+
/**
8+
* Strips "development" conditions from package.json exports before packing.
9+
*
10+
* The "development" condition maps to TypeScript source files (./src/...)
11+
* which are not included in the published package. This prevents
12+
* MODULE_NOT_FOUND errors when consumers install the package from npm.
13+
*
14+
* Called by the "prepack" script; "postpack" restores via git checkout.
15+
*/
16+
/* eslint-disable @typescript-eslint/no-require-imports */
17+
const fs = require('fs');
18+
const path = require('path');
19+
20+
const pkgPath = path.join(__dirname, '..', 'package.json');
21+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
22+
23+
let stripped = 0;
24+
25+
if (pkg.exports) {
26+
for (const [, value] of Object.entries(pkg.exports)) {
27+
if (value && typeof value === 'object' && 'development' in value) {
28+
delete value.development;
29+
stripped++;
30+
}
31+
}
32+
}
33+
34+
if (stripped > 0) {
35+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
36+
console.log(`Stripped "development" condition from ${stripped} export(s)`);
37+
}

0 commit comments

Comments
 (0)