weboptimizer 4.0.72 → 4.0.74

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/browser.js CHANGED
@@ -37,84 +37,77 @@ export const log = new Logger({
37
37
  });
38
38
  // endregion
39
39
  // region ensure presence of common browser environment
40
- if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
41
- /*
42
- NOTE: We use an asynchronous wrapper method to initialize
43
- "browser.initialized" at module loading time.
44
- */
45
- (async () => {
46
- // region mock browser environment
47
- const [{
48
- JSDOM,
49
- VirtualConsole: VirtualConsoleImplementation
50
- }, path] = await Promise.all([import('jsdom'), import('path')]);
51
- const virtualConsole = new VirtualConsoleImplementation();
52
- for (const name of CONSOLE_METHODS) virtualConsole.on(name, console[name].bind(console));
53
- virtualConsole.on('error', error => {
54
- if (!browser.debug && ['XMLHttpRequest', 'resource loading'].includes(error.type)) log.warn(`Loading resource failed: ${error.toString()}.`);else log.error(error.stack, error.detail);
55
- });
56
- const render = template => {
57
- browser.DOM = JSDOM;
58
- browser.initialized = true;
59
- browser.instance = new browser.DOM(template, {
60
- beforeParse: window => {
61
- // We want to use it in a polymorphic way.
40
+ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node') {
41
+ // region mock browser environment
42
+ const [{
43
+ JSDOM,
44
+ VirtualConsole: VirtualConsoleImplementation
45
+ }, path] = await Promise.all([import('jsdom'), import('path')]);
46
+ const virtualConsole = new VirtualConsoleImplementation();
47
+ for (const name of CONSOLE_METHODS) virtualConsole.on(name, console[name].bind(console));
48
+ virtualConsole.on('error', error => {
49
+ if (!browser.debug && ['XMLHttpRequest', 'resource loading'].includes(error.type)) log.warn(`Loading resource failed: ${error.toString()}.`);else log.error(error.stack, error.detail);
50
+ });
51
+ const render = template => {
52
+ browser.DOM = JSDOM;
53
+ browser.initialized = true;
54
+ browser.instance = new browser.DOM(template, {
55
+ beforeParse: window => {
56
+ // We want to use it in a polymorphic way.
57
+ /*
58
+ eslint-disable
59
+ @typescript-eslint/no-unnecessary-type-assertion
60
+ */
61
+ browser.window = global.window ?? window;
62
+ /*
63
+ eslint-enable
64
+ @typescript-eslint/no-unnecessary-type-assertion
65
+ */
66
+
67
+ window.document.addEventListener('DOMContentLoaded', () => {
62
68
  /*
63
- eslint-disable
64
- @typescript-eslint/no-unnecessary-type-assertion
69
+ Move template results into global
70
+ pre-defined dom.
65
71
  */
66
- browser.window = global.window ?? window;
72
+ if (global.window) for (const type of ['head', 'body']) global.window.document[type].innerHTML = window.document[type].innerHTML;
73
+ browser.domContentLoaded = true;
74
+ });
75
+ window.addEventListener('load', () => {
67
76
  /*
68
- eslint-enable
69
- @typescript-eslint/no-unnecessary-type-assertion
77
+ NOTE: Maybe we have miss the "DOMContentLoaded"
78
+ event caused by a race condition.
70
79
  */
71
-
72
- window.document.addEventListener('DOMContentLoaded', () => {
73
- /*
74
- Move template results into global
75
- pre-defined dom.
76
- */
77
- if (global.window) for (const type of ['head', 'body']) global.window.document[type].innerHTML = window.document[type].innerHTML;
78
- browser.domContentLoaded = true;
79
- });
80
- window.addEventListener('load', () => {
81
- /*
82
- NOTE: Maybe we have miss the "DOMContentLoaded"
83
- event caused by a race condition.
84
- */
85
- browser.domContentLoaded = browser.windowLoaded = true;
86
- });
87
- for (const callback of onCreatedListener) void callback();
88
- },
89
- resources: 'usable',
90
- runScripts: 'dangerously',
91
- url: 'http://localhost',
92
- virtualConsole
93
- });
94
- };
95
- let evaluatedContent = '';
96
- if (typeof NAME === 'undefined' || NAME === 'webOptimizer') {
97
- const filePath = path.join(import.meta.dirname, 'index.html.ejs');
98
- /*
99
- NOTE: We load dependencies now to avoid having file imports
100
- after test runner has finished to isolate the environment.
101
- */
102
- const ejsLoader = (await import('./ejsLoader.js')).default;
103
- const content = await (await import('fs')).promises.readFile(filePath, {
104
- encoding: 'utf-8'
105
- });
106
- await ejsLoader.bind({
107
- resourcePath: filePath,
108
- async: () => (error, result) => {
109
- if (error) throw error;else evaluatedContent = result;
110
- }
111
- })(content);
112
- } else evaluatedContent = (await import('webOptimizerDefaultTemplateFilePath')).default;
113
- render(evaluatedContent);
114
- // endregion
115
- })().catch(error => {
116
- log.error(error);
117
- });else {
80
+ browser.domContentLoaded = browser.windowLoaded = true;
81
+ });
82
+ for (const callback of onCreatedListener) void callback();
83
+ },
84
+ resources: 'usable',
85
+ runScripts: 'dangerously',
86
+ url: 'http://localhost',
87
+ virtualConsole
88
+ });
89
+ };
90
+ let evaluatedContent = '';
91
+ if (typeof NAME === 'undefined' || NAME === 'webOptimizer') {
92
+ const filePath = path.join(import.meta.dirname, 'index.html.ejs');
93
+ /*
94
+ NOTE: We load dependencies now to avoid having file imports
95
+ after test runner has finished to isolate the environment.
96
+ */
97
+ const ejsLoader = (await import('./ejsLoader.js')).default;
98
+ const content = await (await import('fs')).promises.readFile(filePath, {
99
+ encoding: 'utf-8'
100
+ });
101
+ await ejsLoader.bind({
102
+ resourcePath: filePath,
103
+ async: () => (error, result) => {
104
+ if (error) throw error;else evaluatedContent = result;
105
+ }
106
+ })(content);
107
+ } else evaluatedContent = (await import('webOptimizerDefaultTemplateFilePath')).default;
108
+ render(evaluatedContent);
109
+ // endregion
110
+ } else {
118
111
  browser.initialized = true;
119
112
  browser.window = window;
120
113
  window.document.addEventListener('DOMContentLoaded', () => {
package/configurator.js CHANGED
@@ -16,7 +16,7 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- import { convertCircularObjectToJSON, copy, evaluateAsyncDynamicData, evaluateDynamicData, extend, getUTCTimestamp, importFilesystemAPI, isFileSync, isObject, isPlainObject, Logger, MAXIMAL_NUMBER_OF_ITERATIONS, modifyObject, optionalImport, parseEncodedObject, removeKeyPrefixes, UTILITY_SCOPE } from 'clientnode';
19
+ import { convertCircularObjectToJSON, copy, evaluateAsyncDynamicData, evaluateDynamicData, extend, getUTCTimestamp, importFilesystemAPI, isFile, isObject, isPlainObject, Logger, MAXIMAL_NUMBER_OF_ITERATIONS, modifyObject, optionalImport, parseEncodedObject, removeKeyPrefixes, UTILITY_SCOPE } from 'clientnode';
20
20
  import fileSystemSynchronous from 'fs';
21
21
  import fileSystem, { lstat, readFile, unlink } from 'fs/promises';
22
22
  import path, { basename, dirname, join, resolve } from 'path';
@@ -136,7 +136,7 @@ environment = eval('process.env')) => {
136
136
  let filePath = null;
137
137
  for (let iteration = 0; iteration < MAXIMAL_NUMBER_OF_ITERATIONS.value; iteration++) {
138
138
  const newFilePath = `${configuration.path.context}.dynamicConfiguration-` + `${String(count)}.json`;
139
- if (!isFileSync(newFilePath)) break;
139
+ if (!(await isFile(newFilePath))) break;
140
140
  filePath = newFilePath;
141
141
  count += 1;
142
142
  }
@@ -166,7 +166,7 @@ environment = eval('process.env')) => {
166
166
  if (Object.prototype.hasOwnProperty.call(result, '__reference__')) {
167
167
  const referenceNames = [].concat(result.__reference__);
168
168
  delete result.__reference__;
169
- for (const name of referenceNames) if (Object.prototype.hasOwnProperty.call(configuration, name)) extend(true, result, configuration[name]);else if (isFileSync(name)) extend(true, result, JSON.parse(await readFile(name, configuration.encoding)));else log.warn(`Given dynamic referenced configuration "${name}"`, 'could not be resolved.');
169
+ for (const name of referenceNames) if (Object.prototype.hasOwnProperty.call(configuration, name)) extend(true, result, configuration[name]);else if (await isFile(name)) extend(true, result, JSON.parse(await readFile(name, configuration.encoding)));else log.warn(`Given dynamic referenced configuration "${name}"`, 'could not be resolved.');
170
170
  }
171
171
  extend(true, modifyObject(configuration, result), result);
172
172
  }
package/ejsLoader.js CHANGED
@@ -174,67 +174,63 @@ export const loader = async function (source) {
174
174
  const templateInstance = new ejs.Template(template, options);
175
175
  templateInstance.compile();
176
176
  const compiledSourceCode = templateInstance.source;
177
- result = `module.exports =
178
- ${options.async ? 'async ' : ''}function(
179
- ${options.localsName}
177
+ result = `export default ${options.async ? 'async ' : ''}function(${options.localsName}) {
178
+ var escapeFn = function(value) {
179
+ return String(value)
180
+ .replace(
181
+ /[&<>"']/g,
182
+ function(char) {
183
+ return {
184
+ '&': '&amp;',
185
+ '<': '&lt;',
186
+ '>': '&gt;',
187
+ '"': '&quot;',
188
+ "'": "&#39;"
189
+ }[char]
190
+ }
191
+ )
192
+ };
193
+ var include = function() {
194
+ throw new Error('Include not implemented.')
195
+ };
196
+ var rethrow = function rethrow(
197
+ err, str, flnm, lineno, esc
180
198
  ) {
181
- var escapeFn = function(value) {
182
- return String(value)
183
- .replace(
184
- /[&<>"']/g,
185
- function(char) {
186
- return {
187
- '&': '&amp;',
188
- '<': '&lt;',
189
- '>': '&gt;',
190
- '"': '&quot;',
191
- "'": "&#39;"
192
- }[char]
193
- }
194
- )
195
- };
196
- var include = function() {
197
- throw new Error('Include not implemented.')
198
- };
199
- var rethrow = function rethrow(
200
- err, str, flnm, lineno, esc
201
- ) {
202
- var lines = str.split('\\n');
203
- var start = Math.max(lineno - 3, 0);
204
- var end = Math.min(
205
- lines.length, lineno + 3
206
- );
207
- var filename = esc(flnm);
208
- // Error context
209
- var context = lines
210
- .slice(start, end)
211
- .map(function (line, i) {
212
- var curr = i + start + 1;
213
- return (
214
- curr == lineno ?
215
- ' >> ' :
216
- ' '
217
- ) +
218
- curr +
219
- '| ' +
220
- line;
221
- })
222
- .join('\\n');
223
- // Alter exception message
224
- err.path = filename;
225
- err.message =
226
- (filename || 'ejs') +
227
- ':' +
228
- lineno +
229
- '\\n' +
230
- context +
231
- '\\n\\n' +
232
- err.message;
233
- throw err;
234
- };
235
- ${compiledSourceCode}
199
+ var lines = str.split('\\n');
200
+ var start = Math.max(lineno - 3, 0);
201
+ var end = Math.min(
202
+ lines.length, lineno + 3
203
+ );
204
+ var filename = esc(flnm);
205
+ // Error context
206
+ var context = lines
207
+ .slice(start, end)
208
+ .map(function (line, i) {
209
+ var curr = i + start + 1;
210
+ return (
211
+ curr == lineno ?
212
+ ' >> ' :
213
+ ' '
214
+ ) +
215
+ curr +
216
+ '| ' +
217
+ line;
218
+ })
219
+ .join('\\n');
220
+ // Alter exception message
221
+ err.path = filename;
222
+ err.message =
223
+ (filename || 'ejs') +
224
+ ':' +
225
+ lineno +
226
+ '\\n' +
227
+ context +
228
+ '\\n\\n' +
229
+ err.message;
230
+ throw err;
236
231
  };
237
- `.trim();
232
+ ${compiledSourceCode}
233
+ };`.trim();
238
234
  } else result = ejs.compile(result, options);
239
235
  }
240
236
  } else {
@@ -252,7 +248,7 @@ export const loader = async function (source) {
252
248
  minified: givenOptions.compress?.javaScript,
253
249
  presets: [],
254
250
  sourceMaps: false,
255
- sourceType: 'script'
251
+ sourceType: 'module'
256
252
  }, (error, file) => {
257
253
  if (error) reject(error);else resolve(file);
258
254
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "4.0.72",
3
+ "version": "4.0.74",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -120,7 +120,7 @@
120
120
  "rimraf": "^6.1.3",
121
121
  "script-loader": "^0.7.2",
122
122
  "typescript": "npm:@typescript/typescript6@^6.0.2",
123
- "webpack": "^5.110.2",
123
+ "webpack": "^5.110.3",
124
124
  "webpack-cli": "^7.2.3",
125
125
  "webpack-sources": "^3.5.1"
126
126
  },
@@ -134,7 +134,7 @@
134
134
  "@types/html-minifier": "^4.0.6",
135
135
  "@types/html-minifier-terser": "^7.0.2",
136
136
  "@types/imagemin": "^9.0.1",
137
- "@types/node": "^26.4.0",
137
+ "@types/node": "^26.4.1",
138
138
  "@types/postcss-import": "^14.0.3",
139
139
  "@types/postcss-url": "^10.0.4",
140
140
  "@types/webpack-env": "^1.18.8",
@@ -144,7 +144,7 @@
144
144
  "cssnano": "^9.0.2",
145
145
  "eslint": "^10.9.1",
146
146
  "eslint-config-google": "^0.14.0",
147
- "eslint-plugin-jsdoc": "^64.3.3",
147
+ "eslint-plugin-jsdoc": "^64.3.4",
148
148
  "favicons": "^7.3.1",
149
149
  "favicons-webpack-plugin": "^6.0.1",
150
150
  "globals": "^17.12.0",