sweet-js / sweet-core

Sweeten your JavaScript.
https://www.sweetjs.org
BSD 2-Clause "Simplified" License
4.59k stars 211 forks source link

Question: best way to include sweet.js in my project #749

Closed xmclark closed 6 years ago

xmclark commented 6 years ago

Hey there I discovered this project a few weeks ago, and have been learning the macro syntax. I like it a lot and would like to add it to a project.

I’m curious about a good way of adding it in a maintainable way. So far, all examples I have found put the macro syntax in the same JavaScript file as the source. I would like to separate my macros into different files and include the macros at build time. I also want to add sjs into my build pipeline that might use Babel and Webpack or Gulp.

What are the best practices or tools to use for a project using sweet macros?

disnet commented 6 years ago

You can use modules: https://www.sweetjs.org/doc/tutorial#sweet-modules

xmclark commented 6 years ago

I guess I had missed this part of the tutorial. My bad.

Sweet modules works pretty well for exporting syntax. With exporting/importing modules, I can see this scaling pretty well.

Thanks, I think this resolves me issue for me. I can imagine most build systems can use the sjs cli to preprocess sweet macros in a project.

disnet commented 6 years ago

The error is because you are missing a ; after the first } On Mon, Mar 26, 2018 at 4:23 AM Mackenzie Clark notifications@github.com wrote:

Closed #749 https://github.com/sweet-js/sweet-core/issues/749.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/sweet-js/sweet-core/issues/749#event-1540614975, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAJOhr_T0NXUI-9elg3vtEl66c91lMPks5tiM_FgaJpZM4S5gGF .

xmclark commented 6 years ago

@disnet yes I realized this right after I posted it!

The export works like a charm! Thanks!