From 99c08d99a54d2af9314e1ff4036746a96ae061ef Mon Sep 17 00:00:00 2001 From: "Anders D. Johnson" Date: Fri, 15 Jul 2022 21:59:46 -0500 Subject: [PATCH] feat: identifiers --- index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7f1221d..fd55c5b 100644 --- a/index.js +++ b/index.js @@ -162,19 +162,22 @@ precinct.paperwork = (filename, options = {}) => { if (!options.includeCore) { return deps.filter((dep) => { - if (dep.startsWith('node:')) { + // If `identifiers: true` was passed, we'll get results objects with `path`, otherwise strings. + const depPath = dep.path || dep; + + if (depPath.startsWith('node:')) { return false } // In nodejs 18, node:test is a builtin but shows up under natives["test"], but // can only be imported by "node:test." We're correcting this so "test" isn't // unnecessarily stripped from the imports - if ("test" == dep) { + if ("test" == depPath) { debug('paperwork: allowing test import to avoid builtin/natives consideration\n'); return true } - const isInNatives = Boolean(natives[dep]); + const isInNatives = Boolean(natives[depPath]); return !isInNatives; }); }