forked from agenda/agenda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: export cjs and es (agenda#1298)
* fix: export cjs and es * fix: export cjs and es renamings and add to doc * fix: use index (=module) entrypoint for es.js * docs: add migration note * Add test for import vs require(). Make sure cjs can be required via destructuring. Update README a bit. Co-authored-by: vasyl <[email protected]>
- Loading branch information
Showing
10 changed files
with
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/index') |
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,5 @@ | ||
// old common js export (see index.ts for module exports) | ||
|
||
import { Agenda } from "./agenda"; | ||
module.exports = Agenda; | ||
module.exports.Agenda = Agenda; |
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,11 @@ | ||
describe("Exports", () => { | ||
it("should export both default Agenda and { Agenda }", () => { | ||
require("./imports/require.js"); | ||
require("./imports/require-es.js"); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const requireEsm = require("esm")(module /*, options*/); | ||
requireEsm("./imports/import.js"); | ||
requireEsm("./imports/import-es.js"); | ||
}); | ||
}); |
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,5 @@ | ||
import assert from "assert"; | ||
|
||
import Agenda1 from "../../es"; | ||
import { Agenda as Agenda2 } from "../../es"; | ||
assert.strictEqual(Agenda1.constructor, Agenda2.constructor); // comparing ctors, as Agenda1 is a JS Proxy in `esm` |
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,5 @@ | ||
import assert from "assert"; | ||
|
||
import Agenda1 from "../.."; | ||
import { Agenda as Agenda2 } from "../.."; | ||
assert.strictEqual(Agenda1.constructor, Agenda2.constructor); // comparing ctors, as Agenda1 is a JS Proxy in `esm` |
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,5 @@ | ||
const assert = require("assert"); | ||
|
||
const Agenda1 = require("../../es").default; | ||
const { Agenda: Agenda2 } = require("../../es"); | ||
assert.strictEqual(Agenda1, Agenda2); |
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,5 @@ | ||
const assert = require("assert"); | ||
|
||
const Agenda1 = require("../.."); | ||
const { Agenda: Agenda2 } = require("../.."); | ||
assert.strictEqual(Agenda1, Agenda2); |