Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Wiki
  • node loader

node loader · Changes

Page history
adding module documentation authored Dec 10, 2013 by Tim Disney's avatar Tim Disney
Hide whitespace changes
Inline Side-by-side
node-loader.md 0 → 100644
View page @ 538da8ad
# Node loader
If you'd like to skip using the `sjs` binary to compile your sweet.js code, you can use the node loader. This allows you to `require` sweet.js files that have the `.sjs` extension:
```js
var sjs = require('sweet.js'),
example = require('./example');
example.one;
```
Where ./example.sjs contains:
```js
// example.sjs
macro id {
rule { ($x) } => {
$x
}
}
exports.one = id (1);
```
Note that `require('sweet.js')` must come before any requires of `.sjs` code. Also note that this does not import any macros, it just uses sweet.js to compile files that contain macros before requiring them. If you're looking to modularize macros check out the [[modules]] wiki page.
\ No newline at end of file
Clone repository
  • Example macros
  • FAQ
  • High level design overview
  • Home
  • Macro resources
  • Patterns
  • Syntax Case
  • case api
  • custom operators
  • design
  • expander design
  • modules
  • node loader
  • pattern_class
  • reader scratch
View All Pages