Skip to content

Commit dcc42e8

Browse files
committed
feat: performance improvement with asynchronous parallel rendering, removed bluebird, support Node v8.x+ only, preview-email new configuration (ability to use custom stylesheets)
1 parent 2d1e043 commit dcc42e8

File tree

5 files changed

+1722
-1240
lines changed

5 files changed

+1722
-1240
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"presets": [
33
["@babel/env", {
44
"targets": {
5-
"node": "6.4.0"
5+
"node": "8"
66
}
77
}]
88
],

README.md

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
1212
Create, [preview][preview-email], and send custom email templates for [Node.js][node]. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more! Made for sending beautiful emails with [Lad][].
1313

14-
**Still on v4.x?**: v5.x is released with only one minor breaking change, see [breaking changes below](#v5-breaking-changes).
15-
16-
**Still on v2.x?**: v3.x is released (you'll need Node v6.4.0+); see [breaking changes below](#v3-breaking-changes). [2.x branch][2-x-branch] docs available if necessary.
17-
1814

1915
## Table of Contents
2016

@@ -38,8 +34,11 @@ Create, [preview][preview-email], and send custom email templates for [Node.js][
3834
* [Open Email Previews in Firefox](#open-email-previews-in-firefox)
3935
* [Options](#options)
4036
* [Plugins](#plugins)
41-
* [V5 Breaking Changes](#v5-breaking-changes)
42-
* [V3 Breaking Changes](#v3-breaking-changes)
37+
* [Breaking Changes](#breaking-changes)
38+
* [v6.0.0](#v600)
39+
* [v5.0.0](#v500)
40+
* [v4.0.0](#v400)
41+
* [v3.0.0](#v300)
4342
* [Tip](#tip)
4443
* [Related](#related)
4544
* [Contributors](#contributors)
@@ -69,15 +68,13 @@ We've added [preview-email][] by default to this package!
6968

7069
This means that (by default) in the development environment (e.g. `NODE_ENV=development`) your emails will be rendered to the tmp directory for you and automatically opened in the browser.
7170

72-
If you have trouble previewing emails in your browser, you can configure a `preview` option which gets passed along to [opn's options][opn-options] (e.g. `{ app: 'firefox' }`). See the example below for [Open Email Previews in Firefox](#open-email-previews-in-firefox).
71+
If you have trouble previewing emails in your browser, you can configure a `preview` option which gets passed along to [open's options][open-options] (e.g. `preview: { open: { app: 'firefox' } }`).
7372

74-
<a target="_blank" href="https://github.com/niftylettuce/preview-email/blob/master/demo.png">View the demo</a>
73+
See the example below for [Open Email Previews in Firefox](#open-email-previews-in-firefox).
7574

7675

7776
## Usage
7877

79-
> **UPGRADING?** If you are upgrading from v2 to v3, see [v3 Breaking Changes](#v3-breaking-changes) below. You'll need Node v6.4.0+ now.
80-
8178
### Debugging
8279

8380
#### Environment Flag
@@ -657,16 +654,18 @@ email
657654

658655
### Open Email Previews in Firefox
659656

660-
The `preview` option can be a custom Object of options to pass along to [opn's options][opn-options].
657+
The `preview` option can be a custom Object of options to pass along to [open's options][open-options].
661658

662659
> Firefox example:
663660
664661
```js
665662
const email = new Email({
666663
// ...
667664
preview: {
668-
app: 'firefox',
669-
wait: false
665+
open: {
666+
app: 'firefox',
667+
wait: false
668+
}
670669
}
671670
});
672671
```
@@ -731,12 +730,42 @@ We also highly recommend to add to your default `config.locals` the following:
731730
* [font-awesome-assets][] - render any [Font Awesome][fa] icon as an image in an email w/retina support (no more Photoshop or Sketch exports!)
732731

733732

734-
## V5 Breaking Changes
733+
## Breaking Changes
734+
735+
See the [Releases](https://github.com/niftylettuce/email-templates/releases) page for an up to date changelog.
736+
737+
### v6.0.0
738+
739+
* Performance should be significantly improved as the rendering of subject, html, and text parts now occurs asynchronously in parallel (previously it was in series and had blocking lookup calls).
740+
* We removed [bluebird][] and replaced it with a lightweight alternative [pify][] (since all we were using was the `Promise.promisify` method from `bluebird` as well).
741+
* This package now only supports Node v8.x+ (due to [preview-email][]'s [open][] dependency requiring it).
742+
* Configuration for the `preview` option has slightly changed, which now allows you to [specify a custom template and stylesheets](https://github.com/niftylettuce/preview-email#custom-preview-template-and-stylesheets) for preview rendering.
743+
744+
> If you were using a custom `preview` option before, you will need to change it slightly:
735745
736-
In version 5.x+, we changed the order of defaults being set. See [#313](https://github.com/niftylettuce/email-templates/issues/313) for more information. This allows you to override message options such as `from` (even if you have a global default `from` set).
746+
```diff
747+
const email = new Email({
748+
// ...
749+
preview: {
750+
+ open: {
751+
+ app: 'firefox',
752+
+ wait: false
753+
+ }
754+
- app: 'firefox',
755+
- wait: false
756+
}
757+
});
758+
```
759+
760+
### v5.0.0
761+
762+
In version 4.x+, we changed the order of defaults being set. See [#313](https://github.com/niftylettuce/email-templates/issues/313) for more information. This allows you to override message options such as `from` (even if you have a global default `from` set).
763+
764+
### v4.0.0
737765

766+
See v5.0.0 above
738767

739-
## V3 Breaking Changes
768+
### v3.0.0
740769

741770
> If you are upgrading from v2 or prior to v3, please note that the following breaking API changes occurred:
742771
@@ -774,7 +803,7 @@ In version 5.x+, we changed the order of defaults being set. See [#313](https:/
774803

775804
5. A new method `email.send` has been added. This allows you to create a Nodemailer transport and send an email template all at once (it calls `email.render` internally). See the [Basic](#basic) usage documentation above for an example.
776805

777-
6. There are new options `options.send` and `options.preview`. Both are Boolean values and configured automatically based off the environment. Take a look at the [configuration object](src/index.js). Note that you can optionally pass an Object to `preview` option, which gets passed along to [opn's options][opn-options].
806+
6. There are new options `options.send` and `options.preview`. Both are Boolean values and configured automatically based off the environment. Take a look at the [configuration object](src/index.js). Note that you can optionally pass an Object to `preview` option, which gets passed along to [open's options][open-options].
778807

779808
7. If you wish to send emails in development or test environment (disabled by default), set `options.send` to `true`.
780809

@@ -827,8 +856,6 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins
827856

828857
[lad]: https://lad.js.org
829858

830-
[2-x-branch]: https://github.com/niftylettuce/node-email-templates/tree/2.x
831-
832859
[i18n]: https://github.com/ladjs/i18n#options
833860

834861
[fa]: http://fontawesome.io/
@@ -859,7 +886,7 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins
859886

860887
[express]: https://expressjs.com
861888

862-
[opn-options]: https://github.com/sindresorhus/opn#options
889+
[open-options]: https://github.com/sindresorhus/open#options
863890

864891
[mandarin]: https://github.com/niftylettuce/mandarin
865892

@@ -874,3 +901,9 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins
874901
[nodemailer-transports]: https://nodemailer.com/transports/
875902

876903
[juice]: https://github.com/Automattic/juice
904+
905+
[bluebird]: https://github.com/petkaantonov/bluebird
906+
907+
[pify]: https://github.com/sindresorhus/pify
908+
909+
[open]: https://github.com/sindresorhus/open

package.json

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,44 @@
1717
],
1818
"dependencies": {
1919
"@ladjs/i18n": "^1.1.0",
20+
"@sindresorhus/is": "^0.17.1",
2021
"auto-bind": "^2.1.0",
21-
"bluebird": "^3.5.5",
2222
"consolidate": "^0.15.1",
2323
"debug": "^4.1.1",
2424
"get-paths": "^0.0.4",
2525
"html-to-text": "^5.1.1",
2626
"juice": "^5.2.0",
2727
"lodash": "^4.17.11",
2828
"nodemailer": "^6.2.1",
29-
"preview-email": "^0.0.10",
30-
"underscore.string": "^3.3.5"
29+
"pify": "^4.0.1",
30+
"preview-email": "^1.0.1"
3131
},
3232
"devDependencies": {
3333
"@babel/cli": "^7.4.4",
3434
"@babel/core": "^7.4.5",
3535
"@babel/preset-env": "^7.4.5",
36-
"@commitlint/cli": "^7.6.1",
37-
"@commitlint/config-conventional": "^7.6.0",
38-
"ava": "^1.4.1",
36+
"@commitlint/cli": "^8.0.0",
37+
"@commitlint/config-conventional": "^8.0.0",
38+
"ava": "^2.1.0",
3939
"cheerio": "^1.0.0-rc.2",
4040
"codecov": "^3.5.0",
4141
"cross-env": "^5.2.0",
42-
"ejs": "^2.6.1",
43-
"eslint": "^5.16.0",
42+
"ejs": "^2.6.2",
43+
"eslint": "^6.0.0",
4444
"eslint-config-xo-lass": "^1.0.3",
4545
"eslint-plugin-node": "^9.1.0",
4646
"fixpack": "^2.3.1",
47-
"husky": "^2.3.0",
48-
"lint-staged": "^8.1.7",
47+
"husky": "^2.4.1",
48+
"lint-staged": "^8.2.1",
4949
"nodemailer-sendgrid": "^1.0.3",
5050
"nyc": "^14.1.1",
51-
"pug": "^2.0.3",
51+
"pug": "^2.0.4",
5252
"remark-cli": "^6.0.1",
53-
"remark-preset-github": "^0.0.13",
53+
"remark-preset-github": "^0.0.14",
5454
"xo": "^0.24.0"
5555
},
5656
"engines": {
57-
"node": ">=6.4.0"
57+
"node": ">=8"
5858
},
5959
"files": [
6060
"lib",
@@ -137,9 +137,6 @@
137137
],
138138
"ignores": [
139139
"config.js"
140-
],
141-
"rules": {
142-
"no-use-extend-native/no-use-extend-native": "off"
143-
}
140+
]
144141
}
145142
}

0 commit comments

Comments
 (0)