wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

rt-include usage yields "RTCodeError: rt-include needs a readFileSync polyfill on options" #204

Open motin opened 7 years ago

motin commented 7 years ago

Apparently readFileSync is necessary, and a polyfill should be included in "options", but how is this done and where? Docs would be great here :)

nippur72 commented 7 years ago

I think I've spotted a possible bug... are you running rt with no options at all?

motin commented 7 years ago

I run it (react-templates 0.5.4) via react-templates-loader 0.5.1 via the following loader config:

{ test: /.rt$/, loader: "react-templates-loader?modules=amd", exclude: /node_modules/ },

I guess this translates to "--modules amd" as command line options.

nippur72 commented 7 years ago

I think there's a a problem with the loader as it directly calls

reactTemplates.convertTemplateToReact(source, options);

but options.readFileSync is filled only when running rt from the CLI.

I think this line should be moved elsewhere, so to cover the non-CLI case as well.