Skip to content

Commit

Permalink
🧑‍💻 Fix type resolution for @typebot.io/react and nextjs
Browse files Browse the repository at this point in the history
Closes #968
  • Loading branch information
baptisteArno committed Oct 26, 2023
1 parent 3f7f094 commit 31b3fc3
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/embeds/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.2.9",
"version": "0.2.10",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
5 changes: 3 additions & 2 deletions packages/embeds/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.2.9",
"version": "0.2.10",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -22,9 +22,9 @@
"@rollup/plugin-terser": "0.4.3",
"@rollup/plugin-typescript": "11.1.2",
"@typebot.io/js": "workspace:*",
"@typebot.io/react": "workspace:*",
"@typebot.io/lib": "workspace:*",
"@typebot.io/prisma": "workspace:*",
"@typebot.io/react": "workspace:*",
"@typebot.io/schemas": "workspace:*",
"@typebot.io/tsconfig": "workspace:*",
"@types/node": "20.4.2",
Expand All @@ -33,6 +33,7 @@
"eslint-config-custom": "workspace:*",
"react": "18.2.0",
"rollup": "3.26.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-typescript-paths": "1.4.0",
"tslib": "2.6.0",
"tsx": "3.12.7",
Expand Down
20 changes: 19 additions & 1 deletion packages/embeds/nextjs/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { babel } from '@rollup/plugin-babel'
import typescript from '@rollup/plugin-typescript'
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
import alias from '@rollup/plugin-alias'
import { dts } from 'rollup-plugin-dts'

const extensions = ['.ts', '.tsx']

Expand Down Expand Up @@ -33,6 +34,23 @@ const indexConfig = {
],
}

const configs = [indexConfig]
const typesConfig = {
input: './src/index.ts',
output: [{ file: './dist/index.d.ts', format: 'es' }],
plugins: [
alias({
entries: [
{ find: '@typebot.io/js', replacement: '../../js' },
{
find: '@/types',
replacement: '../types',
},
],
}),
dts(),
],
}

const configs = [indexConfig, typesConfig]

export default configs
33 changes: 23 additions & 10 deletions packages/embeds/nextjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
import type {
BotProps,
PopupProps,
BubbleProps,
} from '@typebot.io/js/dist/index'
import dynamic from 'next/dynamic'

export const Standard = dynamic(
() => import('@typebot.io/react/src/Standard'),
{ ssr: false }
)
export const Standard: React.ComponentType<
BotProps & {
style?: React.CSSProperties
className?: string
}
> = dynamic(() => import('@typebot.io/react/src/Standard'), { ssr: false })

export const Popup = dynamic(() => import('@typebot.io/react/src/Popup'), {
ssr: false,
})
export const Popup: React.ComponentType<PopupProps> = dynamic(
() => import('@typebot.io/react/src/Popup'),
{
ssr: false,
}
)

export const Bubble = dynamic(() => import('@typebot.io/react/src/Bubble'), {
ssr: false,
})
export const Bubble: React.ComponentType<BubbleProps> = dynamic(
() => import('@typebot.io/react/src/Bubble'),
{
ssr: false,
}
)

export * from '@typebot.io/js'
5 changes: 1 addition & 4 deletions packages/embeds/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"paths": {
"@/*": ["src/*"]
},
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"emitDeclarationOnly": true
"outDir": "dist"
}
}
3 changes: 2 additions & 1 deletion packages/embeds/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.2.9",
"version": "0.2.10",
"description": "Convenient library to display typebots on your React app",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -37,6 +37,7 @@
"eslint-config-custom": "workspace:*",
"react": "18.2.0",
"rollup": "3.26.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-typescript-paths": "1.4.0",
"tslib": "2.6.0",
"tsx": "3.12.7",
Expand Down
20 changes: 19 additions & 1 deletion packages/embeds/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { babel } from '@rollup/plugin-babel'
import typescript from '@rollup/plugin-typescript'
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
import alias from '@rollup/plugin-alias'
import { dts } from 'rollup-plugin-dts'

const extensions = ['.ts', '.tsx']

Expand Down Expand Up @@ -31,6 +32,23 @@ const indexConfig = {
],
}

const configs = [indexConfig]
const typesConfig = {
input: './src/index.ts',
output: [{ file: './dist/index.d.ts', format: 'es' }],
plugins: [
alias({
entries: [
{ find: '@typebot.io/js', replacement: '../../js' },
{
find: '@/types',
replacement: '../types',
},
],
}),
dts(),
],
}

const configs = [indexConfig, typesConfig]

export default configs
5 changes: 1 addition & 4 deletions packages/embeds/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"paths": {
"@/*": ["src/*"]
},
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"emitDeclarationOnly": true
"outDir": "dist"
}
}
25 changes: 24 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 comments on commit 31b3fc3

@vercel
Copy link

@vercel vercel bot commented on 31b3fc3 Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 31b3fc3 Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 31b3fc3 Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

silvercop.online
stan.vselise.com
typebot.aloe.bot
vidalimentar.com
voicehelp.cr8.ai
web.bjogador.com
webwhatsapp.work
whatisappweb.com
www.pantaflow.ai
zap.fundviser.in
acordocorreto.com
akses.sifucrm.com
analistamines.com
app.bouclidom.com
app.chatforms.net
appbotcontato.com
appmillion.online
averdadehoje.site
bot.cerograsa.com
bot.chatbotcv.com
bot.hostnation.de
bot.ketoolife.com
bot.phuonghub.com
bot.reviewamp.com
bot.reviewzer.com
bot.thegymgame.it
bot.uluhub.com.br
cares.urlabout.me
chat.ezbooking.ai
chat.gaswadern.de
chat.gniorder.com
chat.leadmagic.io
chat.onrentme.com
chat.rojie.online
chatdocidadao.com
chatwebonline.com
ds-leadmagnet.com
encode.share5.net
fmm.wpwakanda.com
footballmeetup.ie
gentleman-shop.fr
island.wakanda.is
jetpixoficial.com
k1.kandabrand.com
kp.pedroknoll.com
kylebot.goafk.com
lb.ticketfute.com
mariwelash.com.br
metodoelev.com.br
nutriandreia.shop
bot.barrettamario.it
bot.buenanoticia.fun
bot.conhecaojogo.com
bot.cotemeuplano.com
bot.gameincrivel.com
bot.gamesimples.club
bot.grupodojo.com.br
bot.jogodofuturo.com
bot.jogoquelucra.com
bot.mycompay.reviews
bot.projetodashi.com
bot.socialcliques.me
bt.49educacao.com.br
cha.onewebcenter.com
chat.febredojogo.com
chat.gnipharmahq.com
chat.hayurihijab.com
chat.jottagreens.com
chatbee.agfunnel.com
click.sevenoways.com
compleat.jetdigi.com
connect.growthguy.in
detetivepatricia.com
drapamela.gikpro.com
drgisellegarcia.site
eljogadoroficial.com
encodebot.share5.net
forms.bonanza.design
hello.advergreen.com
infomakeracademy.com
kuiz.sistemniaga.com
leoborges-app.online
linspecteuremma.site
malayanboosterhq.com
menukb.wpwakanda.com
offer.botscientis.us
ore.barrettamario.it
sellmycarglasgow.com
site100seguro.online
solicitarcartao.shop
stephanesampa.online
superglicemia.com.br
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
whats.clickgames.app
www.acordo-certo.com
www.epicbrain.com.br
83701274.21000000.lol
87186327.21000000.one

Please sign in to comment.