react-email-rails 0.1.1 → 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 +10 -0
- data/README.md +17 -16
- 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,15 @@
|
|
|
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
|
+
|
|
8
|
+
## 0.1.2
|
|
9
|
+
|
|
10
|
+
- Support Vite 8 hook filters while keeping production email bundles standalone by default.
|
|
11
|
+
- Keep development email rendering compatible with Vite's module runner.
|
|
12
|
+
|
|
3
13
|
## 0.1.1
|
|
4
14
|
|
|
5
15
|
- Build production React Email bundles from Rails asset tasks with an isolated email-only Vite build.
|
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,10 +390,7 @@ 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
|
-
Rails.logger.info(
|
|
395
|
-
"[react-email-rails] rendered #{event.payload[:component]} " \
|
|
396
|
-
"(#{event.payload[:html_bytes]} bytes) in #{event.duration.round(1)}ms"
|
|
397
|
-
)
|
|
393
|
+
Rails.logger.info("[react-email-rails] Rendered #{event.payload[:component]} (Duration: #{event.duration.round}ms | Size: #{event.payload[:html_bytes]} bytes)")
|
|
398
394
|
end
|
|
399
395
|
```
|
|
400
396
|
|
|
@@ -411,7 +407,7 @@ In development and production, the isolated renderer loads the `reactEmailRails(
|
|
|
411
407
|
| `emails.path` | `"app/javascript/emails"` | Directory containing email components |
|
|
412
408
|
| `emails.extension` | `[".tsx", ".jsx"]` | Component extension, or an array of extensions |
|
|
413
409
|
| `emails.ignore` | `["**/_*", "**/_*/**"]` | Glob patterns ignored under `emails.path` |
|
|
414
|
-
| `standalone` | `true` | Inline
|
|
410
|
+
| `standalone` | `true` | Inline production email bundle dependencies |
|
|
415
411
|
| `vite` | `{}` | Extra email-only Vite config for compilation and resolution |
|
|
416
412
|
|
|
417
413
|
Use a custom directory:
|
|
@@ -458,7 +454,7 @@ These `vite` options are used by `react-email-rails-dev` and `react-email-rails-
|
|
|
458
454
|
|
|
459
455
|
#### Standalone Builds
|
|
460
456
|
|
|
461
|
-
By default the email bundle inlines React, `@react-email/render`, and other Node dependencies. That makes the bundle larger, but it works well for Rails deploys that build assets in one stage and run without `node_modules` in the final runtime image.
|
|
457
|
+
By default the production email bundle inlines React, `@react-email/render`, and other Node dependencies. That makes the bundle larger, but it works well for Rails deploys that build assets in one stage and run without `node_modules` in the final runtime image. Development previews keep dependencies external for Vite's module runner, even when `standalone` is enabled.
|
|
462
458
|
|
|
463
459
|
Set `standalone: false` when your runtime already ships `node_modules` and you prefer a smaller SSR-style bundle:
|
|
464
460
|
|
|
@@ -496,18 +492,23 @@ The Ruby gem and npm package must stay on the same version. The renderer include
|
|
|
496
492
|
|
|
497
493
|
The build command preserves `emails.path`, `emails.extension`, `emails.ignore`, `standalone`, and email-only `vite` options.
|
|
498
494
|
|
|
499
|
-
###
|
|
495
|
+
### Renderer Verification
|
|
496
|
+
|
|
497
|
+
To confirm the renderer is ready before relying on it, run:
|
|
500
498
|
|
|
501
|
-
|
|
499
|
+
```sh
|
|
500
|
+
bin/rails react_email_rails:verify
|
|
501
|
+
```
|
|
502
502
|
|
|
503
|
-
|
|
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.
|
|
504
504
|
|
|
505
|
-
|
|
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:
|
|
506
506
|
|
|
507
507
|
```ruby
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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
|
|
511
512
|
end
|
|
512
513
|
```
|
|
513
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"]
|