Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ES Module support #202

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ jobs:
- name: Run server test
run: npm run test:server

- name: Run ES modules tests
run: npm run test:module

- name: Run server test
run: npm run test:server

- name: Run client test
uses: GabrielBB/xvfb-action@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import HTMLDOMParser from './index.js';

export default HTMLDOMParser;
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"description": "HTML to DOM parser.",
"author": "Mark <mark@remarkablemark.org>",
"main": "index.js",
"module": "index.mjs",
"exports": {
"import": "./index.mjs",
"require": "./index.js"
},
"scripts": {
"build": "rollup --config",
"clean": "rm -rf dist",
Expand All @@ -18,6 +23,7 @@
"test:client": "npm run test:client:watch -- --single-run",
"test:client:build": "webpack --config webpack.test.config.js",
"test:client:watch": "npm run test:client:build && karma start",
"test:module": "node --experimental-modules test/module/index.mjs",
"test:server": "nyc mocha test/server"
},
"repository": {
Expand Down Expand Up @@ -76,6 +82,8 @@
"files": [
"/dist",
"/index.d.ts",
"/index.js",
"/index.mjs",
"/lib"
],
"browser": {
Expand Down
4 changes: 4 additions & 0 deletions test/module/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import assert from 'assert';
import HTMLDOMParser from '../../index.mjs';

assert.strictEqual(typeof HTMLDOMParser, 'function');