-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
"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" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
- Update Julia compat bound to 1.3 to use Pkg.Artifacts
@@ -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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
Ok so a lot of changes in the last 6 commits, mostly about adding the 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 |
Project.toml
Outdated
@@ -1,12 +1,13 @@ | |||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
? 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh -- right, sorry.
**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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
.
- https://docs.npmjs.com/cli/v6/using-npm/scripts
- https://thomasxbanks.com/articles/pre-post-npm-scripts/
Is this a new feature or just something I forgotten from my JS days 🤔
Awesome. This looks great! After adding one line in the
Right, I don't mind giving this That said, releasing this thing isn't that simple. Make sure you review 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. |
An important corollary here: let's not try do this on a Friday afternoon. Mondays are much better for these sort of things 😄 |
There was a problem hiding this 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
.
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:
Artifacts.toml
with value from [POC] Use Julia artifacts for.js
deps (for use withPackageCompiler
) #12 (comment)