Giter Club home page Giter Club logo

Comments (11)

cohitre avatar cohitre commented on July 17, 2024 1

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.

cohitre avatar cohitre commented on July 17, 2024 1

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.

ljacho avatar ljacho commented on July 17, 2024 1

@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.

ljacho avatar ljacho commented on July 17, 2024

+1

from email-builder-js.

jordanisip avatar jordanisip commented on July 17, 2024

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.

erikmeliska avatar erikmeliska commented on July 17, 2024

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.

cohitre avatar cohitre commented on July 17, 2024

We are investigating the issue with server side rendering. Out of curiosity, are you using this within NextJS?

from email-builder-js.

erikmeliska avatar erikmeliska commented on July 17, 2024

Tried both, nextjs, and raw node

from email-builder-js.

HadiAlMarzooq avatar HadiAlMarzooq commented on July 17, 2024

@erikmeliska @ljacho

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.

erikmeliska avatar erikmeliska commented on July 17, 2024

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.

erikmeliska avatar erikmeliska commented on July 17, 2024

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.
(Use node --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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.