New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

html-bundler-webpack-plugin

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-bundler-webpack-plugin - npm Package Compare versions

Comparing version

to
4.10.1

# Change log
## 4.10.1 (2024-12-09)
- fix: re-deploy broken package `v4.10.0` in npm repository.
An error occurred during deployment.
## 4.10.0 (2024-12-08)

@@ -4,0 +9,0 @@

{
"name": "html-bundler-webpack-plugin",
"version": "4.10.0",
"version": "4.10.1",
"description": "Processing HTML templates and bundling assets. Build-in support for Markdown, Eta, EJS, Handlebars, Nunjucks, Pug. Alternative to html-webpack-plugin.",

@@ -56,8 +56,8 @@ "keywords": [

"security": "npm audit --production",
"test": "jest --config ./test/jest.config.js",
"test:coverage": "jest --collectCoverage --config ./test/jest.config.js",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --config ./test/jest.config.js",
"test:coverage": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --collectCoverage --config ./test/jest.config.js",
"test:index": "jest --detectOpenHandles --config ./test/jest.config.js --runTestsByPath ./test/index.test.js",
"test:issue": "jest --detectOpenHandles --config ./test/jest.config.js --runTestsByPath ./test/issue.test.js",
"test:messages": "jest --detectOpenHandles --config ./test/jest.config.js --runTestsByPath ./test/messages.test.js",
"test:unit": "jest --detectOpenHandles --collectCoverage --config ./test/jest.config.js --runTestsByPath ./test/unit.test.js",
"test:unit": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --detectOpenHandles --collectCoverage --config ./test/jest.config.js --runTestsByPath ./test/unit.test.js",
"test:unitQueryParser": "jest --detectOpenHandles --collectCoverage --config ./test/jest.config.js --runTestsByPath ./test/unit.queryParser.test.js",

@@ -64,0 +64,0 @@ "test:verbose": "jest --detectOpenHandles --config ./test/jest.config.js --runTestsByPath ./test/verbose.test.js",

// noinspection DuplicatedCode
const path = require('path');
const fs = require('fs');
const { red, redBright, cyan, whiteBright } = require('ansis');

@@ -16,2 +17,36 @@ const { isWin, pathToPosix } = require('./Helpers');

/**
* Dynamically load a CommonJS or ESM module.
*
* @param {string} filePath The path to the module file.
* @returns {Promise<any>} The loaded module.
* @throws
*/
async function asyncLoadModule(filePath) {
const absolutePath = path.resolve(filePath);
const ext = path.extname(absolutePath).toLowerCase();
if (!fs.existsSync(absolutePath)) {
throw new Error(`File not found: ${cyan(absolutePath)}`);
}
if (ext === '.mjs') {
// ESM file
return import(absolutePath);
} else if (ext === '.cjs' || ext === '.js') {
// CommonJS file
try {
return require(absolutePath);
} catch (error) {
if (error.code === 'ERR_REQUIRE_ESM') {
// fallback to ESM
return import(absolutePath);
}
throw error;
}
} else {
throw new Error(`Unsupported file type: ${cyan(`.${ext}`)}`);
}
}
/**
* Load node module.

@@ -33,3 +68,5 @@ *

if (error.code === 'MODULE_NOT_FOUND') {
const message = whiteBright`Cannot find module '${red(moduleName)}'. Please install the missing module: ${cyan`npm i -D ${moduleName}`}` + "\n";
const message =
whiteBright`Cannot find module '${red(moduleName)}'. Please install the missing module: ${cyan`npm i -D ${moduleName}`}` +
'\n';
throw new Error(message);

@@ -285,2 +322,3 @@ }

module.exports = {
asyncLoadModule,
loadModule,

@@ -287,0 +325,0 @@ isDir,