Socket
Socket
Sign inDemoInstall

resolve-url-loader

Package Overview
Dependencies
50
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 2.2.0

1

index.js

@@ -45,2 +45,3 @@ /*

keepQuery : false,
attempts : 0,
debug : false,

@@ -47,0 +48,0 @@ root : null,

24

lib/find-file.js

@@ -11,7 +11,8 @@ 'use strict';

* Factory for find-file with the given <code>options</code> hash.
* @param {{debug: boolean}} [opt] Optional options hash
* @param {{debug: boolean, attempts:number}} [opt] Optional options hash
*/
function findFile(opt) {
var options = defaults(opt, {
debug: false
debug: false,
attempts: 0
});

@@ -50,2 +51,5 @@ return {

// #69 limit searching: make at least one attempt
var remaining = Math.max(0, options.attempts) || 1E+9;
// ignore explicit uris data|http|https and ensure we are at a valid start path

@@ -68,5 +72,5 @@ var absoluteStart = !(/^(data|https?):/.test(uri)) && path.resolve(startPath);

// process the queue until empty
// the queue pattern ensures that we favour paths closest the the start path
while (queue.length) {
// the queue pattern ensures that we favour paths closest the the start path
// process the queue until empty or until we exhaust our attempts
while (queue.length && (remaining-- > 0)) {

@@ -89,5 +93,11 @@ // shift the first item off the queue, consider it the base for our relative uri

// interrupted by options.attempts
if (queue.length) {
flushMessages('NOT FOUND (INTERRUPTED)');
}
// not found
flushMessages('NOT FOUND');
return null;
else {
flushMessages('NOT FOUND');
return null;
}
}

@@ -94,0 +104,0 @@ // ignored

{
"name": "resolve-url-loader",
"version": "2.1.1",
"version": "2.2.0",
"description": "Webpack loader that resolves relative paths in url() statements based on the original source file",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -105,2 +105,4 @@ # Resolve URL Loader

* `attempts` Limit searching for any files not where they are expected to be. This is unlimited by default so you will want to set it `1` or some small value.
* `silent` Do not display warnings on CSS syntax or source-map error.

@@ -121,3 +123,3 @@

* `includeRoot` (experimental, non-performant) Include the project `root` in file search. The `root` option need **not** be specified.
* `includeRoot` (experimental, non-performant) Include the project `root` in file search. The `root` option need not be specified but `includeRoot` is only really useful if your `root` directory is shallower than your build working directory.

@@ -132,10 +134,10 @@ Note that query parameters take precedence over programmatic parameters.

Usually the asset is found relative to the original source file `O(1)`. However in some cases there is no immediate match (*cough* bootstrap *cough*) and we so we start searching both deeper and shallower from the starting directory `O(n)`.
Usually the asset is found relative to the original source file `O(1)`.
However in cases where there is no immediate match, we start searching both deeper and shallower from the starting directory `O(n)`. Note that `n` may be limited by the `attempts` option.
This file search "magic" is mainly for historic reasons, to work around broken packages whose assets are not where we would expect.
Shallower paths must be limited to avoid the whole file system from being considered. Progressively shallower paths within the `root` will be considered. Paths featuring a `package.json` or `bower.json` file will not be considered.
* This effectively excludes your project root (except where `options.includeRoot`).
* Search in a project subdirectory will not escape that subdirectory (except where`options.includeRoot`).
* Search of a package in `node_modules` will not escape that package.
If the asset is not found then the `url()` statement will not be updated with a Webpack module-relative path. However if the `url()` statement has no source-map `source` information the loader will fail.

@@ -145,4 +147,17 @@

Use the `debug` option to see exactly what paths are being searched.
## Limitations / Known-issues
### File search "magic"
Failure to find an asset will trigger a file search of your project.
This feature was for historic reasons, to work around broken packages, whose assets are not where we would expect. Such problems are rare now and many users may not be aware of the search feature.
We now have the `attempts` option to limit this feature. However by default it is unlimited (`attempts=0`) which could make your build non-performant.
You should explicitly set `attempts=1` and increase the value only if needed. We will look to make this the default in the next major release.
### Mixins

@@ -149,0 +164,0 @@

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