Skip to content

Commit d9fb67b

Browse files
committed
Use ESM
1 parent 70277fb commit d9fb67b

33 files changed

+418
-669
lines changed

Diff for: .babelrc

-3
This file was deleted.

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
*.d.ts
33
*.log
44
coverage/
5-
dist/
65
node_modules/
76
yarn.lock

Diff for: .prettierignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
coverage/
2-
dist/
3-
src/__fixtures__/**/*.html
2+
*.html
43
*.md

Diff for: index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {toDom} from './lib/index.js'

Diff for: karma.conf.js

-31
This file was deleted.

Diff for: src/index.js renamed to lib/index.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import ns from 'web-namespaces'
2-
import find from 'property-information/find.js'
3-
import html from 'property-information/html.js'
4-
import svg from 'property-information/svg.js'
1+
import {webNamespaces} from 'web-namespaces'
2+
import {find, html, svg} from 'property-information'
53

64
/* eslint-env browser */
75

@@ -40,7 +38,7 @@ function root(node, options) {
4038

4139
// Take namespace of the first child.
4240
if (typeof optionsNamespace === 'undefined') {
43-
namespace = properties.xmlns || ns.html
41+
namespace = properties.xmlns || webNamespaces.html
4442
}
4543
}
4644
}
@@ -89,21 +87,21 @@ function element(node, options) {
8987
const {namespace, doc} = options
9088
let impliedNamespace = options.impliedNamespace || namespace
9189
const {
92-
tagName = impliedNamespace === ns.svg ? 'g' : 'div',
90+
tagName = impliedNamespace === webNamespaces.svg ? 'g' : 'div',
9391
properties = {},
9492
children = []
9593
} = node
9694

9795
if (
9896
(impliedNamespace === null ||
9997
impliedNamespace === undefined ||
100-
impliedNamespace === ns.html) &&
98+
impliedNamespace === webNamespaces.html) &&
10199
tagName === 'svg'
102100
) {
103-
impliedNamespace = ns.svg
101+
impliedNamespace = webNamespaces.svg
104102
}
105103

106-
const schema = impliedNamespace === ns.svg ? svg : html
104+
const schema = impliedNamespace === webNamespaces.svg ? svg : html
107105

108106
const result =
109107
impliedNamespace === null || impliedNamespace === undefined
@@ -172,6 +170,6 @@ function appendAll(node, children, options) {
172170
return node
173171
}
174172

175-
export default function toDOM(hast, options = {}) {
173+
export function toDom(hast, options = {}) {
176174
return transform(hast, {...options, doc: options.document || document})
177175
}

Diff for: package.json

+15-47
Original file line numberDiff line numberDiff line change
@@ -24,52 +24,34 @@
2424
"Keith McKnight <[email protected]> (https://keith.mcknig.ht)",
2525
"Titus Wormer <[email protected]> (https://wooorm.com)"
2626
],
27-
"main": "dist/hast-util-to-dom.js",
28-
"module": "dist/hast-util-to-dom.mjs",
27+
"sideEffects": false,
28+
"type": "module",
29+
"main": "index.js",
2930
"files": [
30-
"dist/"
31+
"lib/",
32+
"index.js"
3133
],
3234
"dependencies": {
33-
"property-information": "^5.1.0",
34-
"web-namespaces": "^1.1.3"
35+
"property-information": "^6.0.0",
36+
"web-namespaces": "^2.0.0"
3537
},
3638
"devDependencies": {
37-
"@babel/core": "^7.0.0",
38-
"@babel/plugin-external-helpers": "^7.0.0",
39-
"@babel/preset-env": "^7.0.0",
40-
"@rollup/plugin-babel": "^5.0.0",
41-
"@rollup/plugin-commonjs": "^18.0.0",
42-
"@rollup/plugin-json": "^4.0.0",
43-
"@rollup/plugin-node-resolve": "^11.0.0",
44-
"babel-jest": "^26.0.0",
39+
"c8": "^7.0.0",
4540
"glob": "^7.0.0",
46-
"hastscript": "^6.0.0",
47-
"jasmine-core": "^3.0.0",
48-
"jest-cli": "^26.0.0",
49-
"karma": "^6.0.0",
50-
"karma-chrome-launcher": "^3.0.0",
51-
"karma-firefox-launcher": "^2.0.0",
52-
"karma-jasmine": "^4.0.0",
53-
"karma-mocha-reporter": "^2.0.0",
54-
"karma-rollup-preprocessor": "^7.0.0",
55-
"karma-safari-launcher": "^1.0.0",
41+
"hastscript": "^7.0.0",
42+
"jsdom": "^16.5.3",
5643
"prettier": "^2.0.0",
5744
"remark-cli": "^9.0.0",
5845
"remark-preset-wooorm": "^8.0.0",
59-
"rollup": "^2.0.0",
46+
"tape": "^5.0.0",
6047
"w3c-xmlserializer": "^2.0.0",
61-
"xo": "^0.38.0"
48+
"xo": "^0.39.0"
6249
},
6350
"scripts": {
64-
"build": "rollup -c",
6551
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
66-
"test:api": "jest",
67-
"test:karma": "karma start --single-run --browsers ChromeHeadless,FirefoxHeadless,Safari",
68-
"test:karma:chrome": "karma start --single-run --browsers ChromeHeadless",
69-
"test:karma:firefox": "karma start --single-run --browsers FirefoxHeadless",
70-
"test:karma:safari": "karma start --single-run --browsers Safari",
71-
"test:dev": "jest --watchAll",
72-
"test": "npm run build && npm run format && npm run test:api"
52+
"test-api": "node test/index.js",
53+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test/index.js",
54+
"test": "npm run format && npm run test-coverage"
7355
},
7456
"prettier": {
7557
"tabWidth": 2,
@@ -82,20 +64,6 @@
8264
"xo": {
8365
"prettier": true
8466
},
85-
"jest": {
86-
"collectCoverage": true,
87-
"coveragePathIgnorePatterns": [
88-
"/src/utils.js"
89-
],
90-
"coverageThreshold": {
91-
"global": {
92-
"branches": 100,
93-
"functions": 100,
94-
"lines": 100,
95-
"statements": 100
96-
}
97-
}
98-
},
9967
"remarkConfig": {
10068
"plugins": [
10169
"preset-wooorm"

Diff for: readme.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212

1313
## Install
1414

15-
[yarn][]:
16-
17-
```sh
18-
yarn add hast-util-to-dom
19-
```
15+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
16+
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
2017

2118
[npm][]:
2219

@@ -70,6 +67,9 @@ Buddy, that’s the web!
7067

7168
## API
7269

70+
This package exports the following identifiers: `toDom`.
71+
There is no default export.
72+
7373
### `toDom(node[, options])`
7474

7575
Transform a [**hast**][hast] [*tree*][tree] to a DOM tree.
@@ -145,8 +145,6 @@ abide by its terms.
145145

146146
[chat]: https://github.com/syntax-tree/unist/discussions
147147

148-
[yarn]: https://yarnpkg.com/lang/en/docs/install
149-
150148
[npm]: https://docs.npmjs.com/cli/install
151149

152150
[license]: license

Diff for: rollup.config.js

-25
This file was deleted.

Diff for: src/fixtures.test.js

-39
This file was deleted.

0 commit comments

Comments
 (0)