Skip to content

Instantly share code, notes, and snippets.

@dylan-sessler
Last active March 17, 2022 16:44
Show Gist options
  • Save dylan-sessler/1463bc4d1cb604218e4df4ea6d4544e2 to your computer and use it in GitHub Desktop.
Save dylan-sessler/1463bc4d1cb604218e4df4ea6d4544e2 to your computer and use it in GitHub Desktop.
module.exports = async function primitiveCost(productionGroup){...}
// ⚠ CIRCULAR DEPENDENCY WEIRDNESS ⚠
// We truly want a circular dependency in our application because we happen to
// use another manufacturing process (SLA) in order to manufacture the master
// for casted parts. This just requires a specific sequencing of exports and
// requires as outlined in https://stackoverflow.com/a/21264251
// Just make sure your necessary exports (primitiveCost) are defined before you
// require a file with a circular dependency. Node tries to prevent infinite loops and handles circular dependencies as follows:
//https://nodejs.org/api/modules.html#modules_cycles
// When main.js loads a.js, then a.js in turn loads b.js. At that point, b.js
// tries to load a.js. In order to prevent an infinite loop, an unfinished copy
// of the a.js exports object is returned to the b.js module. b.js then finishes
// loading, and its exports object is provided to the a.js module.
const addFixedCostToSinglePtg = require ('./addFixedCostToSinglePtg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment