Socket
Socket
Sign inDemoInstall

bs-loader

Package Overview
Dependencies
6
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.3 to 1.7.4

86

index.js

@@ -0,1 +1,2 @@

const { readBsConfig } = require('read-bsconfig')
const path = require('path')

@@ -92,43 +93,66 @@ 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 moduleDir = options.module || 'js'
const inSourceBuild = options.inSource || false
const callback = this.async()
this.addContextDependency(this.context)
const callback = this.async()
const compiledFilePath = getJsFile(
buildDir,
moduleDir,
this.resourcePath,
inSourceBuild
)
getCompiledFile(
buildDir,
this._compilation,
moduleDir,
compiledFilePath,
(err, res) => {
if (err) {
if (err instanceof Error) err = err.toString()
const errorMessages = getBsbErrorMessages(err)
getBsConfigModuleOptions(buildDir).then(bsconfig => {
const moduleDir = options.module || bsconfig.moduleDir || 'js'
const inSourceBuild = options.inSource || bsconfig.inSource || false
if (!errorMessages) {
if (!(err instanceof Error)) err = new Error(err)
this.emitError(err)
return callback(err, null)
}
const compiledFilePath = getJsFile(
buildDir,
moduleDir,
this.resourcePath,
inSourceBuild
)
for (let i = 0; i < errorMessages.length - 1; ++i) {
this.emitError(new Error(errorMessages[i]))
getCompiledFile(
buildDir,
this._compilation,
moduleDir,
compiledFilePath,
(err, res) => {
if (err) {
if (err instanceof Error) err = err.toString()
const errorMessages = getBsbErrorMessages(err)
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)
}
}
)
)
})
}

@@ -135,0 +159,0 @@

{
"name": "bs-loader",
"version": "1.7.3",
"version": "1.7.4",
"description": "Bucklescript integration in Webpack",

@@ -13,4 +13,12 @@ "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>",

@@ -23,3 +31,4 @@ "license": "MIT",

"dependencies": {
"loader-utils": "^1.1.0"
"loader-utils": "^1.1.0",
"read-bsconfig": "^1.0.1"
},

@@ -31,5 +40,11 @@ "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