jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.58k stars 505 forks source link

V3 : eliminate circular dependencies #1258

Open z3dev opened 1 year ago

z3dev commented 1 year ago

Expected Behavior

Modules / functions reference(import) specific functionality instead of using indexes.

Actual Behavior

When running the build for modeling, the following error is published by rollup.

(!) Circular dependency
src/primitives/index.js -> src/primitives/torus.js -> src/operations/extrusions/index.js -> src/operations/extrusions/extrudeRectangular.js -> src/operations/extrusions/extrudeRectangularPath2.js -> src/operations/expansions/index.js -> src/operations/expansions/expand.js -> src/operations/expansions/expandGeom3.js -> src/operations/expansions/expandShell.js -> src/primitives/index.js

Steps to Reproduce the Problem

  1. cd to modeling directory
  2. pnpm run build

Specifications

z3dev commented 1 year ago

In general, imports of named functions should be importing from a file, not from an index. This eliminates extra imports, and circular dependencies.

In general, import directly from files if possible. Don't use indexes.