Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support node.js builtin modules in esm build dependencies #15611

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/FileSystemInfo.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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