1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
6 |
|
7 | const Asset = require('../Asset');
|
8 |
|
9 | const fs = require('@parcel/fs');
|
10 |
|
11 | const localRequire = require('../utils/localRequire');
|
12 |
|
13 | class ReasonAsset extends Asset {
|
14 | constructor(name, options) {
|
15 | super(name, options);
|
16 | this.type = 'js';
|
17 | }
|
18 |
|
19 | generate() {
|
20 | var _this = this;
|
21 |
|
22 | return (0, _asyncToGenerator2.default)(function* () {
|
23 | const bsb = yield localRequire('bsb-js', _this.name);
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | if (process.env.NODE_ENV !== 'test') {
|
29 | yield bsb.runBuild();
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 | const outputFile = _this.name.replace(/\.(re|ml)$/, '.bs.js');
|
35 |
|
36 | const outputContent = yield fs.readFile(outputFile);
|
37 | return outputContent.toString();
|
38 | })();
|
39 | }
|
40 |
|
41 | }
|
42 |
|
43 | module.exports = ReasonAsset; |
\ | No newline at end of file |