Skip to content

Commit

Permalink
Require loading as a module
Browse files Browse the repository at this point in the history
The issue is wgsl_reflect defines `class Function`. If this code
is loaded as a non-module then that ends up overriding the default
`Function` class and code that's checking `... instanceof Function`
starts failing.

There's no easy way for a script to check if it was loaded as a
module or a non-module but using `import.meta` ends up requiring
it to be loaded as a module.
  • Loading branch information
greggman committed Jun 9, 2024
1 parent 3189325 commit fef1580
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/webgpu-debug-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ import './compute-pass-encoder.js';
import './render-pass-encoder.js';
import './render-bundle-encoder.js';
import './texture.js';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _ = import.meta; // webgpu-debug-helper must be imported as a module with import or `<script type="module" ...>`
console.log('webgpu-debug-helper loaded:', _ !== undefined);

0 comments on commit fef1580

Please sign in to comment.