Skip to content

Commit aa5a994

Browse files
Robert Sweeneyshellscape
Robert Sweeney
andauthored
fix(node-resolve): bump is-builtin-module version, imports with a trailing 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 <[email protected]>
1 parent 65aa1cd commit aa5a994

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

packages/node-resolve/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@rollup/pluginutils": "^5.0.1",
6565
"@types/resolve": "1.20.2",
6666
"deepmerge": "^4.2.2",
67-
"is-builtin-module": "^3.2.0",
67+
"is-builtin-module": "^3.2.1",
6868
"is-module": "^1.0.0",
6969
"resolve": "^1.22.1"
7070
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import message from 'events/'
2+
3+
export default message;

packages/node-resolve/test/prefer-builtins.js

+18
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ test('true allows preferring a builtin to a local module of the same name', asyn
6969
t.deepEqual(imports, ['events']);
7070
});
7171

72+
test('true prefers a local module to a builtin of the same name when imported with a trailing slash', async (t) => {
73+
const warnings = [];
74+
const bundle = await rollup({
75+
input: 'prefer-local.js',
76+
onwarn: (warning) => warnings.push(warning),
77+
plugins: [
78+
nodeResolve({
79+
preferBuiltins: true
80+
})
81+
]
82+
});
83+
84+
const imports = await getImports(bundle);
85+
86+
t.is(warnings.length, 0);
87+
t.deepEqual(imports, []);
88+
});
89+
7290
test('false allows resolving a local module with the same name as a builtin module', async (t) => {
7391
const warnings = [];
7492
const bundle = await rollup({

pnpm-lock.yaml

+12-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)