bs-loader
Advanced tools
Comparing version 1.4.2 to 1.5.0
@@ -8,3 +8,4 @@ { | ||
"reason-js", | ||
"reason-react" | ||
"reason-react", | ||
"bs-jest" | ||
], | ||
@@ -11,0 +12,0 @@ "reason": { |
@@ -7,3 +7,4 @@ { | ||
"scripts": { | ||
"build": "webpack" | ||
"build": "webpack", | ||
"test": "jest" | ||
}, | ||
@@ -13,4 +14,6 @@ "author": "", | ||
"devDependencies": { | ||
"bs-jest": "^0.1.0", | ||
"bs-loader": "^1.2.1", | ||
"bs-platform": "^1.7.1", | ||
"jest": "^20.0.4", | ||
"reason-js": "0.0.16", | ||
@@ -24,3 +27,16 @@ "reason-react": "^0.1.1", | ||
"react-dom": "^15.4.2" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"re", | ||
"js", | ||
"ml" | ||
], | ||
"testMatch": [ | ||
"**/src/*_test.re" | ||
], | ||
"transform": { | ||
".(re|ml)": "bs-loader" | ||
} | ||
} | ||
} |
@@ -14,2 +14,3 @@ { | ||
"bs-platform": "^1.7.1", | ||
"jest": "^20.0.4", | ||
"reason-js": "0.0.16", | ||
@@ -16,0 +17,0 @@ "reason-react": "^0.1.1", |
23
index.js
const path = require('path') | ||
const { readFile } = require('fs') | ||
const { execFile } = require('child_process') | ||
const { readFile, readFileSync } = require('fs') | ||
const { execFile, execFileSync } = require('child_process') | ||
const { getOptions } = require('loader-utils') | ||
@@ -26,2 +26,3 @@ | ||
const runBsb = callback => { | ||
@@ -31,2 +32,6 @@ execFile(bsb, ['-make-world'], { maxBuffer: Infinity }, callback) | ||
const runBsbSync = () => { | ||
execFileSync(bsb, ['-make-world']) | ||
} | ||
const getCompiledFile = (moduleDir, path, callback) => { | ||
@@ -47,3 +52,9 @@ runBsb((err, res) => { | ||
module.exports = function () { | ||
const getCompiledFileSync = (moduleDir, path) => { | ||
runBsbSync() | ||
const res = readFileSync(path) | ||
return transformSrc(moduleDir, res.toString()) | ||
} | ||
module.exports = function loader () { | ||
const options = getOptions(this) || {} | ||
@@ -74,1 +85,7 @@ const errorType = options.errorType || 'error' | ||
} | ||
module.exports.process = (src, filename) => { | ||
const moduleDir = 'js' | ||
const compiledFilePath = getJsFile(moduleDir, filename) | ||
return getCompiledFileSync(moduleDir, compiledFilePath) | ||
} |
{ | ||
"name": "bs-loader", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "Bucklescript integration in Webpack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
172138
26
137