Skip to content

Commit 8027a2d

Browse files
committed
test that the CDN ESM build is importable (to node)
1 parent be3f395 commit 8027a2d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/node.js.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jobs:
3333
run: |
3434
npm run test-browser
3535
node test/builds/browser_build_as_commonjs.js
36+
# CDN build should be easily importable
37+
- if: contains(matrix.build-how, 'cdn')
38+
name: Test: Can import CDN esm build
39+
run: |
40+
node test/builds/cdn_build_as_esm.mjs
3641
3742
- if: contains(matrix.build-how, 'node')
3843
name: Test Node.js build

test/builds/cdn_build_as_esm.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import hljs from "../../build/es/highlight.js";
2+
3+
const API = [
4+
"getLanguage",
5+
"registerLanguage",
6+
"highlight",
7+
"highlightAuto",
8+
"highlightAll",
9+
"highlightElement"
10+
];
11+
12+
const assert = (f,msg) => {
13+
if (!f()) {
14+
console.error(msg);
15+
process.exit(1);
16+
}
17+
};
18+
const keys = Object.keys(hljs);
19+
20+
API.forEach(n => {
21+
assert(_ => keys.includes(n), `API should include ${n}`);
22+
});
23+
24+
console.log("Pass: browser build works with Node.js just fine.")

0 commit comments

Comments
 (0)