Skip to content

Commit 8c47da6

Browse files
committed
Merge changes from the template repository
2 parents 8b79454 + 9118db0 commit 8c47da6

File tree

8 files changed

+85
-9
lines changed

8 files changed

+85
-9
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/coverage/
2-
/index.cjs
2+
/dist/*
33
/node_modules/
4+
5+
!/dist/package.json

CONTRIBUTING.md

+44
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,47 @@
1616
1. Checkout `master` and make sure it's up to date with the remote
1717
1. Run `npm run release <level>`, where `<level>` can be any of: 'major',
1818
'minor', 'patch', 'premajor', 'preminor', 'prepatch', or 'prerelease'.
19+
20+
## Dependency Management
21+
22+
When adding a dependency, first consider whether to add it as
23+
a *regular* or as a *peer* dependency.
24+
25+
Make sure to update `rollup.config.js` and the usage instructions in `index.js`
26+
after installing a new dependency . Peer dependencies need to be included in the
27+
`npm install` example, and all dependencies need to be mentioned in the UMD
28+
scripting instructions.
29+
30+
### Regular Dependency
31+
32+
Choose a regular dependency when its internal structure is hidden from the
33+
end-user. For example, if you depend on Fluture internally, but never expose
34+
Future instances from any of your public facing functions.
35+
36+
The version of a regular dependency should be pinned at the major version
37+
number. For example `^1.1.0` would allow any versions greater than `1.1.0` and
38+
smaller than `2.0.0`.
39+
40+
### Peer Dependency
41+
42+
Choose a peer dependency when any of its internal structure is exposed to the
43+
end-user. For example, if you depend on Fluture and return Future instances
44+
from public-facing functions, then you should add Fluture as a peer dependency.
45+
46+
The version range of peer dependencies should be as wide as you can make it.
47+
For example, if you code works with Fluture version 1 as well as version 2, then
48+
your dependency range should be `>=1.0.0 <3.0.0`. Then whenever a new compatible
49+
version of Fluture is released, you bump the upper bound to include it. If you
50+
have to make a breaking change to support the new version of the peer dependency
51+
then you reset the lower bound.
52+
53+
### Package Lock
54+
55+
We don't use a package lock file, because this is a library, not a tool. The
56+
reproducible builds provided by a package lock would benefit the developers of
57+
the library, but not its users. When users install this library, the
58+
`package.json` file is used to resolve the versions of sub-depdencies. This
59+
means that even if the developers of this library would have a working
60+
reproducible build, the library might be installing broken dependencies for its
61+
users. The trade-off we're making here is that we lose build reproducibility in
62+
development, but we gain an earlier insight in when a dependency is broken.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The MIT License (MIT)
2-
Copyright (c) 2020 Aldwin Vlasblom
2+
Copyright (c) 2021 Aldwin Vlasblom
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy of
55
this software and associated documentation files (the "Software"), to deal in

dist/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
//.
33
//. FP-style HTTP and streaming utils for Node based on [Fluture][].
44
//.
5+
//. Skip to the [Http section](#http) for the main code example.
6+
//.
7+
//. ## Usage
8+
//.
59
//. ```console
6-
//. $ npm install fluture fluture-node
10+
//. $ npm install --save fluture fluture-node
711
//. ```
812
//.
9-
//. Skip to the [Http section](#http) for the main code example.
13+
//. On Node 12 and up, this module can be loaded directly with `import` or
14+
//. `require`. On Node versions below 12, `require` or the [esm][]-loader can
15+
//. be used.
1016
//.
1117
//. ## API
1218

@@ -825,3 +831,4 @@ export const responseToError = response => {
825831
//. [Readable]: https://nodejs.org/api/stream.html#stream_class_stream_readable
826832

827833
//. [RFC2616 Section 10.3]: https://tools.ietf.org/html/rfc2616#section-10.3
834+
//. [esm]: https://github.com/standard-things/esm

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"timers"
1515
],
1616
"type": "module",
17-
"main": "index.cjs",
17+
"main": "./dist/cjs.js",
1818
"module": "index.js",
1919
"exports": {
2020
".": {
2121
"import": "./index.js",
22-
"require": "./index.cjs"
22+
"require": "./dist/cjs.js"
2323
},
2424
"./index.js": "./index.js"
2525
},
@@ -36,7 +36,7 @@
3636
"url": "git://github.com/fluture-js/fluture-node.git"
3737
},
3838
"files": [
39-
"/index.cjs",
39+
"/dist",
4040
"/index.js",
4141
"/LICENSE",
4242
"/package.json",

rollup.config.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
import pkg from './package.json';
2+
3+
const dependencyNames = Array.prototype.concat.call (
4+
Object.keys (pkg.dependencies),
5+
Object.keys (pkg.peerDependencies),
6+
['fluture/index.js', 'http', 'https', 'querystring', 'stream', 'util', 'dns']
7+
);
8+
19
export default {
210
input: 'index.js',
3-
external: ['fluture/index.js'],
11+
external: dependencyNames,
412
output: {
513
format: 'cjs',
6-
file: 'index.cjs',
14+
file: 'dist/cjs.js',
715
interop: false,
16+
exports: 'named',
17+
globals: {},
818
paths: {
919
'fluture/index.js': 'fluture',
1020
},

scripts/prepublish

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ if ! npm outdated --long; then
1111
fi
1212
fi
1313

14+
source 'node_modules/sanctuary-scripts/functions'
15+
16+
pkg="$(get repo-name)"
17+
files="$(get source-files)"
18+
19+
sed --in-place "s/$pkg@0.0.0/$pkg@$VERSION/" "$files"
20+
sed --in-place "s/$pkg@$PREVIOUS_VERSION/$pkg@$VERSION/" "$files"
21+
22+
git add -- "$files"
23+
1424
npm run build
1525

1626
sanctuary-prepublish "$@"

0 commit comments

Comments
 (0)