jiff icon indicating copy to clipboard operation
jiff copied to clipboard

Build fails without manual TypeScript compilation

Open arberiii opened this issue 11 months ago • 2 comments

  • I'm submitting a ...

    • [x] bug report
    • [ ] feature request
    • [ ] support request
  • What is the current behavior? When trying to run the project (either through npm run build or npm run tutorial) without first compiling TypeScript files, the following error occurs:

Cannot find module '../build/linkedlist.js' from '/Users/arberavdullahu/jiff/lib/jiff-client.js'
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem First delete the build directory rm -rf build and then run npm run build

  • What is the expected behavior? The build and tutorial commands should work without requiring manual TypeScript compilation. The TypeScript compilation step should be handled automatically as part of the build process.

  • What is the motivation / use case for changing the behavior? This issue was introduced in PR #279. The current behavior requires users to manually run tsc -p lib/common/tsconfig.json before running any commands, which is not intuitive and can lead to confusion. This creates a poor developer experience and may prevent new users from getting started with the project.

  • Please tell us about your environment:

    • JIFF Version: 1.0.0/latest
    • Node Version: v23.7.0
    • Browser: all
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc)

Suggested fix:

  1. Add TypeScript compilation as a prerequisite step in the build and tutorial scripts
  2. Update documentation to clarify the build process
  3. Consider adding a pre-build hook to ensure TypeScript is always compiled before running other commands

arberiii avatar Mar 18 '25 13:03 arberiii

I received an email from someone about this very issue recently. I can indeed replicate it on my machine.

I fixed it with the following steps:

# I cloned jiff into some /some/path/jiff
cd /some/path/jiff
npm install && npm install --dev   # installs all dependencies including dev dependencies
cd lib/common && npx tsc  # build type script files located under lib/common, if successful, output files will appear under /some/path/jiff/build

Then, I ran the sum demo for testing:

# in terminal 1:
cd /some/path/jiff
node demos/sum/server.js
# in terminal 2:
node demos/sum/party.js 10 2

Then, I opened http://localhost:8080/demos/sum/client.html in my browser, clicked connect, then entered input 30 and clicked sum. The output was 40 as expected.

In terms of fixes: your suggestions are good. It is a good idea to at least add the build steps to package.json scripts (perhaps as the first step in build). One confusing thing is that attempting to simply run npx tsc in the repo root does not work, because build/ then ends up containing a different directory hierarchy (plus some other ts files error out).

KinanBab avatar Mar 20 '25 04:03 KinanBab

I opened a quick PR with the fix

arberiii avatar Mar 20 '25 18:03 arberiii