Skip to content

Commit

Permalink
test that the CDN ESM build is importable (to node)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Jul 3, 2021
1 parent be3f395 commit 8027a2d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/node.js.yml
Expand Up @@ -33,6 +33,11 @@ jobs:
run: |
npm run test-browser
node test/builds/browser_build_as_commonjs.js
# CDN build should be easily importable
- if: contains(matrix.build-how, 'cdn')
name: Test: Can import CDN esm build
run: |
node test/builds/cdn_build_as_esm.mjs
- if: contains(matrix.build-how, 'node')
name: Test Node.js build
Expand Down
24 changes: 24 additions & 0 deletions test/builds/cdn_build_as_esm.mjs
@@ -0,0 +1,24 @@
import hljs from "../../build/es/highlight.js";

const API = [
"getLanguage",
"registerLanguage",
"highlight",
"highlightAuto",
"highlightAll",
"highlightElement"
];

const assert = (f,msg) => {
if (!f()) {
console.error(msg);
process.exit(1);
}
};
const keys = Object.keys(hljs);

API.forEach(n => {
assert(_ => keys.includes(n), `API should include ${n}`);
});

console.log("Pass: browser build works with Node.js just fine.")

0 comments on commit 8027a2d

Please sign in to comment.