Skip to content

Commit 12aa647

Browse files
authored
fix: plugin load errors are missing information (#733)
Currently errors during plugin loading are not exposed to the user, making it impossible to debug. ### Before <img width="1367" height="35" alt="image" src="https://github.com/user-attachments/assets/f3e26138-1978-4e13-b2ed-8d42d11da961" /> ### After <img width="1029" height="82" alt="image" src="https://github.com/user-attachments/assets/727c2605-0ece-4d66-8ae8-fe01f7171cff" /> --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent cde4468 commit 12aa647

File tree

1 file changed

+12
-5
lines changed
  • packages/@aws-cdk/toolkit-lib/lib/api/plugin

1 file changed

+12
-5
lines changed

packages/@aws-cdk/toolkit-lib/lib/api/plugin/plugin.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ export class PluginHost implements IPluginHost {
3636
* @param ioHost - the I/O host to use for printing progress information
3737
*/
3838
public async load(moduleSpec: string, ioHost?: IIoHost) {
39+
const resolved = this._doResolve(moduleSpec);
40+
if (ioHost) {
41+
await IoHelper.fromIoHost(ioHost, 'init').defaults.debug(`Loading plug-in: ${resolved} from ${moduleSpec}`);
42+
}
43+
return this._doLoad(resolved);
44+
}
45+
46+
/**
47+
* Do the resolving of a module string to an actual path
48+
*/
49+
private _doResolve(moduleSpec: string) {
3950
try {
40-
const resolved = require.resolve(moduleSpec);
41-
if (ioHost) {
42-
await IoHelper.fromIoHost(ioHost, 'init').defaults.debug(`Loading plug-in: ${resolved} from ${moduleSpec}`);
43-
}
44-
return this._doLoad(resolved);
51+
return require.resolve(moduleSpec);
4552
} catch (e: any) {
4653
// according to Node.js docs `MODULE_NOT_FOUND` is the only possible error here
4754
// @see https://nodejs.org/api/modules.html#requireresolverequest-options

0 commit comments

Comments
 (0)