Skip to content

Commit ab3f45d

Browse files
fix(node-resolve): modulePaths default is not set (#1534)
* fix(node-resolve): modulePaths default is not set * test: add a test for defaults --------- Co-authored-by: shellscape <andrew@shellscape.org>
1 parent cdf9113 commit ab3f45d

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

packages/node-resolve/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const defaults = {
3737
extensions: ['.mjs', '.js', '.json', '.node'],
3838
resolveOnly: [],
3939
moduleDirectories: ['node_modules'],
40+
modulePaths: [],
4041
ignoreSideEffectsForRoot: false,
4142
// TODO: set to false in next major release or remove
4243
allowExportsFolderMapping: true

packages/node-resolve/test/snapshots/test.mjs.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ The actual snapshot is saved in `test.mjs.snap`.
44

55
Generated by [AVA](https://avajs.dev).
66

7+
## has default config
8+
9+
> Snapshot 1
10+
11+
{
12+
allowExportsFolderMapping: true,
13+
dedupe: [],
14+
extensions: [
15+
'.mjs',
16+
'.js',
17+
'.json',
18+
'.node',
19+
],
20+
ignoreSideEffectsForRoot: false,
21+
moduleDirectories: [
22+
'node_modules',
23+
],
24+
modulePaths: [],
25+
resolveOnly: [],
26+
}
27+
728
## throws error if local id is not resolved
829

930
> Snapshot 1
254 Bytes
Binary file not shown.

packages/node-resolve/test/test.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import commonjs from '@rollup/plugin-commonjs';
66
import test from 'ava';
77
import { rollup } from 'rollup';
88

9-
import { nodeResolve } from 'current-package';
9+
import { nodeResolve, DEFAULTS } from 'current-package';
1010

1111
import { evaluateBundle, getCode, getImports, testBundle } from '../../../util/test.js';
1212

@@ -23,6 +23,10 @@ test('exposes plugin version', (t) => {
2323
t.regex(plugin.version, /^\d+\.\d+\.\d+/);
2424
});
2525

26+
test('has default config', (t) => {
27+
t.snapshot(DEFAULTS);
28+
});
29+
2630
test('finds a module with jsnext:main', async (t) => {
2731
const bundle = await rollup({
2832
input: 'jsnext.js',

0 commit comments

Comments
 (0)