I am trying to convert my index.ts
file into a UMD index.js
so that I can use it with a <script>
tag. Here is the TypeScript configuration I am using:
{
"compilerOptions": {
"outDir": "dist",
"declaration": true,
"module": "UMD",
"target": "ES6",
"moduleResolution": "node",
"strict": true
},
"include": ["src/**/*.ts", "tests/**/*.ts"]
}
When I compile the file, the generated index.js
is not as expected. It seems to be creating multiple files instead of one unique file. Here is the output:
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./embedTypes/container", "./embedTypes/popup", "./embedTypes/chat"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const container_1 = require("./embedTypes/container");
const popup_1 = require("./embedTypes/popup");
const chat_1 = require("./embedTypes/chat");
const Typebot = {
initContainer: container_1.initContainer,
initPopup: popup_1.initPopup,
initBubble: chat_1.initBubble,
};
exports.default = Typebot;
});
I am not sure what I am missing in the configuration. Any help or suggestions would be greatly appreciated. Thank you!