From ab3f45d07f4501f7d97f34865cf6f1938783522d Mon Sep 17 00:00:00 2001 From: Kieran Date: Sun, 8 Oct 2023 20:15:15 +0100 Subject: [PATCH] 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 --- packages/node-resolve/src/index.js | 1 + .../node-resolve/test/snapshots/test.mjs.md | 21 ++++++++++++++++++ .../node-resolve/test/snapshots/test.mjs.snap | Bin 823 -> 1077 bytes packages/node-resolve/test/test.mjs | 6 ++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/node-resolve/src/index.js b/packages/node-resolve/src/index.js index 09ce84cd8..3d389383d 100644 --- a/packages/node-resolve/src/index.js +++ b/packages/node-resolve/src/index.js @@ -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 diff --git a/packages/node-resolve/test/snapshots/test.mjs.md b/packages/node-resolve/test/snapshots/test.mjs.md index 7eccb2357..ab64d89de 100644 --- a/packages/node-resolve/test/snapshots/test.mjs.md +++ b/packages/node-resolve/test/snapshots/test.mjs.md @@ -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 diff --git a/packages/node-resolve/test/snapshots/test.mjs.snap b/packages/node-resolve/test/snapshots/test.mjs.snap index 84c150452384f0b6ee8303f0be5c734a9d30e0a6..e8af19cf355b7af30cfc13e11c3659c7c76ce39b 100644 GIT binary patch literal 1077 zcmV-51j_qCRzVd<-{l_4#^@RB&5=+G|h*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ltie9SyNW@ zArsaNxwkAs;T&~=O7%`t$_g}<^q>;@$x(Ch9o1c3NmOi7AtDuas14eB(g_7y;fmQt zD$X=?xN$+S7PY&5qpjXy8-d}{*VW@L-66HFh&PaXiIiq>zKi1qnVcaLi%QWhA<3#- zE?eZXMTkYN5Hg=Qjkj@rgX05^CDM1E+-U6Louo8aPESu;c!F+;{} z>9FMC`sUN^wc7gYoyD#7+WOiF(O7C`H?_3|?19;&wsAu6&2N`dGOEokY z^TA;O?oq>>Dr{>!W(anD7CJ7sUGVS%bOP!Fjkr`#sGJN$*y4Wjc=f2pB(kf=@~eqM zF;8L=oE}EhrkUDf&%2)Bep~nD4=3O6K{RiX(tVs4;%H(NCRU@XdV!6XabV+B5*d;c z_vxrlYOVK51}n&KF%?nkiLb&A!|yvlMTd4Zgh<_B0F@LX44^)IPTwzKIG>MUgK8{S zm5T05f#`_HLawhc9ayaiT^WMU@HZNl>sbf{Lnk!A6h=d?b;!;ND4=#5C0}4beT5?f z^e7)7wr`lPqh%_iZ$&baSr{FP92usye3-azi_l@qQn6?8OEewVuOe}EvfvsPJ2Gqw z`LHQQohMwR*WcG7VR>0#B@#!5=wZ&x(tic?xky0mOxdJIisx}&Jc9-&mC^Si83oxG z9cjbPt<*$7v30)Cr4~yZ8KR{#H3OK=hNbsRKZ@j}aX( z(}Vn&(tCkVMH1T0N@#R{|0`!IxEjWX;=3^w)6XI?nH(jTDE)6>e*oHta4LNf002y% Bh4}yg diff --git a/packages/node-resolve/test/test.mjs b/packages/node-resolve/test/test.mjs index 9318d4ea4..64cabc347 100755 --- a/packages/node-resolve/test/test.mjs +++ b/packages/node-resolve/test/test.mjs @@ -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'; @@ -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',