re: Getting Sweet.js parser to run in a browser environment? VIEW POST


I think you need to include RequireJS before you include the Sweet.js files from a CDN.

There seems to be a browser-sweet.js that has a compile() function that wants a source and helpers as arguments.

I don't want to use RequireJS and I don't want to use a CDN.

Then I'd recommend you use something like Webpack, Rollup or Parcel to compile and bundle your code up for the browser.

import compile from '@sweet-js/core/dist/browser-sweet.js';

window.sweetCompile = compile;

The result will be a JS bundle that you can include on your page that will expose window.sweetCompile as a function for you to use.

code of conduct - report abuse