Skip to content

Revise Packaging.md#173

Open
k2d222 wants to merge 7 commits into
mainfrom
k2d222-patch-5
Open

Revise Packaging.md#173
k2d222 wants to merge 7 commits into
mainfrom
k2d222-patch-5

Conversation

@k2d222

@k2d222 k2d222 commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

It's time to un-draft Packaging.md

@k2d222 k2d222 marked this pull request as ready for review February 28, 2026 13:26
@k2d222

k2d222 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

no time or interest to finish this, but it's already an improvement to the exitsing file. OK to merge?

Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md

@mighdoll mighdoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'll be good to get this in! sorry for forgetting about it and glad you're pushing it forward. lmk if you want help on any of the minor edits, I can make more specific text proposals if needed.

Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated

(TODO: unification with param const?)

If two packages in the dependency tree are [semver-compatible](https://semver.org/), npm or Cargo will likely unify them, meaning it will include only one version of the package in its output (often the highest semver-compatible version available).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we might say that users are doing this unification. i.e. users of npm and cargo may unify them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see, the point is that package managers will sometimes unify by default. I think that's the default for npm, though the rules are overridable and expectations vary on whether indirect dependencies are unified. (AFAIR by default pnpm doesn't unify indirect dependencies, but npm might still do that)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lemme know if the current revision clarifies.

Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
* Add the `_wgsl` suffix to the name: `mypackage_wgsl`.
* Use snake_case (underscores to separate words): `my_great_package_wgsl`.
* If your package is part of a larger project, or produced by a company, you can prefix it with that name: `mycompany_mypackage_wgsl`.
* For [wesl-js] specifically, you can use the common naming convention `@mycompany/mypackage_wgsl`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we might add a note here that package names with @ and - and / are sanitized for use in WESL:
"@scope/my-package" => import scope__my_package::...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know the exact sanitization rules in -js, so I added vague footnote

apply revisions
@k2d222 k2d222 requested review from mighdoll and stefnotch July 7, 2026 15:03

@mighdoll mighdoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, nice work moving this forward! Suggestions below are mostly editorial.

Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
## Using shader packages

The WESL linker is responsible for finding and downloading dependencies: [wesl-js] will fetch packages from [npm], while [wesl-rs] will fetch them from [crates.io].
The package dependencies of a shader project are either discovered automatically by the WESL linker, or explicitly listed in the `dependencies` section of [`wesl.toml`].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wesl-rs currently uses build.rs?
wesl-js normally infers from shader code + package.json.
(I don't think we actually use wesl.toml deps in linking at present..)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wesl-rs currently uses build.rs?

yes, packages are built in the build script. Currently the -rs expects that packages are manually provided in the build command.

added a note to be removed once we have better sopport of wesl-toml.

Comment thread Packaging.md Outdated

The WESL linker is responsible for finding and downloading dependencies: [wesl-js] will fetch packages from [npm], while [wesl-rs] will fetch them from [crates.io].
The package dependencies of a shader project are either discovered automatically by the WESL linker, or explicitly listed in the `dependencies` section of [`wesl.toml`].
Inside shader modules, one can reach declarations in dependencies with import paths, as explained in [imports].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

perhaps something in this direction:

WESL tools resolve module paths in WESL code using the algorithm described in import resolution. Each ecosystem package format provides a standard way for WESL tools to map from module paths to shader code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my goal was to explain how packages can be used inside shader code, and that is using import statment. I've settled on a sentence in-between yours and mine.

Comment thread Packaging.md

## Creating and publishing shader packages

Any [`wesl.toml`] file declares a new shader package, which can be published using the linker's CLI.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

in js, wesl-packager is currently a separate cli (from the wesl-link cli).

Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
Comment thread Packaging.md Outdated
@mighdoll  comment revisions

@experimentslee experimentslee left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looking good. best not promise to wesl.toml deps for wesl-js.
resolve/review the 4 comments and then LGTM w/o further review

Comment thread Packaging.md
* Look for packages with the same name in both [npm] and [crates.io].
* It is courtesy to leave the name free for the original author if they wish to publish to the other registry.
* It also avoids confusion for end-users who may think it is the same package.
*

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

extra bullet

Comment thread Packaging.md

In development, packages are typically loaded from repositories by ecosystem package managers like npm or cargo. [wesl-js] will fetch packages from [npm], while [wesl-rs] will fetch them from [crates.io].
The package dependencies of a shader project are either provided manually using linker-specific settings, discovered automatically by the linker, or explicitly listed in the `dependencies` section of [`wesl.toml`][^1].
A package contents is reachable from user code via module paths starting with the package name. This mechanism is detailed in the [import resolution algorithm](Imports.md#resolving-a-declaration-path).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

package's contents are

Comment thread Packaging.md
[wesl-rs]: https://github.com/wgsl-tooling-wg/wesl-rs

We are planning on taking advantage of existing package managers, such as `cargo` for Rust, and `npm` for Javascript. This makes it easier for users to consume shaders, and makes sense for ecosystem-specific tools.
[^1]: At the time of writing, [wesl-js] and [wesl-rs] do not support reading dependencies in `wesl.toml`, but that will become the preferred way of discovering dependencies in the near future.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

perhaps just drop the footnote for now, the base sentence covers the options already we don't need to predict in a spec footnote that will soon go out of date.

(also, I think wesl-js probably stays default auto, and maybe still ignores the wesl.toml deps? not sure, but we'll discuss with #194)

Comment thread Packaging.md

We are planning on taking advantage of existing package managers, such as `cargo` for Rust, and `npm` for Javascript. This makes it easier for users to consume shaders, and makes sense for ecosystem-specific tools.
[^1]: At the time of writing, [wesl-js] and [wesl-rs] do not support reading dependencies in `wesl.toml`, but that will become the preferred way of discovering dependencies in the near future.
[^2]: When a package name contains symbols such as `-` `/` or `@`, [wesl-js] will sanitize it to become a valid WGSL identifier, e.g. a package named `@mycompany/mypackage_wgsl` can be imported with the prefix `mycompany__mypackage_wgsl`. [wesl-js] forbids symbols, with the exception of `-` (dash) which is replaced with `_` (underscore). Refer to the linkers' documentation for more information.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

for wesl-js, it's:

  • @ is removed
  • / becomes __
  • - becomes _

I think maybe the second ref has a typo, supposed to be to wesl-rs.

I think it's goodness to mention the sanitizations, since we have to keep them stable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

instead of a footnote, I'll write a subsection "package name sanitization". It deserves q deeper explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants