resolve-url-loader
Advanced tools
Comparing version 5.0.0-alpha.1 to 5.0.0-beta.1
65
index.js
@@ -7,14 +7,14 @@ /* | ||
var os = require('os'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
util = require('util'), | ||
loaderUtils = require('loader-utils'), | ||
SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
const os = require('os'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const util = require('util'); | ||
const loaderUtils = require('loader-utils'); | ||
const SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
var adjustSourceMap = require('adjust-sourcemap-loader/lib/process'); | ||
const adjustSourceMap = require('adjust-sourcemap-loader/lib/process'); | ||
var valueProcessor = require('./lib/value-processor'), | ||
joinFn = require('./lib/join-function'), | ||
logToTestHarness = require('./lib/log-to-test-harness'); | ||
const valueProcessor = require('./lib/value-processor'); | ||
const joinFn = require('./lib/join-function'); | ||
const logToTestHarness = require('./lib/log-to-test-harness'); | ||
@@ -24,3 +24,3 @@ const DEPRECATED_OPTIONS = { | ||
'DEP_RESOLVE_URL_LOADER_OPTION_ENGINE', | ||
'the "engine" option is deprecated, "postcss" engine is the default, there are no other available engines' | ||
'"engine" option has been removed, postcss is the only parser used' | ||
], | ||
@@ -60,3 +60,3 @@ keepQuery: [ | ||
// details of the file being processed | ||
var loader = this; | ||
const loader = this; | ||
@@ -72,13 +72,9 @@ // a relative loader.context is a problem | ||
// infer webpack version from new loader features | ||
var isWebpackGte5 = 'getOptions' in loader && typeof loader.getOptions === 'function'; | ||
const isWebpackGte5 = 'getOptions' in loader && typeof loader.getOptions === 'function'; | ||
// webpack 1: prefer loader query, else options object | ||
// webpack 2: prefer loader options | ||
// webpack 3: deprecate loader.options object | ||
// webpack 4: loader.options no longer defined | ||
var rawOptions = loaderUtils.getOptions(loader), | ||
options = Object.assign( | ||
// use loader.getOptions where available otherwise use loaderUtils | ||
const rawOptions = isWebpackGte5 ? loader.getOptions() : loaderUtils.getOptions(loader); | ||
const options = Object.assign( | ||
{ | ||
sourceMap: loader.sourceMap, | ||
engine : 'postcss', | ||
silent : false, | ||
@@ -90,3 +86,3 @@ removeCR : os.EOL.includes('\r'), | ||
}, | ||
rawOptions | ||
rawOptions, | ||
); | ||
@@ -103,3 +99,3 @@ | ||
// deprecated options | ||
var deprecatedItems = Object.entries(DEPRECATED_OPTIONS).filter(([key]) => key in rawOptions); | ||
const deprecatedItems = Object.entries(DEPRECATED_OPTIONS).filter(([key]) => key in rawOptions); | ||
if (deprecatedItems.length) { | ||
@@ -123,3 +119,3 @@ deprecatedItems.forEach(([, value]) => handleAsDeprecated(...value)); | ||
// validate the result of calling the join option | ||
var joinProper = options.join(options, loader); | ||
const joinProper = options.join(options, loader); | ||
if (typeof joinProper !== 'function') { | ||
@@ -139,3 +135,3 @@ return handleAsError( | ||
if (typeof options.root === 'string') { | ||
var isValid = (options.root === '') || | ||
const isValid = (options.root === '') || | ||
(path.isAbsolute(options.root) && fs.existsSync(options.root) && fs.statSync(options.root).isDirectory()); | ||
@@ -160,3 +156,4 @@ | ||
// incoming source-map | ||
var sourceMapConsumer, absSourceMap; | ||
let absSourceMap = null; | ||
let sourceMapConsumer = null; | ||
if (sourceMap) { | ||
@@ -198,16 +195,6 @@ | ||
// choose a CSS engine | ||
var enginePath = /^[\w-]+$/.test(options.engine) && path.join(__dirname, 'lib', 'engine', options.engine + '.js'); | ||
var isValidEngine = fs.existsSync(enginePath); | ||
if (!isValidEngine) { | ||
return handleAsError( | ||
'loader misconfiguration', | ||
'"engine" option is not valid' | ||
); | ||
} | ||
// allow engine to throw at initialisation | ||
var engine; | ||
let engine = null; | ||
try { | ||
engine = require(enginePath); | ||
engine = require('./lib/engine/postcss'); | ||
} catch (error) { | ||
@@ -221,3 +208,3 @@ return handleAsError( | ||
// process async | ||
var callback = loader.async(); | ||
const callback = loader.async(); | ||
Promise | ||
@@ -248,3 +235,3 @@ .resolve(engine(loader.resourcePath, content, { | ||
if (options.sourceMap) { | ||
var finalMap = adjustSourceMap(loader, { | ||
const finalMap = adjustSourceMap(loader, { | ||
format: isWebpackGte5 ? 'projectRelative' : 'sourceRelative' | ||
@@ -251,0 +238,0 @@ }, result.map); |
{ | ||
"name": "resolve-url-loader", | ||
"version": "5.0.0-alpha.1", | ||
"version": "5.0.0-beta.1", | ||
"description": "Webpack loader that resolves relative paths in url() statements based on the original source file", | ||
@@ -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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
3
111579
19
919