This guide covers setting up your development environment and working with the Polyslice codebase.
This repository uses Git LFS to store G-code sample files. Make sure you have Git LFS installed:
# Install Git LFS
git lfs install
# If you cloned before installing LFS, pull the actual files:
git lfs pullPolyslice requires Node.js 16 or higher. Install dependencies:
npm installnpm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage reportnpm run compile # Compile CoffeeScript to JavaScriptnpm run build:node # Node.js builds (CommonJS + ESM)
npm run build:browser # Browser build (IIFE)
npm run build:cjs # CommonJS build only
npm run build:esm # ES modules build only
npm run build:minify # Minified builds
npm run build # All buildsnode examples/basic.js
node examples/threejs-integration.jspolyslice/
├── src/ # Source code (CoffeeScript)
│ ├── polyslice.coffee # Main slicer class
│ ├── config/ # Printer and filament configurations
│ │ ├── printer/ # Printer profiles
│ │ └── filament/ # Filament profiles
│ ├── loaders/ # 3D file loaders
│ ├── exporters/ # G-code exporters
│ ├── slicer/ # Slicing engine
│ │ ├── gcode/ # G-code generation
│ │ ├── geometry/ # Geometry utilities
│ │ ├── infill/ # Infill patterns
│ │ ├── preprocessing/ # Mesh preprocessing
│ │ ├── skin/ # Skin generation
│ │ ├── support/ # Support structures
│ │ ├── utils/ # Utility functions
│ │ └── walls/ # Wall generation
│ └── utils/ # General utilities
├── docs/ # Documentation
├── examples/ # Example scripts
├── dist/ # Built files (generated)
└── tests/ # Test files
- Source code is written in CoffeeScript
- Use 4-space indentation
- Follow existing naming conventions
- Add tests for new features
- Update documentation for API changes
Tests are written using Jest and located alongside source files with .test.coffee extension.
# Run all tests
npm test
# Run specific test file
npm test -- --testPathPattern="polyslice.test"
# Run with verbose output
npm test -- --verboseThe build process creates multiple output formats:
| Format | Output | Usage |
|---|---|---|
| CommonJS | dist/index.cjs.js |
Node.js (require) |
| ES Modules | dist/index.esm.js |
Modern bundlers |
| Browser | dist/index.browser.js |
Browser (script tag) |
| Browser (min) | dist/index.browser.min.js |
Production |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
See CONTRIBUTING for detailed guidelines.
Enable verbose mode to add comments in generated G-code:
const slicer = new Polyslice({
verbose: true
});Use the G-code Visualizer to inspect generated G-code in 3D.
- API Reference - Complete API reference
- Examples - Usage examples
- Tools - Development and debugging tools