uglify-js-minify-css-allfiles 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.2.2] - 2024-08-22
9
+
10
+ ### Fixed
11
+
12
+ - `excludeFolder` option now correctly excludes files in deeply nested directories
13
+ - Resolved `@babel/preset-env` dependency issue by implementing dynamic import for `babel-core`
14
+
8
15
  ## [2.2.0] - 2024-08-21
9
16
 
10
17
  ### Added
@@ -105,12 +112,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
105
112
 
106
113
  - New `exceptFolder` parameter to exclude specific folders from minification
107
114
  - Support for using relative paths
108
-
109
- [2.2.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v2.1.0...v2.2.0
110
- [2.1.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v2.0.0...v2.1.0
111
- [2.0.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.2...v2.0.0
112
- [1.3.2]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.1...v1.3.2
113
- [1.3.1]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.0...v1.3.1
114
- [1.3.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.2.0...v1.3.0
115
- [1.2.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.1.0...v1.2.0
116
- [1.1.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/releases/tag/v1.1.0
package/dist/module.js CHANGED
@@ -9,7 +9,17 @@ import path from 'path';
9
9
  import Logger from './modules/logger.js';
10
10
  import { getAllFiles, writeFile } from './modules/fileHandler.js';
11
11
  import { minifyJS, minifyCSS } from './modules/minifier.js';
12
- import babelCore from '@babel/core';
12
+ import { createRequire } from 'module';
13
+ import { fileURLToPath, pathToFileURL } from 'url';
14
+
15
+ const require = createRequire(import.meta.url);
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = path.dirname(__filename);
18
+
19
+ function resolveModulePath(moduleName) {
20
+ const modulePath = require.resolve(moduleName, { paths: [__dirname] });
21
+ return pathToFileURL(modulePath).href;
22
+ }
13
23
 
14
24
  /**
15
25
  * Object containing handlers for different file types.
@@ -31,7 +41,9 @@ const FILE_HANDLERS = {
31
41
  try {
32
42
  let transformed = content;
33
43
  if (options.babelOptions) {
34
- transformed = babelCore.transformSync(content, options.babelOptions).code;
44
+ const babelCoreUrl = resolveModulePath('@babel/core');
45
+ const { transformSync } = await import(babelCoreUrl);
46
+ transformed = transformSync(content, options.babelOptions).code;
35
47
  }
36
48
  const result = minifyJS(transformed, options.jsMinifyOptions);
37
49
  await writeFile(filePath, result, logger);
@@ -177,7 +189,12 @@ export default async function minifyAll(contentPath, options = {}) {
177
189
 
178
190
  try {
179
191
  await getAllFiles(rootDir, async (filePath) => {
180
- if (excludeFolder && path.relative(rootDir, filePath).startsWith(excludeFolder)) {
192
+ const relativePath = path.relative(rootDir, filePath);
193
+ if (
194
+ excludeFolder &&
195
+ (relativePath.startsWith(excludeFolder) ||
196
+ relativePath.includes(path.sep + excludeFolder + path.sep))
197
+ ) {
181
198
  await logger?.debug('Skipping excluded file', { filePath });
182
199
  return;
183
200
  }
@@ -0,0 +1,8 @@
1
+ [08/22/2024, 02:34:34] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
2
+ [08/22/2024, 02:34:34] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
3
+ [08/22/2024, 02:34:35] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
4
+ [08/22/2024, 02:34:35] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
5
+ [08/22/2024, 06:58:25] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
6
+ [08/22/2024, 06:58:25] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
7
+ [08/22/2024, 06:58:27] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
8
+ [08/22/2024, 06:58:27] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uglify-js-minify-css-allfiles",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "you will be able to minify all files as same file names which is js or css",
5
5
  "main": "minify.js",
6
6
  "type": "module",