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
Updated node loader (markdown) authored Apr 30, 2014 by Tim Disney's avatar Tim Disney
Hide whitespace changes
Inline Side-by-side
node-loader.md
View page @ d836ae49
......@@ -22,4 +22,16 @@ macro id {
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
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.
Alternatively, you can use `sweet.loadMacro` to achieve a similar effect to the `--module` command line flag:
```js
var sweet = require('sweet.js');
// load all exported macros in `macros/str.sjs`
sweet.loadMacro('./macros/str');
// test.sjs uses macros that have been defined and exported in `macros/str.sjs`
require('./test.sjs');
```
This is basically equivalent to running `sjs --module ./macros/str test.sjs`.
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