support node.js builtin modules in esm build dependencies
This commit is contained in:
parent
2c200d1656
commit
ab40959467
|
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue