Skip to content

Commit

Permalink
Switch to Weakdeps
Browse files Browse the repository at this point in the history
This is a new feature in Julia 1.9+ that should
remove the dependency on Requires.jl. It should
offer mild precompilation and load time improvement
(contingent upon other dependencies here adopting Weakdeps as well).
  • Loading branch information
sjkelly committed Mar 16, 2023
1 parent e535a1a commit 1cd4c65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ JSON = "0.21"
JSON3 = "1.9"
MD5 = "0.2"
PlotlyBase = "0.8.5, 0.8.6"
PlotlyJS = "0.18"
Requires = "1.3"
YAML = "0.4.7"
julia = "1.6"

[extensions]
PlotlyJSExt = "PlotlyJS"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test"]

[weakdeps]
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
4 changes: 4 additions & 0 deletions src/plotly_js.jl → ext/PlotlyJSExt.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module PlotlyJSExt

import JSON
import PlotlyJS

function DashBase.to_dash(p::PlotlyJS.SyncPlot)
data = JSON.lower(p.plot)
pop!(data, :config, nothing)
return data
end

end
12 changes: 8 additions & 4 deletions src/Dash.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ using DashBase
import HTTP, JSON3, CodecZlib, MD5
using Sockets
using Pkg.Artifacts

if !isdefined(Base, :get_extension)
using Requires
end

const ROOT_PATH = realpath(joinpath(@__DIR__, ".."))
#const RESOURCE_PATH = realpath(joinpath(ROOT_PATH, "resources"))
Expand Down Expand Up @@ -106,12 +109,13 @@ end
@place_embedded_components
const _metadata = load_all_metadata()
function __init__()
setup_renderer_resources()
setup_dash_resources()
@require PlotlyJS="f0f68f2c-4968-5e81-91da-67840de0976a" include("plotly_js.jl")
setup_renderer_resources()
setup_dash_resources()
@static if !isdefined(Base, :get_extension)
@require PlotlyJS="f0f68f2c-4968-5e81-91da-67840de0976a" include("../ext/PlotlyJSExt.jl")
end
end


JSON3.StructTypes.StructType(::Type{DashBase.Component}) = JSON3.StructTypes.Struct()
JSON3.StructTypes.excludes(::Type{DashBase.Component}) = (:name, :available_props, :wildcard_regex)

Expand Down

0 comments on commit 1cd4c65

Please sign in to comment.