Skip to content

Commit f782440

Browse files
Merge pull request #202 from remarkablemark/feat/es-module
feat: add ES Module support
2 parents 996b5c9 + 4b84404 commit f782440

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ jobs:
4242
- name: Run server test
4343
run: npm run test:server
4444

45+
- name: Run ES modules tests
46+
run: npm run test:module
47+
48+
- name: Run server test
49+
run: npm run test:server
50+
4551
- name: Run client test
4652
uses: GabrielBB/xvfb-action@v1
4753
with:

index.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import HTMLDOMParser from './index.js';
2+
3+
export default HTMLDOMParser;

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"description": "HTML to DOM parser.",
55
"author": "Mark <mark@remarkablemark.org>",
66
"main": "index.js",
7+
"module": "index.mjs",
8+
"exports": {
9+
"import": "./index.mjs",
10+
"require": "./index.js"
11+
},
712
"scripts": {
813
"build": "rollup --config",
914
"clean": "rm -rf dist",
@@ -18,6 +23,7 @@
1823
"test:client": "npm run test:client:watch -- --single-run",
1924
"test:client:build": "webpack --config webpack.test.config.js",
2025
"test:client:watch": "npm run test:client:build && karma start",
26+
"test:module": "node --experimental-modules test/module/index.mjs",
2127
"test:server": "nyc mocha test/server"
2228
},
2329
"repository": {
@@ -76,6 +82,8 @@
7682
"files": [
7783
"/dist",
7884
"/index.d.ts",
85+
"/index.js",
86+
"/index.mjs",
7987
"/lib"
8088
],
8189
"browser": {

test/module/index.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import assert from 'assert';
2+
import HTMLDOMParser from '../../index.mjs';
3+
4+
assert.strictEqual(typeof HTMLDOMParser, 'function');

0 commit comments

Comments
 (0)