Sublime Forum

`module` keyword in WebGPU JavaScript code

#1

In the WebGPU API, it is common to name a certain variable module. For example:

	const module = device.createShaderModule({
		label: 'test compute module'
		code: `
			@group(0) @binding(0) var<storage, read_write> data: array<f32>

			@compute @workgroup_size(1) fn computer(
				@builtin(global_invocation_id) id: vec3<u32>
			) {
				let i = id.x;
				data[i] = data[i] * 2;
			}

		`
	});

In Sublime Text, the font style being applied to module in the above code implies it is a reserved keyword (it is a purple italic, I use the default theme), but it is not, and its usage is valid here.

I am not sure whether this issue should be resolved with a custom theme/plugin, or if it is considered a bug; so I categorized this post as ‘Technical Support’.

0 Likes

#2

module is part of CommonJS. See https://en.wikipedia.org/wiki/CommonJS

1 Like