Skip to content

Commit

Permalink
Merge pull request #15611 from webpack/bugfix/esm-build-deps
Browse files Browse the repository at this point in the history
support node.js builtin modules in esm build dependencies
  • Loading branch information
sokra committed Apr 1, 2022
2 parents 2c200d1 + ab40959 commit c4f1e4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/FileSystemInfo.js
Expand Up @@ -6,6 +6,7 @@
"use strict";

const { create: createResolver } = require("enhanced-resolve");
const nodeModule = require("module");
const asyncLib = require("neo-async");
const AsyncQueue = require("./util/AsyncQueue");
const StackedCacheMap = require("./util/StackedCacheMap");
Expand All @@ -22,6 +23,8 @@ const processAsyncTree = require("./util/processAsyncTree");

const supportsEsm = +process.versions.modules >= 83;

const builtinModules = new Set(nodeModule.builtinModules);

let FS_ACCURACY = 2000;

const EMPTY_SET = new Set();
Expand Down Expand Up @@ -1676,6 +1679,7 @@ class FileSystemInfo {

// we should not track Node.js build dependencies
if (dependency.startsWith("node:")) continue;
if (builtinModules.has(dependency)) continue;

push({
type: RBDT_RESOLVE_ESM_FILE,
Expand Down
2 changes: 1 addition & 1 deletion test/BuildDependencies.longtest.js
Expand Up @@ -133,7 +133,7 @@ describe("BuildDependencies", () => {
);
fs.writeFileSync(
path.resolve(inputDirectory, "esm-async-dependency.mjs"),
'import path from "node:path"; export default 0;'
'import path from "node:path"; import vm from "vm"; export default 0;'
);
await exec("0", {
invalidBuildDependencies: true,
Expand Down

0 comments on commit c4f1e4e

Please sign in to comment.