Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the default to not npm build #1512

Closed
chadoh opened this issue Jul 31, 2024 · 8 comments · Fixed by #1731
Closed

Change the default to not npm build #1512

chadoh opened this issue Jul 31, 2024 · 8 comments · Fixed by #1731
Assignees

Comments

@chadoh
Copy link
Contributor

chadoh commented Jul 31, 2024

What problem does your feature solve?

Some pro users don't want to use our TS Bindings because a whole NPM package feels too heavy.

What would you like to see?

Let's add a --file-only option to the bindings typescript command that will:

  • honor the --output-dir option, and emit only [output-dir]/index.ts (NOT [output-dir]/src/index.ts)

  • output a message to stdout (or stderr, whatever the rest of the file is doing) saying:

     Created [output-dir]/index.ts. NOTE: You must have an NPM project configured with:
    
      - typescript@[version from template's package.json] or compatible version
      - @stellar/stellar-sdk@[version from template's package.json] or compatible version
      - buffer@[version from template's package.json] or compatible version
    

Print that you need node and npm installed

What alternatives are there?

Don't

@chadoh chadoh added this to DevX Jul 31, 2024
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Jul 31, 2024
@leighmcculloch
Copy link
Member

leighmcculloch commented Aug 5, 2024

I'm not sure the bindings generate command should output an incomplete view of the generated bindings. The bindings generated are dependent on a specific version of the js-stellar-sdk and other dependencies, and so outputting an incomplete bundle seems like it would set folks up for failure. The suggested output helps.

I'd like to understand what the specific inconvenience is. For folks who don't want the whole NPM package they can generate the bindings and copy out the index.ts file and discard the rest, so the workflow described in the issue is already supported.

Is the inconvenient piece of the existing workflow doing a cp index.ts newlocation out of the bundle?

Or is the inconvenient piece that bindings call npm install or npm whateveritdoes?

If it's the latter, then I think it'd make sense to add an option to skip the npm executions. It removes the inconvenient piece for folks who want to take the typescript elsewhere. It serves other use cases where someone wants to do the npm piece just not right now or not on this system.

@janewang
Copy link
Contributor

janewang commented Aug 6, 2024

Copying out the index.ts suffices the user case. The CLI doesn't need another flag to just help user remove some files.

@chadoh
Copy link
Contributor Author

chadoh commented Aug 6, 2024

Great points. I like the idea of adding a --no-install option instead. Or maybe --no-build, since it would not be able to build the package if it did not install the dependencies.

@leighmcculloch
Copy link
Member

leighmcculloch commented Aug 6, 2024

--no-build

👍🏻

@janewang
Copy link
Contributor

janewang commented Aug 6, 2024

After discussion, we agreed to changing the default behavior to not build. We will not add any flags.

@janewang janewang changed the title TS Bindings: --file-only option Change the default to not npm build Aug 6, 2024
@janewang janewang moved this from Backlog (Not Ready) to Todo (Ready for Dev) in DevX Aug 6, 2024
@leighmcculloch
Copy link
Member

changing the default behavior to not build

Part of the reason was that someone pointed out that in other ecosystems like solidity the code gen just generates files and it's up to the user to run npm commands.

Given that it is easy to call && npm ... after codegen that seems like a reasonable default.

@leighmcculloch
Copy link
Member

Created [output-dir]/index.ts. NOTE: You must have an NPM project configured with:

  - typescript@[version from template's package.json] or compatible version
  - @stellar/stellar-sdk@[version from template's package.json] or compatible version
  - buffer@[version from template's package.json] or compatible version

+1 When removing the calls to npm it's pretty important we educate the user on what got generated and what they need to do to use it, so it's pretty critical we include output like this.

@leighmcculloch
Copy link
Member

@github-project-automation github-project-automation bot moved this from Todo (Ready for Dev) to Done in DevX Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants