-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Uses default import for importing keytar (a CJS module), which is really the only foolproof way of importing CJS from an ESM context. I confirmed by creating a simple package: ```json5 // msal-node-extensions/foo/package.json { "type": "module" } ``` ```js // msal-node-extensions/foo/index.js import * as msal from "../dist/index.mjs"; msal; ``` Running `node foo/index.mjs` on `dev` gives the following error: ``` file:///.../microsoft-authentication-library-for-js/extensions/msal-node-extensions/dist/persistence/KeychainPersistence.mjs:3 import { setPassword, getPassword, deletePassword } from 'keytar'; ^^^^^^^^^^^^^^ SyntaxError: Named export 'deletePassword' not found. The requested module 'keytar' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'keytar'; const { setPassword, getPassword, deletePassword } = pkg; at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21) at async ModuleJob.run (node:internal/modules/esm/module_job:190:5) Node.js v18.17.1 ``` Running the same command on this branch succeeds (no output, exit code 0). Not sure of a good/reliable way to encode that in an automated test, but I'd be happy to add one if anyone has any suggestions
- Loading branch information
Showing
3 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@azure-msal-node-extensions-25a8325b-07d2-4bf8-91b6-ed1140578fdf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Fix downstream ESM imports, fixes #6573", | ||
"packageName": "@azure/msal-node-extensions", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters