File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " eslint-mdx " : patch
3
+ ---
4
+
5
+ fix: handle pure ESM robustly
Original file line number Diff line number Diff line change @@ -90,8 +90,14 @@ export const loadModule = async <T>(modulePath: string): Promise<T> => {
90
90
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-return
91
91
return require ( modulePath )
92
92
} catch ( err ) {
93
+ const code = ( err as { code : string } ) . code
93
94
/* istanbul ignore if */
94
- if ( ( err as { code : string } ) . code === 'ERR_REQUIRE_ESM' ) {
95
+ if (
96
+ code === 'ERR_REQUIRE_ESM' ||
97
+ // A pure ESM could have no `exports.require` and then throw the following error,
98
+ // related to #427.
99
+ code === 'ERR_PACKAGE_PATH_NOT_EXPORTED'
100
+ ) {
95
101
// Load the ESM configuration file using the TypeScript dynamic import workaround.
96
102
// Once TypeScript provides support for keeping the dynamic import this workaround can be
97
103
// changed to a direct dynamic import.
You can’t perform that action at this time.
0 commit comments