Socket
Socket
Sign inDemoInstall

bs-loader

Package Overview
Dependencies
5
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.2 to 1.7.3

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.2",
"version": "1.7.3",
"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/*"]
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc