wesl-tooling 0.6.14 → 0.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wesl-tooling",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -20,7 +20,7 @@
20
20
  "dependent_package": "x"
21
21
  },
22
22
  "peerDependencies": {
23
- "wesl": "^0.7.0"
23
+ "wesl": "^0.7.2"
24
24
  },
25
25
  "scripts": {
26
26
  "test": "cross-env FORCE_COLOR=1 vitest",
@@ -7,12 +7,6 @@ import { moduleToRelativePath, normalizeDebugRoot, parseSrcModule } from "wesl";
7
7
  *
8
8
  * Resolves module paths like `package::foo::bar` to filesystem paths
9
9
  * like `baseDir/foo/bar.wesl` or `baseDir/foo/bar.wgsl`.
10
- *
11
- * @example
12
- * ```ts
13
- * const resolver = new FileModuleResolver("./shaders", "my-package");
14
- * const ast = resolver.resolveModule("package::utils::helper");
15
- * ```
16
10
  */
17
11
  export class FileModuleResolver implements ModuleResolver {
18
12
  /** Cached parsed ASTs to avoid re-parsing the same module */
@@ -21,11 +21,13 @@ import { npmResolveWESL } from "./NpmResolver.ts";
21
21
  *
22
22
  * @param weslSrc - Record of WESL source files by path
23
23
  * @param projectDir - Project directory for resolving package imports
24
+ * @param virtualLibNames - Virtual lib names to exclude (e.g., ['test', 'constants'])
24
25
  * @returns Dependency paths in npm format (e.g., 'foo/bar', 'foo')
25
26
  */
26
27
  export function parseDependencies(
27
28
  weslSrc: Record<string, string>,
28
29
  projectDir: string,
30
+ virtualLibNames: string[] = [],
29
31
  ): string[] {
30
32
  let resolver: RecordResolver;
31
33
  try {
@@ -41,9 +43,10 @@ export function parseDependencies(
41
43
  const unbound = findUnboundIdents(resolver);
42
44
  if (!unbound) return [];
43
45
 
44
- // Filter: skip builtins (1 segment) and linker virtuals ('constants')
46
+ // Filter: skip builtins (1 segment), linker virtuals ('constants'), and custom virtualLibs
47
+ const excludeRoots = new Set(["constants", ...virtualLibNames]);
45
48
  const pkgRefs = unbound.filter(
46
- modulePath => modulePath.length > 1 && modulePath[0] !== "constants",
49
+ modulePath => modulePath.length > 1 && !excludeRoots.has(modulePath[0]),
47
50
  );
48
51
  if (pkgRefs.length === 0) return [];
49
52
 
@@ -64,6 +67,7 @@ export function parseDependencies(
64
67
  * @param projectDir - Project directory for resolving imports
65
68
  * @param packageName - Optional current package name
66
69
  * @param includeCurrentPackage - Include current package in results (default: false)
70
+ * @param virtualLibNames - Virtual lib names to exclude from resolution
67
71
  * @returns Loaded WeslBundle instances
68
72
  */
69
73
  export async function dependencyBundles(
@@ -71,16 +75,18 @@ export async function dependencyBundles(
71
75
  projectDir: string,
72
76
  packageName?: string,
73
77
  includeCurrentPackage = false,
78
+ virtualLibNames: string[] = [],
74
79
  ): Promise<WeslBundle[]> {
75
- const deps = parseDependencies(weslSrc, projectDir);
80
+ const deps = parseDependencies(weslSrc, projectDir, virtualLibNames);
76
81
  const filteredDeps = includeCurrentPackage
77
82
  ? deps
78
83
  : otherPackages(deps, packageName);
79
84
  const projectURL = projectDirURL(projectDir);
85
+
80
86
  const bundles = filteredDeps.map(async dep => {
81
87
  const url = resolve(dep, projectURL);
82
88
  const module = await import(url);
83
- return module.default;
89
+ return module.default as WeslBundle;
84
90
  });
85
91
 
86
92
  return await Promise.all(bundles);