Skip to content

Commit

Permalink
fix(node-resolve): modulePaths default is not set (#1534)
Browse files Browse the repository at this point in the history
* fix(node-resolve): modulePaths default is not set

* test: add a test for defaults

---------

Co-authored-by: shellscape <[email protected]>
  • Loading branch information
bytestream and shellscape authored Oct 8, 2023
1 parent cdf9113 commit ab3f45d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const defaults = {
extensions: ['.mjs', '.js', '.json', '.node'],
resolveOnly: [],
moduleDirectories: ['node_modules'],
modulePaths: [],
ignoreSideEffectsForRoot: false,
// TODO: set to false in next major release or remove
allowExportsFolderMapping: true
Expand Down
21 changes: 21 additions & 0 deletions packages/node-resolve/test/snapshots/test.mjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ The actual snapshot is saved in `test.mjs.snap`.

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

## has default config

> Snapshot 1
{
allowExportsFolderMapping: true,
dedupe: [],
extensions: [
'.mjs',
'.js',
'.json',
'.node',
],
ignoreSideEffectsForRoot: false,
moduleDirectories: [
'node_modules',
],
modulePaths: [],
resolveOnly: [],
}

## throws error if local id is not resolved

> Snapshot 1
Expand Down
Binary file modified packages/node-resolve/test/snapshots/test.mjs.snap
Binary file not shown.
6 changes: 5 additions & 1 deletion packages/node-resolve/test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import commonjs from '@rollup/plugin-commonjs';
import test from 'ava';
import { rollup } from 'rollup';

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

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

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

test('has default config', (t) => {
t.snapshot(DEFAULTS);
});

test('finds a module with jsnext:main', async (t) => {
const bundle = await rollup({
input: 'jsnext.js',
Expand Down

0 comments on commit ab3f45d

Please sign in to comment.