From 8b2a4430dca081c70143f5070ea376128393bc15 Mon Sep 17 00:00:00 2001 From: gabriel miranda Date: Mon, 23 Dec 2024 18:40:18 -0300 Subject: [PATCH] fix build for demo --- packages/preview-utils/package.json | 23 ---------------- packages/preview-utils/tsconfig.json | 9 ------- packages/react-email/package.json | 16 +++++++++++- .../actions/get-emails-directory-metadata.ts | 2 +- .../src/actions/render-email-by-path.tsx | 4 +-- .../react-email/src/cli/commands/export.ts | 2 +- .../src/hooks/use-rendering-metadata.ts | 2 +- packages/react-email/src/package/index.ts | 1 + .../get-email-component.spec.ts | 0 .../preview-utils}/get-email-component.ts | 0 .../src/package/preview-utils}/index.ts | 0 .../preview-utils}/is-file-an-email.ts | 0 .../preview-utils}/render-email-by-path.ts | 0 .../preview-utils}/utils/email-template.ts | 0 .../utils/improve-error-with-source-map.ts | 0 .../utils/rendering-utilities-exporter.ts | 0 .../utils/static-node-modules-for-vm.ts | 0 packages/react-email/tsup.config.ts | 21 ++++++++++----- .../visual-studio-code-extension/package.json | 4 +-- .../src/render-open-email-file.ts | 3 +-- .../tsconfig.json | 1 + pnpm-lock.yaml | 26 ++----------------- 22 files changed, 41 insertions(+), 73 deletions(-) delete mode 100644 packages/preview-utils/package.json delete mode 100644 packages/preview-utils/tsconfig.json create mode 100644 packages/react-email/src/package/index.ts rename packages/{preview-utils/src => react-email/src/package/preview-utils}/get-email-component.spec.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/get-email-component.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/index.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/is-file-an-email.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/render-email-by-path.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/utils/email-template.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/utils/improve-error-with-source-map.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/utils/rendering-utilities-exporter.ts (100%) rename packages/{preview-utils/src => react-email/src/package/preview-utils}/utils/static-node-modules-for-vm.ts (100%) diff --git a/packages/preview-utils/package.json b/packages/preview-utils/package.json deleted file mode 100644 index e03bbccee5..0000000000 --- a/packages/preview-utils/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "preview-utils", - "version": "0.0.0", - "private": true, - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "scripts": { - "test": "vitest run", - "test:watch": "vitest" - }, - "main": "./src/index.ts", - "devDependencies": { - "@react-email/render": "workspace:*", - "tsconfig": "workspace:*" - }, - "dependencies": { - "esbuild": "0.19.11", - "source-map-js": "1.0.2", - "stacktrace-parser": "0.1.10" - } -} diff --git a/packages/preview-utils/tsconfig.json b/packages/preview-utils/tsconfig.json deleted file mode 100644 index 33541a7cdf..0000000000 --- a/packages/preview-utils/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "tsconfig/react-library.json", - "include": [ - "." - ], - "exclude": [ - "node_modules" - ] -} diff --git a/packages/react-email/package.json b/packages/react-email/package.json index 017646a340..192f9d64cf 100644 --- a/packages/react-email/package.json +++ b/packages/react-email/package.json @@ -5,6 +5,21 @@ "bin": { "email": "./dist/cli/index.js" }, + "main": "./dist/package/index.js", + "module": "./dist/package/index.mjs", + "types": "./dist/package/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/package/index.d.mts", + "default": "./dist/package/index.mjs" + }, + "require": { + "types": "./dist/package/index.d.ts", + "default": "./dist/package/index.js" + } + } + }, "scripts": { "build": "tsup-node && node build-preview-server.mjs", "dev": "tsup-node --watch", @@ -67,7 +82,6 @@ "eslint-config-turbo": "2.1.0", "framer-motion": "12.0.0-alpha.2", "postcss": "8.4.40", - "preview-utils": "workspace:*", "prism-react-renderer": "2.1.0", "react": "^19", "react-dom": "^19", diff --git a/packages/react-email/src/actions/get-emails-directory-metadata.ts b/packages/react-email/src/actions/get-emails-directory-metadata.ts index 6234a2ba97..8ed293492a 100644 --- a/packages/react-email/src/actions/get-emails-directory-metadata.ts +++ b/packages/react-email/src/actions/get-emails-directory-metadata.ts @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import fs from 'node:fs'; import path from 'node:path'; -import { isFileAnEmail } from 'preview-utils'; +import { isFileAnEmail } from '../package'; export interface EmailsDirectory { absolutePath: string; diff --git a/packages/react-email/src/actions/render-email-by-path.tsx b/packages/react-email/src/actions/render-email-by-path.tsx index 5042502af3..5858e5e0e6 100644 --- a/packages/react-email/src/actions/render-email-by-path.tsx +++ b/packages/react-email/src/actions/render-email-by-path.tsx @@ -3,8 +3,8 @@ import path from 'node:path'; import ora from 'ora'; import logSymbols from 'log-symbols'; import chalk from 'chalk'; -import type { RenderedEmailMetadata } from 'preview-utils'; -import { renderEmailByPath } from 'preview-utils'; +import type { RenderedEmailMetadata } from '../package'; +import { renderEmailByPath } from '../package'; import { fromError, type ErrorObject } from '../utils/types/error-object'; import { registerSpinnerAutostopping } from '../utils/register-spinner-autostopping'; diff --git a/packages/react-email/src/cli/commands/export.ts b/packages/react-email/src/cli/commands/export.ts index 32d8e0ec5a..f0663614b8 100644 --- a/packages/react-email/src/cli/commands/export.ts +++ b/packages/react-email/src/cli/commands/export.ts @@ -13,7 +13,7 @@ import { EmailsDirectory, getEmailsDirectoryMetadata, } from '../../actions/get-emails-directory-metadata'; -import { renderingUtilitiesExporter } from 'preview-utils'; +import { renderingUtilitiesExporter } from '../../package'; const getEmailTemplatesFromDirectory = (emailDirectory: EmailsDirectory) => { const templatePaths = [] as string[]; diff --git a/packages/react-email/src/hooks/use-rendering-metadata.ts b/packages/react-email/src/hooks/use-rendering-metadata.ts index a24e085c7a..0e51966b45 100644 --- a/packages/react-email/src/hooks/use-rendering-metadata.ts +++ b/packages/react-email/src/hooks/use-rendering-metadata.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import type { RenderedEmailMetadata } from 'preview-utils'; +import type { RenderedEmailMetadata } from '../package'; import type { ActionResult } from '../actions/render-email-by-path'; const lastRenderingMetadataPerEmailPath = {} as Record< diff --git a/packages/react-email/src/package/index.ts b/packages/react-email/src/package/index.ts new file mode 100644 index 0000000000..a1475bea1d --- /dev/null +++ b/packages/react-email/src/package/index.ts @@ -0,0 +1 @@ +export * from './preview-utils'; diff --git a/packages/preview-utils/src/get-email-component.spec.ts b/packages/react-email/src/package/preview-utils/get-email-component.spec.ts similarity index 100% rename from packages/preview-utils/src/get-email-component.spec.ts rename to packages/react-email/src/package/preview-utils/get-email-component.spec.ts diff --git a/packages/preview-utils/src/get-email-component.ts b/packages/react-email/src/package/preview-utils/get-email-component.ts similarity index 100% rename from packages/preview-utils/src/get-email-component.ts rename to packages/react-email/src/package/preview-utils/get-email-component.ts diff --git a/packages/preview-utils/src/index.ts b/packages/react-email/src/package/preview-utils/index.ts similarity index 100% rename from packages/preview-utils/src/index.ts rename to packages/react-email/src/package/preview-utils/index.ts diff --git a/packages/preview-utils/src/is-file-an-email.ts b/packages/react-email/src/package/preview-utils/is-file-an-email.ts similarity index 100% rename from packages/preview-utils/src/is-file-an-email.ts rename to packages/react-email/src/package/preview-utils/is-file-an-email.ts diff --git a/packages/preview-utils/src/render-email-by-path.ts b/packages/react-email/src/package/preview-utils/render-email-by-path.ts similarity index 100% rename from packages/preview-utils/src/render-email-by-path.ts rename to packages/react-email/src/package/preview-utils/render-email-by-path.ts diff --git a/packages/preview-utils/src/utils/email-template.ts b/packages/react-email/src/package/preview-utils/utils/email-template.ts similarity index 100% rename from packages/preview-utils/src/utils/email-template.ts rename to packages/react-email/src/package/preview-utils/utils/email-template.ts diff --git a/packages/preview-utils/src/utils/improve-error-with-source-map.ts b/packages/react-email/src/package/preview-utils/utils/improve-error-with-source-map.ts similarity index 100% rename from packages/preview-utils/src/utils/improve-error-with-source-map.ts rename to packages/react-email/src/package/preview-utils/utils/improve-error-with-source-map.ts diff --git a/packages/preview-utils/src/utils/rendering-utilities-exporter.ts b/packages/react-email/src/package/preview-utils/utils/rendering-utilities-exporter.ts similarity index 100% rename from packages/preview-utils/src/utils/rendering-utilities-exporter.ts rename to packages/react-email/src/package/preview-utils/utils/rendering-utilities-exporter.ts diff --git a/packages/preview-utils/src/utils/static-node-modules-for-vm.ts b/packages/react-email/src/package/preview-utils/utils/static-node-modules-for-vm.ts similarity index 100% rename from packages/preview-utils/src/utils/static-node-modules-for-vm.ts rename to packages/react-email/src/package/preview-utils/utils/static-node-modules-for-vm.ts diff --git a/packages/react-email/tsup.config.ts b/packages/react-email/tsup.config.ts index 90073db127..b8682ebf98 100644 --- a/packages/react-email/tsup.config.ts +++ b/packages/react-email/tsup.config.ts @@ -1,9 +1,16 @@ import { defineConfig } from 'tsup'; -export default defineConfig({ - dts: true, - entry: ['./src/cli/index.ts'], - noExternal: ['preview-utils'], - format: ['esm', 'cjs'], - outDir: 'dist/cli', -}); +export default defineConfig([ + { + dts: true, + entry: ['./src/cli/index.ts'], + format: ['esm', 'cjs'], + outDir: 'dist/cli', + }, + { + dts: true, + entry: ['./src/package/index.ts'], + format: ['esm', 'cjs'], + outDir: 'dist/package', + }, +]); diff --git a/packages/visual-studio-code-extension/package.json b/packages/visual-studio-code-extension/package.json index b68e947817..7f9969b65b 100644 --- a/packages/visual-studio-code-extension/package.json +++ b/packages/visual-studio-code-extension/package.json @@ -40,7 +40,7 @@ }, "scripts": { "publish": "vsce publish", - "package": "pnpm build && node ./prebuild.mjs && vsce package", + "package": "node ./prebuild.mjs && vsce package", "vscode:prepublish": "pnpm build --minify", "dev": "pnpm build --watch", "build": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --tsconfig=./tsconfig.json --external:vscode --external:esbuild --format=cjs --platform=node", @@ -73,7 +73,7 @@ "esbuild": "^0.19.12" }, "devDependencies": { - "preview-utils": "workspace:*", + "react-email": "workspace:*", "@types/mocha": "^10.0.2", "@types/node": "18.x", "@types/vscode": "^1.83.0", diff --git a/packages/visual-studio-code-extension/src/render-open-email-file.ts b/packages/visual-studio-code-extension/src/render-open-email-file.ts index 6a3cdfad4a..6c5424d527 100644 --- a/packages/visual-studio-code-extension/src/render-open-email-file.ts +++ b/packages/visual-studio-code-extension/src/render-open-email-file.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode"; import * as path from "path"; -import { isFileAnEmail, renderEmailByPath } from "preview-utils"; +import { isFileAnEmail, renderEmailByPath } from "react-email"; export type BuiltEmail = | { @@ -41,7 +41,6 @@ export async function renderOpenEmailFile( const err = new Error(result.error.message); err.stack = result.error.stack; err.name = result.error.name; - err.cause = result.error.cause; throw err; } diff --git a/packages/visual-studio-code-extension/tsconfig.json b/packages/visual-studio-code-extension/tsconfig.json index bbd3d4b865..f98bc4a97a 100644 --- a/packages/visual-studio-code-extension/tsconfig.json +++ b/packages/visual-studio-code-extension/tsconfig.json @@ -7,6 +7,7 @@ "ES2020", "DOM" ], + "esModuleInterop": true, "sourceMap": true, "rootDir": "src", "strict": true /* enable all strict type-checking options */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27cb93b331..1629750b4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -952,25 +952,6 @@ importers: specifier: 5.1.6 version: 5.1.6 - packages/preview-utils: - dependencies: - esbuild: - specifier: 0.19.11 - version: 0.19.11 - source-map-js: - specifier: 1.0.2 - version: 1.0.2 - stacktrace-parser: - specifier: 0.1.10 - version: 0.1.10 - devDependencies: - '@react-email/render': - specifier: workspace:* - version: link:../render - tsconfig: - specifier: workspace:* - version: link:../tsconfig - packages/react-email: dependencies: '@babel/core': @@ -1088,9 +1069,6 @@ importers: postcss: specifier: 8.4.40 version: 8.4.40 - preview-utils: - specifier: workspace:* - version: link:../preview-utils prism-react-renderer: specifier: 2.1.0 version: 2.1.0(react@19.0.0) @@ -1426,9 +1404,9 @@ importers: mocha: specifier: ^10.2.0 version: 10.8.2 - preview-utils: + react-email: specifier: workspace:* - version: link:../preview-utils + version: link:../react-email typescript: specifier: ^5.2.2 version: 5.4.2