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

Add auto-generated files in <my_dash_component> to the .gitignore #19

Closed
wilzbach opened this issue Oct 11, 2018 · 1 comment
Closed

Comments

@wilzbach
Copy link

Hi there,

So I was just interested whether there's a reasoning behind committing the auto-generated files in my_dash_component into git and not adding them to the .gitignore?
And subsequently whether you would accept a PR to the .gitignore for this?
(Though it probably makes sense to wait for #14 if that PR will be merged in the near future.)

Anyhow, I'm guessing that committing the generated files into git has the motivation that it simplifies deployment to e.g. Heroku?

Though for Heroku it's easy to add multiple buildpacks, e.g.

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git
cat > .buildpacks << EOF
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-python.git
EOF

The only "tricky" bit is to split up the build:py into a step that can be run during the nodejs build stage and one that can be run later during the Python build stage:

  "scripts": {
...
    "build:py-js": "node ./extract-meta src/lib/components > my_dash_component/metadata.json && copyfiles package.json my_dash_component",
    "build:py-py": "python -c \"import dash; dash.development.component_loader.generate_classes('my_dash_component', 'my_dash_component/metadata.json')\"",
    "build:py": "npm run build:py-js && npm run build:py-py",
...
    "postinstall": "npm run build:js && npm run build:py-js"
  },
mkdir bin
cat > bin/post-compile << EOF
#!/bin/bash
# Generates the Dash components (requires all Python dependencies to be installed)

npm run build:py-py
EOF
@chriddyp
Copy link
Member

Anyhow, I'm guessing that committing the generated files into git has the motivation that it simplifies deployment to e.g. Heroku?

Yeah, we commit the build files for a couple of reasons:

  • Users can git clone the project and then directly import the library. This is helpful for reviews and prereleases as it reduces the friction for community users to try out the library or different branches.
  • In reviews, it's helpful for us to see whether build files changed or not and another sanity check that the build process is working for them.
  • The files that we have in the repo are directly what we have on PyPI. By building and committing the files, it provides yet another sanity check on what we're publishing.

These things are pretty opinionated (it's uncommon to commit build files) but we've found that it works well for our own development teams. You're welcome to modify this process yourself in your own components, but I think I'd like to keep this boilerplate representative of our own internal processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants