Skip to content

Commit

Permalink
docs(readme): update usage instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer committed Jun 25, 2023
1 parent b797d48 commit 6411a49
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ export default {
export default config;
```
Now you can create a module with a macro, e.g. `random.js`:
```javascript
function random() {
return Math.random();
}
export { random };
```
And then import it in your code with appropriate import attribute:
```javascript
import { random } from './random.js' with { type: 'macro' };
// or using the older syntax
// import { random } from './random.js' assert { type: 'macro' };
console.log( random() );
```
After bundling the code with Rollup the import will be removed and the `random()` call replaced with an actual value returned by the macro:
```javascript
console.log(0.7507075485199182);
```
## How does it work?
## License
Expand Down

0 comments on commit 6411a49

Please sign in to comment.