2
0

🏗️ Use tsup for bot and typebot-js packages

This commit is contained in:
Baptiste Arnaud
2022-10-10 08:28:11 +02:00
committed by Baptiste Arnaud
parent 0b58f4e976
commit 84163c6585
27 changed files with 474 additions and 739 deletions

View File

@ -4,7 +4,6 @@ tests
.eslintignore
.eslintrc.js
jest.config.js
rollup.config.js
tsconfig.json
examples
__mocks__

View File

@ -11,16 +11,12 @@
margin: 0;
}
</style>
<script src="../dist/index.umd.min.js"></script>
<script src="../dist/index.global.js"></script>
</head>
<body>
<script>
const { open } = Typebot.initBubble({
Typebot.initBubble({
url: 'https://typebot.io/typebot-support',
button: {
color: 'green',
iconUrl: 'https://image.flaticon.com/icons/png/512/5138/5138352.png',
},
proactiveMessage: {
avatarUrl:
'https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80',
@ -31,7 +27,10 @@
})
</script>
<div style="width: 100%; height: 300vh; background-color: aquamarine">
<button onclick="(()=>{open()})()" style="width: 200px; height: 60px">
<button
onclick="Typebot.getBubbleActions().open()"
style="width: 200px; height: 60px"
>
OPEN CHAT
</button>
</div>

View File

@ -23,17 +23,19 @@
<div id="typebot-container-2" style="width: 1000px; height: 600px"></div>
</div>
<div id="typebot-container-3" style="width: 1000px; height: 600px"></div>
<script src="../dist/index.umd.min.js"></script>
<script src="../dist/index.global.js"></script>
<script>
Typebot.initContainer("typebot-container", { publishId: "jamhouse" });
Typebot.initContainer("typebot-container-2", {
publishId: "lead-generation",
});
Typebot.initContainer("typebot-container-3", {
publishId: "feedback-form",
Typebot.initContainer('typebot-container', {
url: 'https://viewer.typebot.io/lead-generation-copy-c3yiqz1',
})
Typebot.initContainer('typebot-container-2', {
url: 'https://viewer.typebot.io/kebab',
})
Typebot.initContainer('typebot-container-3', {
url: 'https://viewer.typebot.io/typebot-support',
loadWhenVisible: false,
});
})
</script>
</body>
</html>

View File

@ -13,12 +13,12 @@
</style>
</head>
<body>
<script src="../dist/index.umd.min.js"></script>
<script src="../dist/index.global.js"></script>
<script>
const { open } = Typebot.initPopup({
publishId: "feedback-form",
publishId: 'feedback-form',
delay: 1000,
});
})
</script>
<div style="width: 100%; height: 300vh; background-color: aquamarine">
<button onclick="(()=>{open()})()">CLICK</button>

View File

@ -5,28 +5,24 @@
"unpkg": "dist/index.umd.min.js",
"license": "AGPL-3.0-or-later",
"scripts": {
"dev": "pnpm rollup -c --watch",
"build": "pnpm lint && rollup -c",
"dev": "tsup --watch",
"build": "tsup",
"lint": "eslint src --ext .ts && eslint tests --ext .ts",
"test": "pnpm jest"
},
"devDependencies": {
"jest-environment-jsdom": "29.1.2",
"@rollup/plugin-typescript": "8.5.0",
"@types/jest": "29.1.2",
"@typescript-eslint/eslint-plugin": "5.39.0",
"@typescript-eslint/parser": "5.39.0",
"baptistearno-tsup": "^0.1.0",
"eslint": "8.25.0",
"eslint-plugin-functional": "4.4.1",
"eslint-plugin-jest": "27.1.1",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.1.2",
"jest-environment-jsdom": "29.1.2",
"prettier": "2.7.1",
"rollup": "2.79.1",
"rollup-plugin-styles": "4.0.0",
"rollup-plugin-terser": "7.0.2",
"ts-jest": "29.0.3",
"tslib": "2.4.0",
"typescript": "4.8.4"
}
}

View File

@ -1,26 +0,0 @@
import typescript from "@rollup/plugin-typescript";
import { terser } from "rollup-plugin-terser";
import styles from "rollup-plugin-styles";
export default [
// ES Modules
{
input: "src/index.ts",
output: {
file: "dist/index.js",
format: "cjs",
},
plugins: [typescript({ tsconfig: "./tsconfig.json" }), styles()],
},
// UMD
{
input: "src/index.ts",
output: {
file: "dist/index.umd.min.js",
format: "umd",
name: "Typebot",
},
plugins: [typescript({ tsconfig: "./tsconfig.json" }), terser(), styles()],
},
];

View File

@ -0,0 +1,11 @@
import { defineConfig } from 'baptistearno-tsup'
export default defineConfig((options) => ({
entry: ['src/index.ts'],
sourcemap: true,
minify: !options.watch,
dts: true,
format: ['esm', 'cjs', 'iife'],
globalName: 'Typebot',
injectStyle: true,
}))