Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webdiscus/pug-loader

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webdiscus/pug-loader - npm Package Compare versions

Comparing version 2.10.4 to 2.10.5

4

CHANGELOG.md
# Change log
## 2.10.5 (2023-08-12)
- fix: add the svg file referenced with a fragment, e.g. `icons.svg#home`, to watch dependencies
- chore: update packages
## 2.10.4 (2023-03-10)

@@ -4,0 +8,0 @@ - fix(for pug-plugin): add missing node modules to compilation after rebuild

26

package.json
{
"name": "@webdiscus/pug-loader",
"version": "2.10.4",
"version": "2.10.5",
"description": "Pug loader renders Pug files into HTML or compiles them into a template function.",

@@ -77,20 +77,20 @@ "keywords": [

"pug": "^3.0.2",
"webpack-merge": "^5.8.0"
"webpack-merge": "^5.9.0"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@types/jest": "^29.4.0",
"css-loader": "^6.7.3",
"@babel/core": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@types/jest": "^29.5.3",
"css-loader": "^6.8.1",
"html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.0",
"jest": "^29.4.1",
"prettier": "^2.8.3",
"html-webpack-plugin": "^5.5.3",
"jest": "^29.6.2",
"prettier": "^3.0.1",
"prismjs": "^1.29.0",
"pug-plugin": "4.9.5",
"pug-plugin": "4.9.8",
"responsive-loader": "^3.1.2",
"sharp": "^0.31.3",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"webpack": "^5.75.0"
"sharp": "^0.32.4",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"webpack": "^5.88.2"
}
}

@@ -30,9 +30,9 @@ const fs = require('fs');

// resolver for scripts from the 'script' tag, npm modules and other js files
this.resolveFile = ResolverFactory.create.sync({
// resolver for scripts from the 'script' tag, npm modules, and other js files
this.resolveScript = ResolverFactory.create.sync({
...options,
preferRelative: options.preferRelative !== false,
// resolve 'exports' field in package.json, default value is ['webpack', 'production', 'browser']
// resolve 'exports' field in package.json, default value is: ['webpack', 'production', 'browser']
conditionNames: ['require', 'node'],
// restrict default extensions list '.js', '.json', '.wasm' for faster resolving
// restrict default extensions list '.js', '.json', '.wasm' for faster resolving of script files
extensions: options.extensions.length ? options.extensions : ['.js'],

@@ -47,3 +47,3 @@ });

conditionNames: ['style', 'sass'],
// firstly try to resolve 'browser' or 'style' fields in package.json to get compiled CSS bundle of a module,
// firstly, try to resolve 'browser' or 'style' fields in package.json to get compiled CSS bundle of a module,
// e.g. bootstrap has the 'style' field, but material-icons has the 'browser' field for resolving the CSS file;

@@ -57,2 +57,14 @@ // if a module has not a client specified field, then must be used path to client file of the module,

});
// resolver for resources: scripts w/o an ext (e.g.: require('./data')), images, fonts, etc.
this.resolveFile = ResolverFactory.create.sync({
...options,
preferRelative: options.preferRelative !== false,
// resolve 'exports' field in package.json, default value is: ['webpack', 'production', 'browser']
conditionNames: ['require', 'node'],
// restrict default extensions list '.js', '.json', '.wasm' for faster resolving of script files
extensions: options.extensions.length ? options.extensions : ['.js'],
// remove extensions for faster resolving of files different from styles and scripts
//extensions: [], // don't work if required js file w/o an ext in template
});
}

@@ -63,3 +75,3 @@

*
* @param {string} file The file to resolve.
* @param {string} request The file to resolve.
* @param {string} templateFile The template file.

@@ -69,3 +81,3 @@ * @param {string} [type = 'default'] The require type: 'default', 'script', 'style'.

*/
static resolve(file, templateFile, type = 'default') {
static resolve(request, templateFile, type = 'default') {
const context = path.dirname(templateFile);

@@ -75,35 +87,43 @@ const isScript = type === 'script';

let isAliasArray = false;
let resolvedFile = null;
let resolvedRequest = null;
// resolve an absolute path by prepending options.basedir
if (file[0] === '/') {
resolvedFile = path.join(this.basedir, file);
if (request[0] === '/') {
resolvedRequest = path.join(this.basedir, request);
}
// resolve a relative file
if (resolvedFile == null && file[0] === '.') {
resolvedFile = path.join(context, file);
if (resolvedRequest == null && request[0] === '.') {
resolvedRequest = path.join(context, request);
}
// resolve a file by webpack `resolve.alias`
if (resolvedFile == null) {
resolvedFile = this.resolveAlias(file);
isAliasArray = Array.isArray(resolvedFile);
if (resolvedRequest == null) {
resolvedRequest = this.resolveAlias(request);
isAliasArray = Array.isArray(resolvedRequest);
}
// fallback to enhanced resolver
if (resolvedFile == null || isAliasArray) {
let request = file;
if (resolvedRequest == null || isAliasArray) {
let normalizedRequest = request;
// remove optional prefix in request for enhanced resolver
if (isAliasArray) request = this.removeAliasPrefix(request);
if (isAliasArray) normalizedRequest = this.removeAliasPrefix(normalizedRequest);
try {
resolvedFile = isStyle ? this.resolveStyle(context, request) : this.resolveFile(context, request);
resolvedRequest = isScript
? this.resolveScript(context, normalizedRequest)
: isStyle
? this.resolveStyle(context, normalizedRequest)
: this.resolveFile(context, normalizedRequest);
} catch (error) {
resolveException(error, file, templateFile);
resolveException(error, request, templateFile);
}
}
// request of the svg file can contain a fragment id, e.g., shapes.svg#circle
const separator = resolvedRequest.indexOf('#') > 0 ? '#' : '?';
const [resolvedFile] = resolvedRequest.split(separator, 1);
if (isScript) {
resolvedFile = this.resolveScriptExtension(resolvedFile);
resolvedRequest = this.resolveScriptExtension(resolvedRequest);
} else {

@@ -113,3 +133,3 @@ Dependency.add(resolvedFile);

return isWin ? pathToPosix(resolvedFile) : resolvedFile;
return isWin ? pathToPosix(resolvedRequest) : resolvedRequest;
}

@@ -116,0 +136,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc