Skip to content

Commit

Permalink
Add unit tests distinguishing modulePaths from moduleDirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hyndman committed Feb 10, 2022
1 parent 82069ce commit 9d6a580
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PACKAGE, {dependency} from 'package-with-dependency';

export { PACKAGE, dependency };

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

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

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

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

30 changes: 30 additions & 0 deletions packages/node-resolve/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,36 @@ test('allows custom moduleDirectories with legacy customResolveOptions.moduleDir
t.snapshot(warnings);
});

test('custom moduleDirectories do not support nested dependencies', async (t) => {
const warnings = [];
const bundle = await rollup({
input: 'custom-module-path/main.js',
onwarn: (warning) => warnings.push(warning),
plugins: [
nodeResolve({
moduleDirectories: [join(process.cwd(), 'custom-module-path/node_modules')]
})
]
});

t.is(warnings.length, 1);
t.is(bundle.cache.modules.length, 2);
});

test('allows custom modulePaths', async (t) => {
const bundle = await rollup({
input: 'custom-module-path/main.js',
onwarn: failOnWarn(t),
plugins: [
nodeResolve({
modulePaths: [join(process.cwd(), 'custom-module-path/node_modules')]
})
]
});

t.is(bundle.cache.modules.length, 3);
});

test('ignores deep-import non-modules', async (t) => {
const warnings = [];
const bundle = await rollup({
Expand Down

0 comments on commit 9d6a580

Please sign in to comment.