Question about importing dependencies of package

I am developing a Julia package, say “PackA.jl”. It depends on many other packages, for example, “JSON.jl”.

I put JOSN both to Project.toml and REQUIRE.

In the main source file, “PackA.jl”, there’s a line to use JSON:

using JSON

Then I start julia REPL like this, in the root dir of PackA.jl:

julia --project=.

And:

julia> using JSON
ERROR: ArgumentError: Package JSON not found in current path:
- Run `import Pkg; Pkg.add("JSON")` to install the JSON package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:876

julia> using PackA.JSON
julia> using JSON
ERROR: ArgumentError: Package JSON not found in current path:
- Run `import Pkg; Pkg.add("JSON")` to install the JSON package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:876

julia> JSON
JSON

JSON can only be imported through PackA but can’t be imported directly. Is this by design?

Thanks.

Yes it is.

What packages PackA depends on is an implementation detail that you as a user should not see. If you want to using JSON should should add JSON as a dependency, not rely on some other package to make it available for you.

Thanks.