My TypeScript 4.8.4 library is being packaged with npm. Within my package.json
, I have a "bin"
section that includes several utility scripts for consumers of the package.
"bin": {
"generate-docs": "./docs/docs.py",
"configure-this-and-that": "lib/configure-this-and-that.js",
"register-things": "lib/data/register-things.js"
}
The issue I am facing is that simply importing the package triggers the execution of all these scripts. This behavior started occurring after upgrading to TypeScript 4.8. Previously, this was not an issue with TS 3.7.
import { Anything } from 'my-package-from-above';
// This causes the files in "bin" above to run
const anything = new Anything();
console.log('Done');
Is this a new behavior in TS4? Or could it be related to the package.json configuration?
Edit The class that is being executed upon import looks like this. Is there something in its structure that could be causing this issue?
#!/usr/bin/env node
import { DeployUtility } from './deploy-utility';
const deployUtility = new DeployUtility();
deployUtility.configureDomainMapping().then(data => {
return data;
});
The issue is that the contents of this class execute whenever the package is imported, even if the importing code is not directly using this specific class.