Comparing version 1.5.5 to 1.5.6
@@ -15,3 +15,3 @@ const path = require('path') | ||
{ | ||
loader: './bs-loader', | ||
loader: 'bs-loader', | ||
options: { | ||
@@ -18,0 +18,0 @@ module: 'es6' |
32
index.js
@@ -8,3 +8,3 @@ const path = require('path') | ||
try { | ||
bsb = require.resolve('bs-platform/bin/bsb') | ||
bsb = require.resolve('bs-platform/bin/bsb.exe') | ||
} catch (e) { | ||
@@ -15,7 +15,13 @@ bsb = 'bsb' | ||
const outputDir = 'lib' | ||
const CWD = process.cwd() | ||
const fileNameRegex = /\.(ml|re)$/ | ||
const es6ReplaceRegex = /(from\ "\.\.?\/.*)(\.js)("\;)/g | ||
const commonJsReplaceRegex = /(require\("\.\.?\/.*)(\.js)("\);)/g | ||
const getErrorRegex = /(File [\s\S]*?:\n|Fatal )[eE]rror: [\s\S]*?(?=ninja|\n\n|$)/g | ||
const getJsFile = (moduleDir, resourcePath) => { | ||
const mlFileName = resourcePath.replace(process.cwd(), '') | ||
const jsFileName = mlFileName.replace(/\.(ml|re)$/, '.js') | ||
return path.join(process.cwd(), outputDir, moduleDir, jsFileName) | ||
const mlFileName = resourcePath.replace(CWD, '') | ||
const jsFileName = mlFileName.replace(fileNameRegex, '.js') | ||
return path.join(CWD, outputDir, moduleDir, jsFileName) | ||
} | ||
@@ -25,4 +31,4 @@ | ||
moduleDir === 'es6' | ||
? src.replace(/(from\ "\.\.?\/.*)(\.js)("\;)/g, '$1$3') | ||
: src.replace(/(require\("\.\.?\/.*)(\.js)("\);)/g, '$1$3') | ||
? src.replace(es6ReplaceRegex, '$1$3') | ||
: src.replace(commonJsReplaceRegex, '$1$3') | ||
@@ -37,7 +43,7 @@ const runBsb = (compilation, callback) => { | ||
const runBsbSync = () => { | ||
execFileSync(bsb, ['-make-world'], { stdio: 'pipe' }) | ||
const cp = execFileSync(bsb, ['-make-world'], { stdio: 'pipe' }) | ||
cp.stdin.end() | ||
} | ||
const getBsbErrorMessages = err => | ||
err.match(/(File [\s\S]*?:\n|Fatal )[eE]rror: [\s\S]*?(?=ninja|\n\n|$)/g) | ||
const getBsbErrorMessages = err => err.match(getErrorRegex) | ||
@@ -93,7 +99,7 @@ const getCompiledFile = (compilation, moduleDir, path, callback) => { | ||
errorMessages | ||
.slice(0, -1) | ||
.forEach(msg => this.emitError(new Error(msg))) | ||
for (let i = 0; i < errorMessages.length - 1; ++i) { | ||
this.emitError(new Error(errorMessages[i])) | ||
} | ||
callback(new Error(errorMessages.slice(-1)), null) | ||
callback(new Error(errorMessages[errorMessages.length - 1]), null) | ||
} else { | ||
@@ -100,0 +106,0 @@ callback(null, res) |
{ | ||
"name": "bs-loader", | ||
"version": "1.5.5", | ||
"version": "1.5.6", | ||
"description": "Bucklescript integration in Webpack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218183
164