Skip to content

Commit

Permalink
Do not error on external Node builtins in libraries (#7348)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Nov 23, 2021
1 parent 9f0d52d commit 4fbc352
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/utils/node-resolver-core/src/NodeResolver.js
Expand Up @@ -255,7 +255,7 @@ export default class NodeResolver {
}

if (!this.shouldIncludeNodeModule(env, filename)) {
if (sourcePath && env.isLibrary) {
if (sourcePath && env.isLibrary && !builtin) {
await this.checkExcludedDependency(sourcePath, filename, ctx);
}
return null;
Expand Down
19 changes: 19 additions & 0 deletions packages/utils/node-resolver-core/test/resolver.js
Expand Up @@ -2380,6 +2380,25 @@ describe('resolver', function () {

assert.deepEqual(result, {isExcluded: true});
});

it('should not error on builtin node modules', async function () {
let result = await resolver.resolve({
env: new Environment(
createEnvironment({
context: 'browser',
isLibrary: true,
includeNodeModules: false,
}),
DEFAULT_OPTIONS,
),
filename: 'buffer',
specifierType: 'esm',
parent: path.join(rootDir, 'env-dep/foo.js'),
sourcePath: path.join(rootDir, 'env-dep/foo.js'),
});

assert.deepEqual(result, {isExcluded: true});
});
});

describe('urls', function () {
Expand Down

0 comments on commit 4fbc352

Please sign in to comment.