Skip to content

Commit d283184

Browse files
committed
fix: skip builtin node and npm modules in esm resolve hook
1 parent aff9eba commit d283184

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-bundler-webpack-plugin",
3-
"version": "4.20.0-beta.5",
3+
"version": "4.20.0-beta.6",
44
"description": "Generates complete single-page or multi-page website from source assets. Build-in support for Markdown, Eta, EJS, Handlebars, Nunjucks, Pug. Alternative to html-webpack-plugin.",
55
"keywords": [
66
"html",

src/Common/FileSystem/Module/nocacheLoader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ async function resolve(specifier, context, nextResolve) {
1919
const parentUrl = new URL(context.parentURL);
2020
const flag = 'nocache';
2121

22+
// skip builtin node and npm modules in resolve hook
23+
if (resolved.format === 'builtin' || resolvedUrl.protocol === 'node:' || resolved.url.includes('/node_modules/')) {
24+
return resolved;
25+
}
26+
2227
if (!resolvedUrl.searchParams.get(flag) && parentUrl.searchParams.get(flag)) {
2328
resolvedUrl.searchParams.set(flag, Date.now().toString());
2429

test/manual/watch-data-file-in-template-esm/src/data/data.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { URL } from 'node:url'; // node
2+
import assert from 'assert'; // node
3+
import ansis from 'ansis'; // npm
14
import company from './company.js';
25

36
class Company {
@@ -27,6 +30,9 @@ const data = {
2730
date: new Date(),
2831
},
2932
test: {
33+
ansi: ansis.red`hello`,
34+
assert: assert('hello', 'hello!'),
35+
host: new URL('https://example.com'),
3036
ArrayBuffer: new ArrayBuffer(8),
3137
Uint8Array: new Uint8Array([10, 20, 30]),
3238
Float64Array: new Float64Array([1.1, 2.2]),

0 commit comments

Comments
 (0)