Skip to content

Commit

Permalink
Move JSAsset's options gathering code into separate method (#241)
Browse files Browse the repository at this point in the history
* Move js asset's options code into separate method

* rename getOptions -> getParserOptions
  • Loading branch information
chee authored and devongovett committed Dec 14, 2017
1 parent bd45866 commit 333c3aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/assets/JSAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class JSAsset extends Asset {
);
}

async parse(code) {
async getParserOptions() {
// Babylon options. We enable a few plugins by default.
const options = {
filename: this.name,
Expand All @@ -56,6 +56,12 @@ class JSAsset extends Asset {
options.plugins.push(...file.parserOpts.plugins);
}

return options;
}

async parse(code) {
const options = await this.getParserOptions();

return babylon.parse(code, options);
}

Expand Down

0 comments on commit 333c3aa

Please sign in to comment.