diff --git a/index.js b/index.js index 32f006e..6f5f8f0 100644 --- a/index.js +++ b/index.js @@ -163,6 +163,9 @@ precinct.paperwork = function(filename, options = {}) { if (!options.includeCore) { return deps.filter(function(d) { + if (d.startsWith('node:')) { + return false; + } return !natives[d]; }); } diff --git a/test/index.js b/test/index.js index 956f380..6699c07 100644 --- a/test/index.js +++ b/test/index.js @@ -338,6 +338,16 @@ describe('node-precinct', function() { }); }); + describe('that imports node-internal with node:-prefix', () => { + it('assumes that it exists', () => { + var deps = precinct.paperwork(path.join(__dirname, 'internalNodePrefix.js'), { + includeCore: false + }); + assert(!deps.includes('node:nonexistant')); + assert.deepEqual(deps, ['streams']); + }); + }); + describe('that uses dynamic imports', function() { it('grabs the dynamic import', function() { var es6 = precinct(read('es6DynamicImport.js')); diff --git a/test/internalNodePrefix.js b/test/internalNodePrefix.js new file mode 100644 index 0000000..1d804f1 --- /dev/null +++ b/test/internalNodePrefix.js @@ -0,0 +1,2 @@ +const someModule = require("node:nonexistant") +const anotherModule = require("streams")