Skip to content

Commit

Permalink
fix: compute integrity for the current compilation only to isolate th…
Browse files Browse the repository at this point in the history
…em by async tests
  • Loading branch information
webdiscus committed Nov 7, 2023
1 parent 3559ea0 commit ce0fd65
Show file tree
Hide file tree
Showing 45 changed files with 713 additions and 235 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change log

## 2.16.0-beta.2 (2023-10-24)

- fix: compute integrity for the current compilation only to isolate them by async tests
- fix: output exceptions for new callbacks
- test: add test for `beforePreprocessor` hook
- test: add test for `beforePreprocessor` callback
- test: add test for `preprocessor` hook
- test: add test for `beforeEmit` hook
- test: add test for `beforeEmit` callback
- test: add test for `afterEmit` hook
- test: add test for `afterEmit` callback

## 2.16.0-beta.1 (2023-10-23)

- feat: add `js.inline.keepAttributes` option to allow keep some original script tag attributes when JS is inlined
Expand Down
80 changes: 78 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-bundler-webpack-plugin",
"version": "2.16.0-beta.0",
"version": "2.16.0-beta.2",
"description": "HTML bundler plugin for webpack handles a template as an entry point, extracts CSS and JS from their sources referenced in HTML, supports template engines like Eta, EJS, Handlebars, Nunjucks.",
"keywords": [
"html",
Expand Down Expand Up @@ -112,6 +112,7 @@
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^5.0.1",
"ejs": "^3.1.9",
"favicons": "^7.1.4",
"handlebars": "^4.7.8",
"handlebars-layouts": "^3.1.4",
"jest": "^29.7.0",
Expand Down
6 changes: 3 additions & 3 deletions src/Loader/Messages/Exeptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ const preprocessorError = (error, file) => {
* @param {string} file
* @returns {Error}
*/
const compileError = (error, file) => {
return new LoaderException(`Template compilation failed.\nFile: ${cyan(file)}`, error);
const resolveError = (error, file) => {
return new LoaderException(`Resolving of source files in the template file failed.\nFile: ${cyan(file)}`, error);
};

/**
Expand All @@ -209,6 +209,6 @@ module.exports = {
initError,
beforePreprocessorError,
preprocessorError,
compileError,
resolveError,
exportError,
};
1 change: 0 additions & 1 deletion src/Loader/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class Options {
}

// preprocessor

if (!Preprocessor.isReady(options.preprocessor)) {
options.preprocessor = Preprocessor.factory(loaderContext, {
preprocessor: options.preprocessor,
Expand Down
6 changes: 3 additions & 3 deletions src/Loader/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Template {
* @return {string}
*/

static compile(content, issuer, entryId) {
static resolve(content, issuer, entryId) {
const sources = Options.getSources();

if (sources === false) {
Expand All @@ -34,7 +34,7 @@ class Template {

for (let { type, parsedAttrs } of parsedTags) {
for (let { startPos, endPos, value: file, offset } of parsedAttrs) {
const resolvedFile = this.resolve({ isBasedir, type, file, issuer, entryId });
const resolvedFile = this.resolveFile({ isBasedir, type, file, issuer, entryId });
// skip not resolvable value, e.g. URL
if (!resolvedFile) continue;

Expand Down Expand Up @@ -71,7 +71,7 @@ class Template {
* @param {string|number} entryId The entry id where is loaded the resource.
* @return {string|boolean} Return a resolved full path of source file or false.
*/
static resolve({ isBasedir, type, file, issuer, entryId }) {
static resolveFile({ isBasedir, type, file, issuer, entryId }) {
file = file.trim();

if (
Expand Down
11 changes: 6 additions & 5 deletions src/Loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
initError,
beforePreprocessorError,
preprocessorError,
compileError,
resolveError,
exportError,
} = require('./Messages/Exeptions');

Expand Down Expand Up @@ -75,8 +75,9 @@ const loader = function (content, map, meta) {
return value;
})
.then((value) => {
errorStage = 'compile';
return Template.compile(value, resource, entryId);
errorStage = 'resolve';
// TODO: this is possible in 'render' (html) mode only, skip it in 'compile' (js template) mode
return Template.resolve(value, resource, entryId);
})
.then((value) => {
errorStage = 'export';
Expand All @@ -101,8 +102,8 @@ const loader = function (content, map, meta) {
case 'preprocessor':
error = preprocessorError(error, issuer);
break;
case 'compile':
error = compileError(error, issuer);
case 'resolve':
error = resolveError(error, issuer);
break;
case 'export':
error = exportError(error, issuer);
Expand Down
Loading

0 comments on commit ce0fd65

Please sign in to comment.