weboptimizer 4.0.62 → 4.0.64

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "4.0.62",
3
+ "version": "4.0.64",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -102,7 +102,7 @@
102
102
  "babel-loader": "^10.1.1",
103
103
  "babel-plugin-polyfill-corejs3": "^1.0.0",
104
104
  "babel-plugin-transform-rewrite-imports": "^1.5.4",
105
- "clientnode": "4.0.1498",
105
+ "clientnode": "4.0.1500",
106
106
  "core-js": "^3.50.0",
107
107
  "ejs": "^6.0.1",
108
108
  "exports-loader": "^5.0.0",
@@ -165,7 +165,7 @@
165
165
  "terser-webpack-plugin": "^5.6.1",
166
166
  "typescript-eslint": "^8.68.0",
167
167
  "typescript-plugin-css-modules": "^5.2.0",
168
- "web-documentation": "^1.0.49",
168
+ "web-documentation": "^1.0.50",
169
169
  "workbox-webpack-plugin": "^7.4.1"
170
170
  },
171
171
  "peerDependencies": {
@@ -16,7 +16,7 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- import { convertToValidVariableName, evaluate, escapeRegularExpressions, extend, importFilesystemAPI, isFileSync, isObject, isPlainObject, Logger, mask, optionalImport, represent, UTILITY_SCOPE } from 'clientnode';
19
+ import { convertToValidVariableName, evaluate, evaluateOrThrowError as evaluateOrThrowErrorBase, escapeRegularExpressions, extend, importFilesystemAPI, isFileSync, isObject, isPlainObject, Logger, mask, optionalImport, represent, UTILITY_SCOPE } from 'clientnode';
20
20
  import { rm, writeFile } from 'fs/promises';
21
21
  import { extname, join, relative, resolve } from 'path';
22
22
  import util from 'util';
@@ -370,34 +370,33 @@ const scope = {
370
370
  isFilePathInDependencies,
371
371
  loader
372
372
  };
373
- const evaluateOrThrowOnError = (object, givenOptions = {}) => {
373
+ const evaluateOrThrowError = (object, givenOptions = {}) => {
374
374
  const options = {
375
+ async: false,
375
376
  filePath: configuration.path.context,
376
377
  ...givenOptions
377
378
  };
378
- if (typeof object === 'string') {
379
- const evaluated = evaluate(object, {
380
- scope: {
381
- filePath: options.filePath,
382
- ...scope,
383
- type: options.type
384
- }
385
- });
386
- if (evaluated.error) throw new Error('Error occurred during processing given expression: ' + evaluated.error);
387
- return evaluated.result;
388
- }
379
+ if (typeof object === 'string') evaluateOrThrowErrorBase(object, {
380
+ async: options.async,
381
+ scope: {
382
+ filePath: options.filePath,
383
+ ...scope,
384
+ type: options.type
385
+ }
386
+ });
389
387
  return object;
390
388
  };
391
- const createEvaluateMapper = type => value => evaluateOrThrowOnError(value, {
389
+ const createEvaluateMapper = (type, async = false) => value => evaluateOrThrowError(value, {
390
+ async,
392
391
  type
393
392
  });
394
393
  const evaluateAdditionalLoaderConfiguration = loaderConfiguration => ({
395
- exclude: filePath => evaluateOrThrowOnError(loaderConfiguration.exclude, {
394
+ exclude: filePath => evaluateOrThrowError(loaderConfiguration.exclude, {
396
395
  filePath
397
396
  }),
398
- include: loaderConfiguration.include && evaluateOrThrowOnError(loaderConfiguration.include) || configuration.path.source.base,
399
- test: new RegExp(evaluateOrThrowOnError(loaderConfiguration.test)),
400
- use: evaluateOrThrowOnError(loaderConfiguration.use)
397
+ include: loaderConfiguration.include && evaluateOrThrowError(loaderConfiguration.include) || configuration.path.source.base,
398
+ test: new RegExp(evaluateOrThrowError(loaderConfiguration.test)),
399
+ use: evaluateOrThrowError(loaderConfiguration.use)
401
400
  });
402
401
  const getIncludingPaths = path => normalizePaths([path].concat(module.locations.directoryPaths));
403
402
  const postCSSResolver = (name, _context) => {
@@ -422,7 +421,7 @@ const cssUse = (await Promise.all(module.preprocessor.cascadingStyleSheet.additi
422
421
  plugins: [].concat(postcssImport ? postcssImport({
423
422
  root: configuration.path.context,
424
423
  resolve: postCSSResolver
425
- }) : [], await Promise.all(module.preprocessor.cascadingStyleSheet.additional.plugins.pre.map(createEvaluateMapper('css.postcss'))),
424
+ }) : [], await Promise.all(module.preprocessor.cascadingStyleSheet.additional.plugins.pre.map(createEvaluateMapper('css.postcss', true))),
426
425
  /*
427
426
  NOTE: Checking path doesn't work if fonts
428
427
  are referenced in libraries provided in
@@ -470,7 +469,7 @@ const genericLoader = {
470
469
  // Convert to compatible native web types.
471
470
  // region generic template
472
471
  ejs: {
473
- exclude: filePath => normalizePaths(configuration.files.html.concat(configuration.files.defaultHTML).map(htmlConfiguration => htmlConfiguration.template.filePath)).includes(filePath) || module.preprocessor.ejs.exclude === null ? false : evaluateOrThrowOnError(module.preprocessor.ejs.exclude, {
472
+ exclude: filePath => normalizePaths(configuration.files.html.concat(configuration.files.defaultHTML).map(htmlConfiguration => htmlConfiguration.template.filePath)).includes(filePath) || module.preprocessor.ejs.exclude === null ? false : evaluateOrThrowError(module.preprocessor.ejs.exclude, {
474
473
  filePath
475
474
  }),
476
475
  include: getIncludingPaths(configuration.path.source.asset.template),
@@ -487,12 +486,12 @@ const genericLoader = {
487
486
  // endregion
488
487
  // region script
489
488
  script: {
490
- exclude: filePath => evaluateOrThrowOnError(module.preprocessor.javaScript.exclude, {
489
+ exclude: filePath => evaluateOrThrowError(module.preprocessor.javaScript.exclude, {
491
490
  filePath,
492
491
  type: 'script'
493
492
  }),
494
493
  include: filePath => {
495
- const result = evaluateOrThrowOnError(module.preprocessor.javaScript.include, {
494
+ const result = evaluateOrThrowError(module.preprocessor.javaScript.include, {
496
495
  filePath,
497
496
  type: 'script'
498
497
  });
@@ -517,7 +516,7 @@ const genericLoader = {
517
516
  use: configuration.files.defaultHTML.template.use
518
517
  },
519
518
  ejs: {
520
- exclude: filePath => normalizePaths(configuration.files.html.concat(configuration.files.defaultHTML).map(htmlConfiguration => htmlConfiguration.template.filePath)).includes(filePath) || (module.preprocessor.html.exclude === null ? false : evaluateOrThrowOnError(module.preprocessor.html.exclude, {
519
+ exclude: filePath => normalizePaths(configuration.files.html.concat(configuration.files.defaultHTML).map(htmlConfiguration => htmlConfiguration.template.filePath)).includes(filePath) || (module.preprocessor.html.exclude === null ? false : evaluateOrThrowError(module.preprocessor.html.exclude, {
521
520
  filePath,
522
521
  type: 'html.ejs'
523
522
  })),
@@ -543,7 +542,7 @@ const genericLoader = {
543
542
  }, await Promise.all(module.preprocessor.html.additional.post.map(createEvaluateMapper('html.ejs'))))
544
543
  },
545
544
  html: {
546
- exclude: filePath => normalizePaths(configuration.files.html.concat(configuration.files.defaultHTML).map(htmlConfiguration => htmlConfiguration.template.filePath)).includes(filePath) || (module.html.exclude === null ? true : evaluateOrThrowOnError(module.html.exclude, {
545
+ exclude: filePath => normalizePaths(configuration.files.html.concat(configuration.files.defaultHTML).map(htmlConfiguration => htmlConfiguration.template.filePath)).includes(filePath) || (module.html.exclude === null ? true : evaluateOrThrowError(module.html.exclude, {
547
546
  filePath,
548
547
  type: 'html'
549
548
  })),
@@ -563,12 +562,12 @@ const genericLoader = {
563
562
  // Load dependencies.
564
563
  // region style
565
564
  style: {
566
- exclude: filePath => module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateOrThrowOnError(module.cascadingStyleSheet.exclude, {
565
+ exclude: filePath => module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateOrThrowError(module.cascadingStyleSheet.exclude, {
567
566
  filePath,
568
567
  type: 'style'
569
568
  }),
570
569
  include: filePath => {
571
- const result = evaluateOrThrowOnError(module.cascadingStyleSheet.include, {
570
+ const result = evaluateOrThrowError(module.cascadingStyleSheet.include, {
572
571
  filePath,
573
572
  type: 'style'
574
573
  });
@@ -586,7 +585,7 @@ const genericLoader = {
586
585
  // region font
587
586
  font: {
588
587
  eot: {
589
- exclude: filePath => module.optimizer.font.eot.exclude === null ? false : evaluateOrThrowOnError(module.optimizer.font.eot.exclude, {
588
+ exclude: filePath => module.optimizer.font.eot.exclude === null ? false : evaluateOrThrowError(module.optimizer.font.eot.exclude, {
590
589
  filePath,
591
590
  type: 'font.eot'
592
591
  }),
@@ -603,7 +602,7 @@ const genericLoader = {
603
602
  use: await Promise.all(module.optimizer.font.eot.loader.map(createEvaluateMapper('font.eot')))
604
603
  },
605
604
  svg: {
606
- exclude: filePath => module.optimizer.font.svg.exclude === null ? false : evaluateOrThrowOnError(module.optimizer.font.svg.exclude, {
605
+ exclude: filePath => module.optimizer.font.svg.exclude === null ? false : evaluateOrThrowError(module.optimizer.font.svg.exclude, {
607
606
  filePath,
608
607
  type: 'svg'
609
608
  }),
@@ -622,7 +621,7 @@ const genericLoader = {
622
621
  use: await Promise.all(module.optimizer.font.svg.loader.map(createEvaluateMapper('font.svg')))
623
622
  },
624
623
  ttf: {
625
- exclude: filePath => module.optimizer.font.ttf.exclude === null ? false : evaluateOrThrowOnError(module.optimizer.font.ttf.exclude, {
624
+ exclude: filePath => module.optimizer.font.ttf.exclude === null ? false : evaluateOrThrowError(module.optimizer.font.ttf.exclude, {
626
625
  filePath,
627
626
  type: 'ttf'
628
627
  }),
@@ -640,7 +639,7 @@ const genericLoader = {
640
639
  use: await Promise.all(module.optimizer.font.ttf.loader.map(createEvaluateMapper('font.ttf')))
641
640
  },
642
641
  woff: {
643
- exclude: filePath => module.optimizer.font.woff.exclude === null ? false : evaluateOrThrowOnError(module.optimizer.font.woff.exclude, {
642
+ exclude: filePath => module.optimizer.font.woff.exclude === null ? false : evaluateOrThrowError(module.optimizer.font.woff.exclude, {
644
643
  filePath,
645
644
  type: 'woff'
646
645
  }),
@@ -660,7 +659,7 @@ const genericLoader = {
660
659
  // endregion
661
660
  // region image
662
661
  image: {
663
- exclude: filePath => module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateOrThrowOnError(module.optimizer.image.exclude, {
662
+ exclude: filePath => module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateOrThrowError(module.optimizer.image.exclude, {
664
663
  filePath,
665
664
  type: 'image'
666
665
  }),
@@ -682,7 +681,7 @@ const genericLoader = {
682
681
  data: {
683
682
  exclude: filePath => {
684
683
  if (typeof filePath !== 'string') return false;
685
- return configuration.extensions.file.internal.includes(extname(stripLoader(filePath))) || (module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : evaluateOrThrowOnError(module.optimizer.data.exclude, {
684
+ return configuration.extensions.file.internal.includes(extname(stripLoader(filePath))) || (module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : evaluateOrThrowError(module.optimizer.data.exclude, {
686
685
  filePath,
687
686
  type: 'data'
688
687
  }));