Skip to content

Commit 1481591

Browse files
committed
Add type: 'module'
1 parent 59dc50a commit 1481591

File tree

8 files changed

+31
-32
lines changed

8 files changed

+31
-32
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {rss} from './lib/rss.js'
2+
export {atom} from './lib/atom.js'

index.mjs

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/atom.mjs renamed to lib/atom.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import u from 'unist-builder'
2-
import x from 'xastscript'
1+
import {u} from 'unist-builder'
2+
import {x} from 'xastscript'
33
import bcp47 from 'bcp-47-normalize'
4-
import {toAuthor} from './util.mjs'
4+
import {toAuthor} from './util.js'
55

66
export function atom(channel, data) {
77
var now = new Date()
@@ -20,7 +20,7 @@ export function atom(channel, data) {
2020

2121
items.push(
2222
x('title', String(meta.title)),
23-
x('subtitle', String(meta.description || '')),
23+
x('subtitle', String(meta.description || '') || null),
2424
// `rel: 'alternate'` is the default.
2525
x('link', value),
2626
x('id', value),

lib/rss.mjs renamed to lib/rss.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import u from 'unist-builder'
2-
import x from 'xastscript'
1+
import {u} from 'unist-builder'
2+
import {x} from 'xastscript'
33
import bcp47 from 'bcp-47-normalize'
4-
import {toAuthor} from './util.mjs'
4+
import {toAuthor} from './util.js'
55

66
export function rss(channel, data) {
77
var now = new Date()
@@ -19,7 +19,7 @@ export function rss(channel, data) {
1919

2020
items.push(
2121
x('title', String(meta.title)),
22-
x('description', String(meta.description || '')),
22+
x('description', String(meta.description || '') || null),
2323
x('link', new URL(meta.url).href),
2424
x('lastBuildDate', now.toGMTString()),
2525
x('dc:date', now.toISOString())
File renamed without changes.

package.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
"contributors": [
2626
"Titus Wormer <[email protected]> (https://wooorm.com)"
2727
],
28+
"sideEffects": false,
2829
"type": "module",
29-
"main": "./index.mjs",
30-
"module": "./index.mjs",
30+
"main": "index.js",
3131
"files": [
3232
"lib/",
33-
"index.mjs"
33+
"index.js"
3434
],
3535
"dependencies": {
3636
"bcp-47-normalize": "^1.0.0",
37-
"unist-builder": "^2.0.0",
38-
"xastscript": "^2.0.0"
37+
"unist-builder": "^3.0.0",
38+
"xastscript": "^3.0.0"
3939
},
4040
"devDependencies": {
4141
"c8": "^7.0.0",
@@ -45,13 +45,13 @@
4545
"remark-cli": "^9.0.0",
4646
"remark-preset-wooorm": "^8.0.0",
4747
"tape": "^5.0.0",
48-
"xast-util-to-xml": "^2.0.0",
49-
"xo": "^0.38.0"
48+
"xast-util-to-xml": "^3.0.0",
49+
"xo": "^0.39.0"
5050
},
5151
"scripts": {
5252
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
53-
"test-api": "node test.mjs",
54-
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --experimental-modules test.mjs",
53+
"test-api": "node test.js",
54+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
5555
"test": "npm run format && npm run test-coverage"
5656
},
5757
"prettier": {
@@ -64,10 +64,6 @@
6464
},
6565
"xo": {
6666
"prettier": true,
67-
"esnext": false,
68-
"extensions": [
69-
"mjs"
70-
],
7167
"rules": {
7268
"complexity": "off",
7369
"eqeqeq": [
@@ -77,7 +73,9 @@
7773
"null": "ignore"
7874
}
7975
],
80-
"no-eq-null": "off"
76+
"no-eq-null": "off",
77+
"no-var": "off",
78+
"prefer-arrow-callback": "off"
8179
}
8280
},
8381
"remarkConfig": {

readme.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ blog posts, notes, and images).
2525

2626
Just using either RSS or Atom is probably fine: no need to do both.
2727

28-
Note that this package is ESM only: Node 12+ is required to use it and it must
29-
be imported instead of required.
30-
3128
## Install
3229

30+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
31+
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
32+
3333
[npm][]:
3434

3535
```sh
@@ -38,7 +38,7 @@ npm install xast-util-feed
3838

3939
## Use
4040

41-
Say we have the following module, `example.mjs`
41+
Say we have the following module, `example.js`
4242

4343
```js
4444
import {atom, rss} from 'xast-util-feed'
@@ -68,7 +68,7 @@ console.log(toXml(rss(channel, data)))
6868
console.log(toXml(atom(channel, data)))
6969
```
7070

71-
Now, running `node example.mjs` yields (pretty printed):
71+
Now, running `node example.js` yields (pretty printed):
7272

7373
```xml
7474
<?xml version="1.0" encoding="utf-8"?>
@@ -131,6 +131,9 @@ Now, running `node example.mjs` yields (pretty printed):
131131

132132
## API
133133

134+
This package exports the following identifiers: `atom`, `rss`.
135+
There is no default export.
136+
134137
### `rss(channel, data)`
135138

136139
Build an RSS feed.

test.mjs renamed to test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict'
2-
31
import test from 'tape'
4-
import {atom, rss} from './index.mjs'
2+
import {atom, rss} from './index.js'
53

64
// Hack so the tests don’t need updating everytime…
75
var ODate = global.Date

0 commit comments

Comments
 (0)