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 build fixups + use Artifacts #13

Merged
merged 12 commits into from
Dec 13, 2021

Conversation

Felix-Gauthier
Copy link
Collaborator

@Felix-Gauthier Felix-Gauthier commented Dec 9, 2021

This is following 2 other closed PRs (#10 and #12) made I was getting familiar working with a "Dash component project", so to speak.

Third time's the charm!

Resolves #11

To-do:

Comment on lines 18 to 24
"build:create-tar-file-from-deps": "tar -czf ./deps.tar.gz ./deps && mv ./deps.tar.gz ./deps",
"build": "npm run build:js && npm run build:backends && npm run build:create-tar-file-from-deps",
"build:activated": "npm run build:js && npm run build:backends-activated",
"postbuild:fixup-external-url-jl": "sed -i 's/https:\\/\\/unpkg.com\\/dash_textarea_autocomplete/https:\\/\\/unpkg.com\\/dash-textarea-autocomplete/' src/DashTextareaAutocomplete.jl",
"postbuild:fixup-dash-version-project-jl": "sed -i 's/Dash = \"0.1.3\"/Dash = \"0.1.3, 1.0\"/' Project.toml",
"postbuild:fixup-resources-path-jl": "sed -i 's/realpath(joinpath( @__DIR__, \"..\", \"deps\"))/artifact\"dash_textarea_autocomplete_resources\"/' src/DashTextareaAutocomplete.jl",
"postbuild": "npm run postbuild:fixup-external-url-jl && npm run postbuild:fixup-dash-version-project-jl && npm run postbuild:fixup-resources-path-jl"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of manual fix-ups, it would be nice to follow up on creating PR in the dash repo so we can remove each of these one by one. We can create Issues here to track it potentially ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

I would start by opening an issue in https://github.com/plotly/dash/issues mentioning that the "proper" way (and the one that's work with PackageCompiler.jl 😏 ) to handle artifacts in Julia now is by defining Artifact.toml.

Then, we should mention that Artifact.toml only accepts tarball, so we would need to tar the min.js and min.js.map files together in the build process so that the tarball is part of the npm registry and has a permanent URL available from unpkg.com

We could also reference this PR (they can see it, it's opensource 🎊 ) to put things in context.

Felix-Gauthier and others added 2 commits December 9, 2021 23:55
- Update Julia compat bound to 1.3 to use Pkg.Artifacts
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@@ -16,14 +17,14 @@ function __init__()
[
DashBase.Resource(
relative_package_path = "dash_textarea_autocomplete.min.js",
external_url = "https://unpkg.com/dash_textarea_autocomplete@1.1.0/dash_textarea_autocomplete/dash_textarea_autocomplete.min.js",
external_url = "https://unpkg.com/dash-textarea-autocomplete@1.1.0/dash_textarea_autocomplete/dash_textarea_autocomplete.min.js",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need these externarl_url definitions now that we're set to use Artifacts and a tarball?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we didn't need them before since they never actually worked 😏

If we're going to have an external_url resource, it'd be nice if it was a functioning link even if we won't rely on it because of artifacts.

Maybe there's a case where artifacts can't be acquired and this would be the fallback ?

@Felix-Gauthier
Copy link
Collaborator Author

Ok so a lot of changes in the last 6 commits, mostly about adding the url value and moving the postbuild stuff to a separate file, as well as committing the deps tarball to the repo.

I think this should be good for final review pass and version bump, but we have to be extra sure the url should work before merging & tagging : it's not dramatic if we have to do a v1.2.1 to correct it but it would be nice to get it right on the first try.

@Felix-Gauthier Felix-Gauthier marked this pull request as ready for review December 10, 2021 21:04
Project.toml Outdated
@@ -1,12 +1,13 @@

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's new. Something must be off in the sed command. Can you try to modify it so that we don't get this spurious newline.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, nevermind.

Looks like the current main version

https://github.com/etpinard/dash-textarea-autocomplete/blob/main/Project.toml#L1

has a newline at the top of file also.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that would be part of a PR to https://github.com/plotly/dash/blob/dev/dash/development/_jl_components_generation.py

looking at it, it seems like https://github.com/plotly/dash/blob/dev/dash/development/_jl_components_generation.py#L87 is part of main , so why aren't we getting that with npm run build ? 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at it, it seems like https://github.com/plotly/dash/blob/dev/dash/development/_jl_components_generation.py#L87 is part of main , so why aren't we getting that with npm run build ? thinking

That's their dev branch, so yeah it will be part of the next dash.py release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh -- right, sorry.

Comment on lines +43 to +44
**N.B.**
+ We use `postbuild_fixups.sh` to re-write certain lines in the generated Julia files of this package to allow usage of Julia's [Artifact](https://pkgdocs.julialang.org/v1/artifacts/#Artifacts) system.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, we do need to run npm run postbuild while developing the package.

But more importantly, we should also mention npm run postbuild in the Create a production build and publish section below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've been doing, npm run build seems to run every step of the "scripts" section in package.json, regardless of the name as long as the script entry starts with npm run ...

I've haven't had to do npm run postbuild yet to have the postbuild:<> step run so far.

Maybe it's different for a production build though ?

Copy link
Owner

@etpinard etpinard Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. Looks like the pre and post complementary scripts work even for user-defined scripts like build.


Is this a new feature or just something I forgotten from my JS days 🤔

@etpinard
Copy link
Owner

etpinard commented Dec 10, 2021

Awesome. This looks great! After adding one line in the CONTRIBUTING.md file, I'd be happy with giving this a go!

I think this should be good for final review pass and version bump, but we have to be extra sure the url should work before merging & tagging : it's not dramatic if we have to do a v1.2.1 to correct it but it would be nice to get it right on the first try.

Right, I don't mind giving this v1.2.0 a shot and quickly make a fix in v1.2.1 if things don't work. Let's be honest, this project isn't that popular (yet 🙃 )

That said, releasing this thing isn't that simple. Make sure you review

https://github.com/etpinard/dash-textarea-autocomplete/blob/main/CONTRIBUTING.md#create-a-production-build-and-publish

namely, you'll need an https://www.npmjs.com/ account (to publish the javascript package), https://pypi.org/ account (to publish the python package) and then I'll need to add you as a contributor to both registries.

@etpinard
Copy link
Owner

Right, I don't mind giving this v1.2.0 a shot and quickly make a fix in v1.2.1

An important corollary here: let's not try do this on a Friday afternoon. Mondays are much better for these sort of things 😄

Copy link
Owner

@etpinard etpinard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Let's give this a shot!

@Felix-Gauthier go ahead and merge this PR to main and follow the CONTRIBUTING.md to make the release from main.

@Felix-Gauthier Felix-Gauthier merged commit 3f110cd into main Dec 13, 2021
@Felix-Gauthier Felix-Gauthier deleted the add-build-fixups-and-add-artifacts branch December 13, 2021 21:17
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

Successfully merging this pull request may close these issues.

Need to manually set Dash = "0.1.3, 1.0" in the Project.toml after npm run build
2 participants