Open mighdoll opened 1 month ago
One approach from discord via @stefnotch
We only have one separator, but the meaning of it can change.
Given an import like import bevy_pbr/lighting/foo, we
- Import the bevy_pbr.wesl file. It's a root module, and it contains sub-modules.
- bevy_pbr exports a lighting sub-module, so we go there and import lighting.wesl (path is specified in bevy_pbr).
- lighting turns out to also use sub-modules. So we follow it to find the foo module.
Meanwhile, an import like import ./foo/bar would be resolved like
- Import the . module. Turns out that the current module does not use sub-modules. So the rest of the path must be an actual file path.
- Go straight to ./foo/bar.wesl and import that.
Namespaces are likely coming eventually to wesl. They've come up in wesl design discussions several times, and the wgsl team has had namespaces on the radar for several years. Let's sketch a way to extend the import syntax to support namespaces and add it to the future section of the import spec.