Skip to content

Commit

Permalink
fix(node-resolve): bump is-builtin-module version, imports with a tra…
Browse files Browse the repository at this point in the history
…iling slash (#1424)

* Bump the version of is-builtin-module to include the fix for imports with a trailing slash

* Add tests for bypassing builtin modules with a trailing slash

---------

Co-authored-by: Andrew Powell <shellscape@users.noreply.github.com>
  • Loading branch information
Robert Sweeney and shellscape committed Apr 4, 2023
1 parent 65aa1cd commit aa5a994
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/node-resolve/package.json
Expand Up @@ -64,7 +64,7 @@
"@rollup/pluginutils": "^5.0.1",
"@types/resolve": "1.20.2",
"deepmerge": "^4.2.2",
"is-builtin-module": "^3.2.0",
"is-builtin-module": "^3.2.1",
"is-module": "^1.0.0",
"resolve": "^1.22.1"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/node-resolve/test/fixtures/prefer-local.js
@@ -0,0 +1,3 @@
import message from 'events/'

export default message;
18 changes: 18 additions & 0 deletions packages/node-resolve/test/prefer-builtins.js
Expand Up @@ -69,6 +69,24 @@ test('true allows preferring a builtin to a local module of the same name', asyn
t.deepEqual(imports, ['events']);
});

test('true prefers a local module to a builtin of the same name when imported with a trailing slash', async (t) => {
const warnings = [];
const bundle = await rollup({
input: 'prefer-local.js',
onwarn: (warning) => warnings.push(warning),
plugins: [
nodeResolve({
preferBuiltins: true
})
]
});

const imports = await getImports(bundle);

t.is(warnings.length, 0);
t.deepEqual(imports, []);
});

test('false allows resolving a local module with the same name as a builtin module', async (t) => {
const warnings = [];
const bundle = await rollup({
Expand Down
15 changes: 12 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aa5a994

Please sign in to comment.