Comparing version 1.7.4 to 1.7.5
86
index.js
@@ -1,2 +0,1 @@ | ||
const { readBsConfig } = require('read-bsconfig') | ||
const path = require('path') | ||
@@ -93,66 +92,43 @@ const { readFile, readFileSync } = require('fs') | ||
const getBsConfigModuleOptions = buildDir => | ||
readBsConfig(buildDir).then(bsconfig => { | ||
if (!bsconfig) { | ||
throw new Error(`bsconfig not found in ${buildDir}`) | ||
} | ||
if (!bsconfig['package-specs'] || !bsconfig['package-specs'].length) { | ||
resolve({ module: 'js', inSource: false }) | ||
} | ||
const moduleSpec = bsconfig['package-specs'][0] | ||
const moduleDir = | ||
typeof moduleSpec === 'string' ? moduleSpec : moduleSpec.module | ||
const inSource = | ||
typeof moduleSpec === 'string' ? false : moduleSpec['in-source'] | ||
return { moduleDir, inSource } | ||
}) | ||
module.exports = function loader() { | ||
const options = getOptions(this) || {} | ||
const buildDir = options.cwd || CWD | ||
const callback = this.async() | ||
const moduleDir = options.module || 'js' | ||
const inSourceBuild = options.inSource || false | ||
this.addContextDependency(this.context) | ||
const callback = this.async() | ||
const compiledFilePath = getJsFile( | ||
buildDir, | ||
moduleDir, | ||
this.resourcePath, | ||
inSourceBuild | ||
) | ||
getBsConfigModuleOptions(buildDir).then(bsconfig => { | ||
const moduleDir = options.module || bsconfig.moduleDir || 'js' | ||
const inSourceBuild = options.inSource || bsconfig.inSource || false | ||
getCompiledFile( | ||
buildDir, | ||
this._compilation, | ||
moduleDir, | ||
compiledFilePath, | ||
(err, res) => { | ||
if (err) { | ||
if (err instanceof Error) err = err.toString() | ||
const errorMessages = getBsbErrorMessages(err) | ||
const compiledFilePath = getJsFile( | ||
buildDir, | ||
moduleDir, | ||
this.resourcePath, | ||
inSourceBuild | ||
) | ||
if (!errorMessages) { | ||
if (!(err instanceof Error)) err = new Error(err) | ||
this.emitError(err) | ||
return callback(err, null) | ||
} | ||
getCompiledFile( | ||
buildDir, | ||
this._compilation, | ||
moduleDir, | ||
compiledFilePath, | ||
(err, res) => { | ||
if (err) { | ||
if (err instanceof Error) err = err.toString() | ||
const errorMessages = getBsbErrorMessages(err) | ||
for (let i = 0; i < errorMessages.length - 1; ++i) { | ||
this.emitError(new Error(errorMessages[i])) | ||
} | ||
if (!errorMessages) { | ||
if (!(err instanceof Error)) err = new Error(err) | ||
this.emitError(err) | ||
return callback(err, null) | ||
} | ||
for (let i = 0; i < errorMessages.length - 1; ++i) { | ||
this.emitError(new Error(errorMessages[i])) | ||
} | ||
callback(new Error(errorMessages[errorMessages.length - 1]), null) | ||
} else { | ||
callback(null, res) | ||
} | ||
callback(new Error(errorMessages[errorMessages.length - 1]), null) | ||
} else { | ||
callback(null, res) | ||
} | ||
) | ||
}) | ||
} | ||
) | ||
} | ||
@@ -159,0 +135,0 @@ |
{ | ||
"name": "bs-loader", | ||
"version": "1.7.4", | ||
"version": "1.7.5", | ||
"description": "Bucklescript integration in Webpack", | ||
@@ -13,12 +13,4 @@ "main": "index.js", | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"bucklescript", | ||
"reason", | ||
"webpack", | ||
"ocaml", | ||
"reasonml" | ||
], | ||
"files": ["index.js"], | ||
"keywords": ["bucklescript", "reason", "webpack", "ocaml", "reasonml"], | ||
"author": "Ryan Delaney <rrdelaney@outlook.com>", | ||
@@ -31,4 +23,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"loader-utils": "^1.1.0", | ||
"read-bsconfig": "^1.0.1" | ||
"loader-utils": "^1.1.0" | ||
}, | ||
@@ -40,11 +31,5 @@ "devDependencies": { | ||
"jest": { | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/test/", | ||
"/example/" | ||
], | ||
"projects": [ | ||
"test/*" | ||
] | ||
"testPathIgnorePatterns": ["/node_modules/", "/test/", "/example/"], | ||
"projects": ["test/*"] | ||
} | ||
} |
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
1
9046
125
- Removedread-bsconfig@^1.0.1
- Removedjson5@0.5.1(transitive)
- Removedread-bsconfig@1.0.5(transitive)