react-email-rails 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +14 -12
- data/lib/react_email_rails/configuration.rb +0 -8
- data/lib/react_email_rails/railtie.rb +0 -9
- data/lib/react_email_rails/tasks.rb +7 -0
- data/lib/react_email_rails/version.rb +1 -1
- data/lib/tasks/react_email_rails/build.rake +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d5d324a8d629ad252aa11946478dd3b610c78920675bb027aedabf8c96c36239
|
|
4
|
+
data.tar.gz: eaa690f2caecb96ef322bac6e587bb1dbf2bfe51e9c601a8b1b9dceb4d43d7a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca696714d6b95038f96fc579c8040fb9eaf6e98b213ddf42ba7ab92fdb49e5ab8d1dc3bb6b8a095d8fc91573314df6f4ae06136c4af41f3ec9cf66ea2bd22c85
|
|
7
|
+
data.tar.gz: 77c513dfda5a19d5296396433d4adb79e198cffcda518311e4fe5f780efb19f532baba3743dd0b0d08928528eece7d74047280f0d3bde34a89a565ab06ddd975
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
- Remove the `verify_render_on_boot` configuration option, which only logged on failure and duplicated the render-time `ReactEmailRails::RenderError`.
|
|
6
|
+
- Add the `react_email_rails:verify` rake task that checks the renderer and exits non-zero on failure.
|
|
7
|
+
|
|
3
8
|
## 0.1.2
|
|
4
9
|
|
|
5
10
|
- Support Vite 8 hook filters while keeping production email bundles standalone by default.
|
data/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Build and send emails using React and Rails — a seamless integration between [
|
|
|
19
19
|
|
|
20
20
|
## Why
|
|
21
21
|
|
|
22
|
-
Building HTML emails is painfully archaic. [React Email](https://react.email) is a collection of unstyled components for building emails with React, Tailwind, and TypeScript. This gem brings that power directly into your Rails app
|
|
22
|
+
Building HTML emails is painfully archaic. [React Email](https://react.email) is a collection of unstyled components for building emails with React, Tailwind, and TypeScript. This gem brings that power directly into your Rails app. Write emails as React components, send them through Action Mailer, and recipients get automatically generated HTML and text emails.
|
|
23
23
|
|
|
24
24
|
## How
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ Building HTML emails is painfully archaic. [React Email](https://react.email) is
|
|
|
27
27
|
|
|
28
28
|
**In production,** Rails builds a server-side email bundle during `assets:precompile`. The bundled rake task runs an isolated email-only Vite build, using `reactEmailRails()` in your app's Vite config for discovery and options.
|
|
29
29
|
|
|
30
|
-
Delivery, headers,
|
|
30
|
+
React Email Rails automatically renders both HTML and plain-text versions from the same component. Delivery, headers, previews, queues, and callbacks all stay normal Action Mailer. If rendering fails, no email is sent and `ReactEmailRails::RenderError` is raised.
|
|
31
31
|
|
|
32
32
|
## Status
|
|
33
33
|
|
|
@@ -308,7 +308,6 @@ If the defaults don't fit, override them in `config/initializers/react_email_rai
|
|
|
308
308
|
| `render_timeout` | `10` seconds |
|
|
309
309
|
| `render_process_max_requests` | `1_000` |
|
|
310
310
|
| `on_render_error` | `nil` |
|
|
311
|
-
| `verify_render_on_boot` | `false` |
|
|
312
311
|
|
|
313
312
|
#### Prop Transformation
|
|
314
313
|
|
|
@@ -391,8 +390,6 @@ Every render emits an [ActiveSupport::Notifications](https://guides.rubyonrails.
|
|
|
391
390
|
|
|
392
391
|
```ruby
|
|
393
392
|
ActiveSupport::Notifications.subscribe("render.react-email-rails") do |event|
|
|
394
|
-
next if event.payload[:exception]
|
|
395
|
-
|
|
396
393
|
Rails.logger.info("[react-email-rails] Rendered #{event.payload[:component]} (Duration: #{event.duration.round}ms | Size: #{event.payload[:html_bytes]} bytes)")
|
|
397
394
|
end
|
|
398
395
|
```
|
|
@@ -495,18 +492,23 @@ The Ruby gem and npm package must stay on the same version. The renderer include
|
|
|
495
492
|
|
|
496
493
|
The build command preserves `emails.path`, `emails.extension`, `emails.ignore`, `standalone`, and email-only `vite` options.
|
|
497
494
|
|
|
498
|
-
###
|
|
495
|
+
### Renderer Verification
|
|
496
|
+
|
|
497
|
+
To confirm the renderer is ready before relying on it, run:
|
|
499
498
|
|
|
500
|
-
|
|
499
|
+
```sh
|
|
500
|
+
bin/rails react_email_rails:verify
|
|
501
|
+
```
|
|
501
502
|
|
|
502
|
-
|
|
503
|
+
It checks that the render command runs and that the npm package version matches the gem, then exits non-zero with an actionable message on failure. Wire it into your CI or release step to catch a missing bundle or version drift before a deploy ships — a renderer failure won't otherwise surface until the first email is sent.
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
For programmatic checks (for example, a health endpoint), `ReactEmailRails.healthy?` returns a boolean. If you specifically want a check at boot, call it from your own initializer and scope it to the processes that send mail so others don't pay the cost:
|
|
505
506
|
|
|
506
507
|
```ruby
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
Rails.application.config.after_initialize do
|
|
509
|
+
if Rails.env.production? && Sidekiq.server? && !ReactEmailRails.healthy?
|
|
510
|
+
Rails.logger.error("[react-email-rails] renderer verification failed")
|
|
511
|
+
end
|
|
510
512
|
end
|
|
511
513
|
```
|
|
512
514
|
|
|
@@ -27,14 +27,11 @@ class ReactEmailRails::Configuration
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
DEFAULT_VERIFY_RENDER_ON_BOOT = false
|
|
31
|
-
|
|
32
30
|
attr_accessor(
|
|
33
31
|
:component_path_resolver,
|
|
34
32
|
:render_options,
|
|
35
33
|
:transform_props,
|
|
36
34
|
:on_render_error,
|
|
37
|
-
:verify_render_on_boot,
|
|
38
35
|
)
|
|
39
36
|
attr_reader(
|
|
40
37
|
:render_mode,
|
|
@@ -52,15 +49,10 @@ class ReactEmailRails::Configuration
|
|
|
52
49
|
config.render_process_max_requests = DEFAULT_RENDER_PROCESS_MAX_REQUESTS
|
|
53
50
|
config.transform_props = :lower_camel
|
|
54
51
|
config.on_render_error = nil
|
|
55
|
-
config.verify_render_on_boot = DEFAULT_VERIFY_RENDER_ON_BOOT
|
|
56
52
|
end
|
|
57
53
|
end
|
|
58
54
|
end
|
|
59
55
|
|
|
60
|
-
def verify_render_on_boot?
|
|
61
|
-
verify_render_on_boot.respond_to?(:call) ? !!verify_render_on_boot.call : !!verify_render_on_boot
|
|
62
|
-
end
|
|
63
|
-
|
|
64
56
|
def render_mode=(value)
|
|
65
57
|
if (value.is_a?(Symbol) || value.is_a?(String)) && !RENDER_MODES.key?(value.to_sym)
|
|
66
58
|
raise(ArgumentError, "Unknown react-email-rails render mode: #{value.inspect}")
|
|
@@ -6,13 +6,4 @@ class ReactEmailRails::Railtie < Rails::Railtie
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
rake_tasks { load(File.expand_path("../tasks/react_email_rails/build.rake", __dir__)) }
|
|
9
|
-
|
|
10
|
-
config.after_initialize do
|
|
11
|
-
if ReactEmailRails.configuration.verify_render_on_boot? && !ReactEmailRails.healthy?
|
|
12
|
-
Rails.logger.error(
|
|
13
|
-
"[react-email-rails] render verification failed for command: " \
|
|
14
|
-
"#{ReactEmailRails.configuration.send(:resolved_render_command).inspect}",
|
|
15
|
-
)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
9
|
end
|
|
@@ -14,6 +14,13 @@ module ReactEmailRails::Tasks
|
|
|
14
14
|
FileUtils.rm_rf(Rails.root.join(File.dirname(ReactEmailRails::Configuration::BUNDLE_PATH)))
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def verify
|
|
18
|
+
return if ReactEmailRails.healthy?
|
|
19
|
+
|
|
20
|
+
command = ReactEmailRails.configuration.send(:resolved_render_command)
|
|
21
|
+
raise("react-email-rails renderer verification failed for command: #{command.inspect}")
|
|
22
|
+
end
|
|
23
|
+
|
|
17
24
|
private
|
|
18
25
|
|
|
19
26
|
def build_command
|
|
@@ -4,6 +4,9 @@ namespace(:react_email_rails) do
|
|
|
4
4
|
|
|
5
5
|
desc("Remove the React Email Rails production bundle")
|
|
6
6
|
task(clobber: :environment) { ReactEmailRails::Tasks.clobber }
|
|
7
|
+
|
|
8
|
+
desc("Verify the React Email Rails renderer is healthy (exits non-zero on failure)")
|
|
9
|
+
task(verify: :environment) { ReactEmailRails::Tasks.verify }
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
unless ENV["SKIP_REACT_EMAIL_RAILS_BUILD"]
|