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

@node-minify/core

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-minify/core - npm Package Compare versions

Comparing version 8.0.6 to 9.0.0

dist/index.d.mts

2

dist/index.d.ts

@@ -5,3 +5,3 @@ import { Settings } from '@node-minify/types';

* node-minify
* Copyright(c) 2011-2023 Rodolphe Stoclin
* Copyright(c) 2011-2024 Rodolphe Stoclin
* MIT Licensed

@@ -8,0 +8,0 @@ */

@@ -25,6 +25,64 @@ "use strict";

// src/compress.ts
var import_node_fs = __toESM(require("fs"));
var import_utils = require("@node-minify/utils");
var import_mkdirp = __toESM(require("mkdirp"));
var compress = (settings) => {
if (typeof settings.compressor !== "function") {
throw new Error(
"compressor should be a function, maybe you forgot to install the compressor"
);
}
if (settings.output) {
createDirectory(settings.output);
}
if (Array.isArray(settings.output)) {
return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
}
return import_utils.utils.compressSingleFile(settings);
};
var compressArrayOfFilesSync = (settings) => {
return Array.isArray(settings.input) && settings.input.forEach((input, index) => {
const content = import_utils.utils.getContentFromFiles(input);
return import_utils.utils.runSync({ settings, content, index });
});
};
var compressArrayOfFilesAsync = (settings) => {
let sequence = Promise.resolve();
Array.isArray(settings.input) && settings.input.forEach((input, index) => {
const content = import_utils.utils.getContentFromFiles(input);
sequence = sequence.then(
() => import_utils.utils.runAsync({ settings, content, index })
);
});
return sequence;
};
var createDirectory = (file) => {
if (Array.isArray(file)) {
file = file[0];
}
const dir = file?.substr(0, file.lastIndexOf("/"));
if (!dir) {
return;
}
if (!import_node_fs.default.statSync(dir).isDirectory()) {
import_mkdirp.default.sync(dir);
}
};
// src/compressInMemory.ts
var import_utils2 = require("@node-minify/utils");
var compressInMemory = (settings) => {
if (typeof settings.compressor !== "function") {
throw new Error(
"compressor should be a function, maybe you forgot to install the compressor"
);
}
return import_utils2.utils.compressSingleFile(settings);
};
// src/setup.ts
var import_path = __toESM(require("path"));
var import_glob = require("glob");
var import_utils = require("@node-minify/utils");
var import_node_path = __toESM(require("path"));
var import_utils3 = require("@node-minify/utils");
var import_fast_glob = require("fast-glob");
var defaultSettings = {

@@ -37,3 +95,6 @@ sync: false,

var setup = (inputSettings) => {
let settings = Object.assign(import_utils.utils.clone(defaultSettings), inputSettings);
let settings = Object.assign(
import_utils3.utils.clone(defaultSettings),
inputSettings
);
if (settings.content) {

@@ -45,3 +106,6 @@ checkMandatoriesMemoryContent(inputSettings);

if (settings.input) {
settings = Object.assign(settings, wildcards(settings.input, settings.publicFolder));
settings = Object.assign(
settings,
wildcards(settings.input, settings.publicFolder)
);
}

@@ -51,7 +115,15 @@ if (settings.input && settings.output) {

settings,
checkOutput(settings.input, settings.output, settings.publicFolder, settings.replaceInPlace)
checkOutput(
settings.input,
settings.output,
settings.publicFolder,
settings.replaceInPlace
)
);
}
if (settings.input && settings.publicFolder) {
settings = Object.assign(settings, setPublicFolder(settings.input, settings.publicFolder));
settings = Object.assign(
settings,
setPublicFolder(settings.input, settings.publicFolder)
);
}

@@ -61,12 +133,23 @@ return settings;

var checkOutput = (input, output, publicFolder, replaceInPlace) => {
const reg = new RegExp("\\$1");
const reg = /\$1/;
if (reg.test(output)) {
if (Array.isArray(input)) {
const outputMin = input.map(
(file) => import_utils.utils.setFileNameMin(file, output, replaceInPlace ? void 0 : publicFolder, replaceInPlace)
(file) => import_utils3.utils.setFileNameMin(
file,
output,
replaceInPlace ? void 0 : publicFolder,
replaceInPlace
)
);
return { output: outputMin };
} else {
return { output: import_utils.utils.setFileNameMin(input, output, replaceInPlace ? void 0 : publicFolder, replaceInPlace) };
}
return {
output: import_utils3.utils.setFileNameMin(
input,
output,
replaceInPlace ? void 0 : publicFolder,
replaceInPlace
)
};
}

@@ -98,3 +181,3 @@ };

if (isWildcardsPresent) {
output.input = (0, import_glob.globSync)(inputWithPublicFolder);
output.input = (0, import_fast_glob.globSync)(inputWithPublicFolder);
}

@@ -112,3 +195,3 @@ for (let i = 0; i < output.input.length; i++) {

if (input.indexOf("*") > -1) {
output = (0, import_glob.globSync)((publicFolder || "") + input);
output = (0, import_fast_glob.globSync)((publicFolder || "") + input);
}

@@ -122,13 +205,13 @@ return output;

}
publicFolder = import_path.default.normalize(publicFolder);
publicFolder = import_node_path.default.normalize(publicFolder);
if (Array.isArray(input)) {
output.input = input.map((item) => {
if (import_path.default.normalize(item).indexOf(publicFolder) > -1) {
if (import_node_path.default.normalize(item).indexOf(publicFolder) > -1) {
return item;
}
return import_path.default.normalize(publicFolder + item);
return import_node_path.default.normalize(publicFolder + item);
});
return output;
}
input = import_path.default.normalize(input);
input = import_node_path.default.normalize(input);
if (input.indexOf(publicFolder) > -1) {

@@ -138,70 +221,21 @@ output.input = input;

}
output.input = import_path.default.normalize(publicFolder + input);
output.input = import_node_path.default.normalize(publicFolder + input);
return output;
};
var checkMandatories = (settings) => {
["compressor", "input", "output"].forEach((item) => mandatory(item, settings));
["compressor", "input", "output"].forEach(
(item) => mandatory(item, settings)
);
};
var checkMandatoriesMemoryContent = (settings) => {
["compressor", "content"].forEach((item) => mandatory(item, settings));
["compressor", "content"].forEach(
(item) => mandatory(item, settings)
);
};
var mandatory = (setting, settings) => {
if (!settings[setting]) {
throw new Error(setting + " is mandatory.");
throw new Error(`${setting} is mandatory.`);
}
};
// src/compress.ts
var import_fs = __toESM(require("fs"));
var import_mkdirp = __toESM(require("mkdirp"));
var import_utils2 = require("@node-minify/utils");
var compress = (settings) => {
if (typeof settings.compressor !== "function") {
throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);
}
if (settings.output) {
createDirectory(settings.output);
}
if (Array.isArray(settings.output)) {
return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
} else {
return import_utils2.utils.compressSingleFile(settings);
}
};
var compressArrayOfFilesSync = (settings) => {
return Array.isArray(settings.input) && settings.input.forEach((input, index) => {
const content = import_utils2.utils.getContentFromFiles(input);
return import_utils2.utils.runSync({ settings, content, index });
});
};
var compressArrayOfFilesAsync = (settings) => {
let sequence = Promise.resolve();
Array.isArray(settings.input) && settings.input.forEach((input, index) => {
const content = import_utils2.utils.getContentFromFiles(input);
sequence = sequence.then(() => import_utils2.utils.runAsync({ settings, content, index }));
});
return sequence;
};
var createDirectory = (file) => {
if (Array.isArray(file)) {
file = file[0];
}
const dir = file && file.substr(0, file.lastIndexOf("/"));
if (!dir) {
return;
}
if (!import_fs.default.statSync(dir).isDirectory()) {
import_mkdirp.default.sync(dir);
}
};
// src/compressInMemory.ts
var import_utils3 = require("@node-minify/utils");
var compressInMemory = (settings) => {
if (typeof settings.compressor !== "function") {
throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);
}
return import_utils3.utils.compressSingleFile(settings);
};
// src/index.ts

@@ -237,5 +271,5 @@ var minify = (settings) => {

* node-minify
* Copyright(c) 2011-2023 Rodolphe Stoclin
* Copyright(c) 2011-2024 Rodolphe Stoclin
* MIT Licensed
*/
//# sourceMappingURL=index.js.map
{
"name": "@node-minify/core",
"version": "8.0.6",
"version": "9.0.0",
"description": "core of @node-minify",

@@ -14,3 +14,3 @@ "keywords": [

"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},

@@ -25,5 +25,7 @@ "directories": {

"exports": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},

@@ -43,17 +45,19 @@ "files": [

},
"scripts": {
"clean": "pnpm dlx rimraf dist",
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
"prepublishOnly": "pnpm build"
},
"dependencies": {
"@node-minify/utils": "8.0.6",
"glob": "9.3.5",
"mkdirp": "1.0.4"
"fast-glob": "3.3.2",
"mkdirp": "3.0.1",
"@node-minify/utils": "9.0.0"
},
"devDependencies": {
"@node-minify/types": "8.0.6",
"@types/mkdirp": "^1.0.2"
"@types/mkdirp": "^1.0.2",
"@node-minify/types": "9.0.0"
},
"gitHead": "9fb532af458cb6416ecfb7abfb9cc0a3b9cb42e1"
}
"scripts": {
"clean": "pnpm dlx rimraf dist",
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
"lint": "biome lint .",
"test": "vitest run",
"test:ci": "vitest run --coverage",
"test:watch": "vitest"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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