Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: default export when importing in pure node ESM (#145)
* Fix default export when importing in pure node ESM * preserve compatibility with code accessing the `default` field * fix "default" type for cjs require * add tests
- Loading branch information
Showing
5 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
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
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,8 @@ | ||
const sentryTestkit = require('../dist/index') | ||
|
||
describe('commonjs require', () => { | ||
it('should allow to require both default and non-default exports', () => { | ||
expect(sentryTestkit()).toBeDefined() | ||
expect(sentryTestkit.default()).toBeDefined() | ||
}) | ||
}) |
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,10 @@ | ||
import execa from 'execa' | ||
|
||
describe('es modules require', () => { | ||
it('should allow to import as native esm', () => { | ||
// test will fail if the command fails | ||
execa.commandSync('node --experimental-vm-modules test/fixtures/esm.mjs', { | ||
stdio: 'inherit', | ||
}) | ||
}) | ||
}) |
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,3 @@ | ||
import sentryTestkit from '../../dist/index.js' | ||
|
||
sentryTestkit() |