0

I'm trying to build the TypeScript project here as

git clone https://github.com/simpleledger/BitcoinFilesJS.git test/
cd test
npm i
tsc # or npx tsc

The index.js created is this:

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./lib/bfp"), exports);
__exportStar(require("./lib/utils"), exports);
//# sourceMappingURL=index.js.map

However, if I install the project as in a new directory with npm i bitcoinfiles, the index.js is:

let bfp = require('./lib/bfp');
let utils = require('./lib/utils');
let network = require('./lib/network');

module.exports = {
    bfp: bfp,
    utils: utils, 
    network: network
}

What could be causing TypeScript to generate my unclean index.js? In addition, they don't work. As you can see, the unclean index.js doesn't define module.exports

2
  • You need to use the build script defined in the package.json Commented Apr 4, 2021 at 17:21
  • No, that doesn't work, it invokes tsc which is what fails. Commented Apr 4, 2021 at 18:55

1 Answer 1

1

I just recreated the index.js successfully from a checkout of the release-tagged code at https://github.com/simpleledger/BitcoinFilesJS/tree/0.5.0 by running npm run build

let bfp = require('./lib/bfp');
let utils = require('./lib/utils');
let network = require('./lib/network');

module.exports = {
    bfp: bfp,
    utils: utils, 
    network: network
}

Be aware that the main/master branch of any repo might be where work is going on, and released versions could be different. Currently the main branch of this repo seems to target ES5 which transpiles differently.

Currently this only builds successfully by manually creating the dist directory and probably requires manual install of typescript and browserify which I guess is just installed globally in the authors machine so they didn't realise they were missing these dependencies.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.