Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maorleger/msal-2-esm-repro
https://github.com/maorleger/msal-2-esm-repro
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/maorleger/msal-2-esm-repro
- Owner: maorleger
- Created: 2024-01-24T16:16:34.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-25T22:35:29.000Z (12 months ago)
- Last Synced: 2024-12-09T18:01:23.895Z (about 1 month ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Repro of incompatibility between MSAL 2.x and the ESM NPM package
This is a minimal repro showing different behaviors when loading MSAL 2.x:
Context: MSAL 2.x moved to ESM with [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) controlling whether to load ESM or CJS
The problem is that a very popular package [esm](https://www.npmjs.com/package/esm) (2.6 million downloads per week) does not support conditional exports. As a result, using `esm` prevents the ability to load the correct type of MSAL module.
To run this:
```bash
npm install
npm run start:module # runs main.mjs using native esm, prints "ok" and MSAL's version
npm run start:commonjs # runs main.cjs using common js, prints "ok" and MSAL's version
npm run start:esm # runs main.mjs using the esm package, throws Error: Cannot find module '@azure/msal-node'
```