I'm currently working on developing an npm module that is intended for use in web browsers.
For this project, I have chosen to utilize TypeScript and Rollup as my tools of choice.
Here is a snippet of my tsconfig.json
:
{
"compilerOptions": {
"module": "CommonJS",
"outDir": "lib",
"strict": true,
"rootDir": "src"
}
}
Additionally, here is a glimpse at my rollup.config.js
:
import typescript from "@rollup/plugin-typescript";
export default {
input: "src/index.ts",
output: {
dir: "lib",
format: "iife",
},
plugins: [typescript()],
};
Within the file src/index.ts
, you can find the following code:
// src/index.ts
import log from './log'
const myFn = () => {
...myFn code
}
The issue I am facing is evident in the bundled code snippet below:
// lib/index.js bundle
var log_1 = require("./log");
My goal is to include the contents of the log
file directly within the main lib/index.js
file during bundling.
Is there a way to achieve this using TypeScript and Rollup?
It's worth mentioning that I previously attempted to use outFile
(referencing the TypeScript documentation), but it seems that this feature is not supported by the "@rollup/plugin-typescript".
Could the solution involve manually compiling with tsc before proceeding with the Rollup bundling?