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

[paperwork] take node: prefix as indicator for being a core module #88

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
});
}
Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 2 additions & 0 deletions test/internalNodePrefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const someModule = require("node:nonexistant")
const anotherModule = require("streams")