Skip to content

Unable to specify custom parser options when using riot.compile #64

Closed
@joepie91

Description

@joepie91

While the _compileJS method accepts parserOpts as a fourth argument, there's no way to specify these when using riot.compile() (as opposed to riot.js(), where it is possible to do so).

The specific usecase where I'm finding this to be an issue: I'm currently working on a project that uses Webpack + Riot + Babel, but the Babel settings for Riot (via riotjs-loader) have to be different from those for babel-node when running the server application. Namely, babel-node uses the es2015-node preset, whereas Riot needs the es2015-riot preset.

Right now, there's no way for me to specify a custom preset in the Riot parser options on a project-wide basis, only for each component individually via an options tag (which is also broken, per #63). This means that it uses the .babelrc, which tries to use es2015-node and consequently fails on top-level this.

My use of riotjs-loader means that I also have no control over which Riot compiler method is being called, and so I'm stuck with riot.compile() and can't eg. patch in something with riot.js(). Essentially, it's impossible for me at this stage to successfully compile my code.

This would only be an API addition (and corresponding documentation fixes), something along the lines of:

riot.compile(source, {
    parserOptions: {
        js: {
            presets: ["es2015-riot"]
        }
    }
})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions