Skip to content

Commit 6705282

Browse files
committed
Fix build and runtime issues in rush-sdk.
1 parent 6d23282 commit 6705282

File tree

10 files changed

+35
-48
lines changed

10 files changed

+35
-48
lines changed

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/rush-sdk/.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@
3030
# ---------------------------------------------------------------------------
3131
# DO NOT MODIFY ABOVE THIS LINE! Add any project-specific overrides below.
3232
# ---------------------------------------------------------------------------
33+
34+
/lib-dts/**
3335
/lib-commonjs/**
34-
/lib-esnext/**
36+
/lib-esm/**

libraries/rush-sdk/config/api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33

4-
"mainEntryPointFilePath": "<projectFolder>/lib-commonjs/loader.d.ts",
4+
"mainEntryPointFilePath": "<projectFolder>/lib-dts/loader.d.ts",
55

66
"apiReport": {
77
"enabled": true,
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
11
{
2-
"extends": "local-node-rig/profiles/default/config/jest.config.json",
3-
4-
"roots": ["<rootDir>/lib-shim"],
5-
6-
"testMatch": ["<rootDir>/lib-shim/**/*.test.js"],
7-
8-
"collectCoverageFrom": [
9-
"lib-shim/**/*.js",
10-
"!lib-shim/**/*.d.ts",
11-
"!lib-shim/**/*.test.js",
12-
"!lib-shim/**/test/**",
13-
"!lib-shim/**/__tests__/**",
14-
"!lib-shim/**/__fixtures__/**",
15-
"!lib-shim/**/__mocks__/**"
16-
]
2+
"extends": "local-node-rig/profiles/default/config/jest.config.json"
173
}

libraries/rush-sdk/config/typescript.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

libraries/rush-sdk/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"@rushstack/node-core-library": "workspace:*",
4545
"@rushstack/package-deps-hash": "workspace:*",
4646
"@rushstack/terminal": "workspace:*",
47-
"tapable": "2.2.1"
47+
"tapable": "2.2.1",
48+
"true-case-path": "~2.2.1"
4849
},
4950
"devDependencies": {
5051
"@microsoft/rush-lib": "workspace:*",

libraries/rush-sdk/src/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Executable
1111
} from '@rushstack/node-core-library';
1212
import { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';
13-
import { RushGlobalFolder } from '@microsoft/rush-lib/lib-esnext/api/RushGlobalFolder';
13+
import { RushGlobalFolder } from '@microsoft/rush-lib/lib/api/RushGlobalFolder';
1414
import type { SpawnSyncReturns } from 'child_process';
1515
import {
1616
RUSH_LIB_NAME,
@@ -211,6 +211,20 @@ ${errorMessage}
211211
process.exit(1);
212212
}
213213

214+
const exports: typeof import('@microsoft/rush-lib') = {
215+
/**
216+
* Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.
217+
*/
218+
_rushSdk_loadInternalModule: (srcImportPath: string) => {
219+
if (!exports._RushInternals) {
220+
throw new Error(
221+
`Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`
222+
);
223+
}
224+
return exports._RushInternals.loadModule(srcImportPath);
225+
}
226+
} as unknown as typeof import('@microsoft/rush-lib');
227+
214228
// Based on TypeScript's __exportStar()
215229
for (const property in sdkContext.rushLibModule) {
216230
if (property !== 'default' && !exports.hasOwnProperty(property)) {
@@ -226,14 +240,4 @@ for (const property in sdkContext.rushLibModule) {
226240
}
227241
}
228242

229-
/**
230-
* Used by the .js stubs for path-based imports of `@microsoft/rush-lib` internal APIs.
231-
*/
232-
export function _rushSdk_loadInternalModule(srcImportPath: string): unknown {
233-
if (!exports._RushInternals) {
234-
throw new Error(
235-
`Rush version ${exports.Rush.version} does not support internal API imports via rush-sdk`
236-
);
237-
}
238-
return exports._RushInternals.loadModule(srcImportPath);
239-
}
243+
export default exports;

libraries/rush-sdk/src/test/__snapshots__/script.test.ts.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ exports[`@rushstack/rush-sdk Should load via global (for plugins): stdout 1`] =
7777
exports[`@rushstack/rush-sdk Should load via install-run (for standalone tools): stderr 1`] = `""`;
7878

7979
exports[`@rushstack/rush-sdk Should load via install-run (for standalone tools): stdout 1`] = `
80-
"Trying to load @microsoft/rush-lib installed by install-run-rush
80+
"Try to load @microsoft/rush-lib from rush global folder
81+
The expected global rush installed folder is \\"/Users/ianc/.rush/node-v22.12.0/rush-5.57.0\\"
82+
Failed to load @microsoft/rush-lib from rush global folder: File does not exist: /Users/ianc/.rush/node-v22.12.0/rush-5.57.0
83+
ENOENT: no such file or directory, lstat '/Users/ianc/.rush/node-v22.12.0/rush-5.57.0'
84+
Trying to load @microsoft/rush-lib installed by install-run-rush
8185
Loaded @microsoft/rush-lib installed by install-run-rush
8286
[
8387
'_rushSdk_loadInternalModule',

libraries/rush-sdk/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json",
33
"compilerOptions": {
4-
"outDir": "lib-commonjs",
54
"types": [
65
"node",
76
"heft-jest",

libraries/rush-sdk/webpack.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ module.exports = () => {
1717
mode: 'development', // So the output isn't minified
1818
devtool: 'source-map',
1919
entry: {
20-
// Using CommonJS due to access of module.parent
21-
index: `${__dirname}/lib-commonjs/index.js`,
22-
loader: `${__dirname}/lib-commonjs/loader.js`
20+
index: `${__dirname}/lib-esm/index.js`,
21+
loader: `${__dirname}/lib-esm/loader.js`
2322
},
2423
output: {
2524
path: `${__dirname}/lib-shim`,
2625
filename: '[name].js',
2726
chunkFilename: 'chunks/[name].js',
2827
library: {
29-
type: 'commonjs2'
28+
type: 'commonjs2',
29+
export: 'default'
3030
}
3131
},
3232
optimization: {

0 commit comments

Comments
 (0)