Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(echo): Use tsup for building distributable #5658

Merged
merged 7 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/e2e/echo.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as http from 'http';
import * as express from 'express';
// FIXME: subpath import not working with `workspace:` protocol. Currently we need to drill into the module instead of using the ES export.
import { serve } from '../../../packages/echo/dist/src/express';
import { serve } from '../../../packages/echo/dist/express';
import { Echo } from '@novu/echo';

class EchoServer {
Expand Down
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@faker-js/faker": "^6.0.0",
"@nestjs/cli": "^10.1.16",
"@nestjs/schematics": "^10.0.2",
"@nestjs/testing": "^10.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/echo/.eslintrc.js → packages/echo/.eslintrc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
extends: ['../../.eslintrc.js'],
parserOptions: {
project: './tsconfig.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* https://jestjs.io/docs/configuration
*/

module.exports = {
export default {
/*
* All imported modules in your tests should be mocked automatically
* automock: false,
Expand Down
41 changes: 20 additions & 21 deletions packages/echo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@novu/echo",
"version": "0.24.3-alpha.0",
"description": "The Code-First Notifications Workflow SDK.",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand All @@ -17,10 +17,8 @@
"lint:fix": "eslint src --ext .ts --fix",
"format": "prettier --check --ignore-path .gitignore .",
"format:fix": "prettier --write --ignore-path .gitignore .",
"clean": "rm -rf ./dist",
"prebuild": "rimraf dist",
"build": "pnpm run clean && tsc --build",
"build:watch": "tsc --build --watch",
"build": "tsup",
"build:watch": "tsup --watch",
"$comment:bump:prerelease": "This is a workaround to support `npm version prerelease` with lerna",
"bump:prerelease": "npm version prerelease --preid=alpha & PID=$!; (sleep 1 && kill -9 $PID) & wait $PID",
"release:alpha": "pnpm bump:prerelease || pnpm build && npm publish"
Expand All @@ -45,29 +43,29 @@
"license": "MIT",
"exports": {
".": {
"require": "./dist/src/index.js",
"import": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./express": {
"require": "./dist/src/express.js",
"import": "./dist/src/express.js",
"types": "./dist/src/express.d.ts"
"require": "./dist/express.js",
"import": "./dist/express.mjs",
"types": "./dist/express.d.ts"
},
"./next": {
"require": "./dist/src/next.js",
"import": "./dist/src/next.js",
"types": "./dist/src/next.d.ts"
"require": "./dist/next.js",
"import": "./dist/next.mjs",
"types": "./dist/next.d.ts"
},
"./nuxt": {
"require": "./dist/src/nuxt.js",
"import": "./dist/src/nuxt.js",
"types": "./dist/src/nuxt.d.ts"
"require": "./dist/nuxt.js",
"import": "./dist/nuxt.mjs",
"types": "./dist/nuxt.d.ts"
},
"./h3": {
"require": "./dist/src/h3.js",
"import": "./dist/src/h3.js",
"types": "./dist/src/h3.d.ts"
"require": "./dist/h3.js",
"import": "./dist/h3.mjs",
"types": "./dist/h3.d.ts"
}
},
"devDependencies": {
Expand All @@ -84,6 +82,7 @@
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/echo/src/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Either } from './types';
import { type SupportedFrameworkName } from './types';
import { getResponse } from './utils';

export const frameworkName: SupportedFrameworkName = 'nextjs';
export const frameworkName: SupportedFrameworkName = 'next';

/**
* In Next.js, serve and register any declared workflows with Echo, making
Expand Down
2 changes: 1 addition & 1 deletion packages/echo/src/types/framework.types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type SupportedFrameworkName = 'nextjs' | 'express' | 'nuxt' | 'h3';
export type SupportedFrameworkName = 'next' | 'express' | 'nuxt' | 'h3';
4 changes: 2 additions & 2 deletions packages/echo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES2019",
"module": "CommonJS",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"skipLibCheck": true,
"resolveJsonModule": true,
Expand Down
12 changes: 0 additions & 12 deletions packages/echo/tsconfig.module.json

This file was deleted.

17 changes: 17 additions & 0 deletions packages/echo/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from 'tsup';
import { type SupportedFrameworkName } from './src';

const frameworks: SupportedFrameworkName[] = ['h3', 'express', 'next', 'nuxt'];

export default defineConfig({
entry: ['src/index.ts', ...frameworks.map((framework) => `src/${framework}.ts`)],
sourcemap: false,
clean: true,
treeshake: true,
dts: true,
format: ['cjs', 'esm'],
minify: true,
minifyWhitespace: true,
minifyIdentifiers: true,
minifySyntax: true,
});
Loading
Loading