Comments (11)
Thanks @erikmeliska. I was able to reproduce your issue and we are working on a fix that should be released within the next week.
from email-builder-js.
We just released version 0.0.4 of @usewaypoint/email-builder which adds react-dom as a peer dependency and fixed this issue in some environments.
from email-builder-js.
@cohitre , @erikmeliska I have tried several options as well, ended up creating the simplest possible showcase using TS: email-builder-test
unfortunately it seems that lib is not build like it supposed to be and it doesn't work
from email-builder-js.
+1
from email-builder-js.
Hi @erikmeliska and @ljacho, thanks for reporting!
Sorry for the confusion – you're right, it turns out we were referencing the incorrect method name in the docs.
This has been fixed in #89 and you can see the latest here: https://github.com/usewaypoint/email-builder-js?tab=readme-ov-file#sending-through-nodemailer
from email-builder-js.
Thanks for reply!
I figured, that it would be this, but still, I can't make it work from server side, since it is using client features (hooks, libs) everywhere.
Can you provide some working example, how to render json to html so that I can send it from the server?
from email-builder-js.
We are investigating the issue with server side rendering. Out of curiosity, are you using this within NextJS?
from email-builder-js.
Tried both, nextjs, and raw node
from email-builder-js.
Hey guys, I'm using this method to integrate it with the emails generated via this builder which works fine for me, this method does not depend on @usewaypoint/email-builder
First, import dependencies via:
const nodemailer = require("nodemailer");
const fs = require("fs");
const path = require("path");
Then read the .html
template via:
const templatePath = path.resolve(
__dirname,
"../templates/email_template.html"
);
const emailTemplate = fs.readFileSync(templatePath, "utf-8");
And the mail options as follow:
let mailOptions = {
from: process.env.EMAIL,
to: email,
subject: subject,
html: emailTemplate,
};
then send using:
await transporter.sendMail(mailOptions);
from email-builder-js.
Thanks @HadiAlMarzooq,
I don't have problems with sending already rendered html.
The problem is how to get this html rendered in the first place.
from email-builder-js.
Guys, help me out here, I did all, possible and impossible, and I still can't make it work on node.
What I did:
- created clean node project (yarn init)
- imported library (yarn add @usewaypoint/email-builder)
- created index.js with the simplest proof that it works:
import { renderToStaticMarkup } from '@usewaypoint/email-builder';
const SIMPLE = {}
const html = renderToStaticMarkup(SIMPLE, {
rootBlockId: 'root'
});
console.log(html)
node index.js
I get errors about
(node:27368) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
So I add "type": "module" to package.json, no the error is:
import { renderToStaticMarkup } from '@usewaypoint/email-builder';
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'renderToStaticMarkup' not found. The requested module '@usewaypoint/email-builder' is a CommonJS module, which may not support all module.exports as named exports.
So I do as suggested in the error message:
import pkg from '@usewaypoint/email-builder';
const { renderToStaticMarkup } = pkg;
Now I get
(node:30430) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Usenode --trace-warnings ...
to show where the warning was created)
/Users/ericsko/Projekty/_Sandbox/email-builder-node/node_modules/@usewaypoint/email-builder/dist/index.js:1
export { default as renderToStaticMarkup } from './renderers/renderToStaticMarkup';
^^^^^^SyntaxError: Unexpected token 'export'
Going in circles..
So I go to approach 2:
Install babel and try to compile it instead of changing type.
Result is pretty much the same.
So I go to approach 3:
Install typescript
Result the same.
Install babel on top
Result the same.
Here is my odyssey trying to get some help from the artificial brain, if someone is interested: :D
https://chat.openai.com/share/27c76a65-8c6c-471b-a746-2c54e987c19e
So, can somebody show me how to make this work in the simplest environment (ideally only with js)?
Thank you.
from email-builder-js.
Related Issues (20)
- Allow to export and import the JSON HOT 3
- New lines aren't being applied HOT 3
- Compile lib as CommonJS HOT 2
- Feature Request: Data Persistence and Auto-Save to Prevent Data Loss HOT 2
- Feature Request: Support Embedding Local Image Files in HTML Files HOT 4
- Your brand name on the email builder HOT 2
- Feature Request HOT 1
- how to host it? HOT 1
- Feature request to add hyperlink to text HOT 3
- integrate in php HOT 2
- Is there a way to use this in vue/nuxt? HOT 2
- Developer Documentation HOT 1
- What is the LICENSE HOT 1
- Read/Write Editor content in Javascript
- unable to compile this in production mode because of renderToStaticMarkup HOT 5
- Can I import HTML directly? HOT 1
- Placeholder/variable in email template HOT 2
- Support for Preview Text? HOT 2
- Feature Request: Allow setting word break
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from email-builder-js.