-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#168): cjs default export for typescript
- Loading branch information
1 parent
18a1a4b
commit 714e796
Showing
4 changed files
with
37 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ lib/ | |
.eslintcache | ||
.idea/ | ||
.DS_Store | ||
pnpm-lock.yaml |
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,16 @@ | ||
/** | ||
* get rid of this script if module will be switched to pure ESM with only named | ||
* exports | ||
*/ | ||
|
||
const path = require('path') | ||
const fs = require('fs') | ||
|
||
const indexCjs = ` | ||
var Holidays = require('./Holidays.cjs'); | ||
module.exports = Holidays.Holidays; | ||
module.exports.default = Holidays.Holidays; | ||
` | ||
|
||
fs.writeFileSync(path.resolve(__dirname, '../lib/index.cjs'), indexCjs, 'utf8') |
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,17 @@ | ||
const assert = require('assert') | ||
|
||
describe('cjs', function () { | ||
it('module.exports', function () { | ||
const Holidays = require('../lib/index.cjs') | ||
const hd = new Holidays() | ||
const countries = hd.getCountries() | ||
assert.ok(Object.keys(countries).length > 100) | ||
}) | ||
|
||
it('exports.default', function () { | ||
const Holidays = require('../lib/index.cjs').default | ||
const hd = new Holidays() | ||
const countries = hd.getCountries() | ||
assert.ok(Object.keys(countries).length > 100) | ||
}) | ||
}) |