Skip to content

Commit

Permalink
test: Use destructuring imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Codex- committed Aug 26, 2022
1 parent 6a5b771 commit b5380f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions smoke-tests/smoke-test-cjs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const mod = require("../dist/cjs/index.js");
const { TypeScriptLoader } = mod;
const { TypeScriptLoader } = require("../dist/cjs/index.js");
TypeScriptLoader();

console.info("Loaded with CJS successfully");
3 changes: 1 addition & 2 deletions smoke-tests/smoke-test-esm.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import mod from "../dist/cjs/index.js";
const { TypeScriptLoader } = mod;
import { TypeScriptLoader } from "../dist/cjs/index.js";
TypeScriptLoader();

console.info("Loaded with ESM successfully");
16 changes: 6 additions & 10 deletions smoke-tests/smoke-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ const assert = require("node:assert");

(async () => {
try {
const esm = await import("../dist/cjs/index.js");
const cjs = require("../dist/cjs/index.js");
const { TypeScriptLoader: esm } = await import("../dist/cjs/index.js");
const { TypeScriptLoader: cjs } = require("../dist/cjs/index.js");

assert.strictEqual(
esm.TypeScriptLoader,
cjs.TypeScriptLoader,
"esm.TypeScriptLoader === cjs.TypeScriptLoader"
);
assert.strictEqual(esm, cjs, "esm === cjs");

// try to create loaders
esm.TypeScriptLoader();
cjs.TypeScriptLoader();
// Try to create loaders
esm();
cjs();

console.info("Loaded with both CJS and ESM successfully");
} catch (error) {
Expand Down

0 comments on commit b5380f7

Please sign in to comment.