fluidcad 0.0.19 → 0.0.20

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": "fluidcad",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "Parametric CAD modeling library using javascript",
5
5
  "author": "Marwan Aouida <contact@marwan.dev>",
6
6
  "homepage": "https://fluidcad.io",
@@ -1,5 +1,4 @@
1
- import { join, dirname } from 'path';
2
- import { fileURLToPath } from 'url';
1
+ import { createRequire } from 'module';
3
2
  async function loadTreeSitter() {
4
3
  const mod = await import('web-tree-sitter');
5
4
  // v0.24.x: default export IS the Parser class with .init() and .Language.
@@ -13,8 +12,12 @@ async function getParser() {
13
12
  const TreeSitter = await loadTreeSitter();
14
13
  await TreeSitter.init();
15
14
  parser = new TreeSitter();
16
- const thisDir = dirname(fileURLToPath(import.meta.url));
17
- const wasmPath = join(thisDir, '..', '..', 'node_modules', 'tree-sitter-wasms', 'out', 'tree-sitter-javascript.wasm');
15
+ // Use Node's resolver so the lookup walks up node_modules and finds the
16
+ // wasm regardless of whether npm hoisted `tree-sitter-wasms` next to or
17
+ // below `fluidcad`. The relative-path approach broke when fluidcad was
18
+ // installed from npm.
19
+ const requireFromHere = createRequire(import.meta.url);
20
+ const wasmPath = requireFromHere.resolve('tree-sitter-wasms/out/tree-sitter-javascript.wasm');
18
21
  const lang = await TreeSitter.Language.load(wasmPath);
19
22
  parser.setLanguage(lang);
20
23
  return parser;