|
2 | 2 | import * as path from 'path'; |
3 | 3 | import os from 'os'; |
4 | 4 |
|
5 | | -import resolve from '@rollup/plugin-node-resolve'; |
| 5 | +import nodeResolve from '@rollup/plugin-node-resolve'; |
6 | 6 |
|
7 | 7 | import test from 'ava'; |
8 | 8 | import { getLocator } from 'locate-character'; |
@@ -91,7 +91,7 @@ test('supports an object of multiple entry points', async (t) => { |
91 | 91 | b: require.resolve('./fixtures/samples/multiple-entry-points/b.js'), |
92 | 92 | c: require.resolve('./fixtures/samples/multiple-entry-points/c.js') |
93 | 93 | }, |
94 | | - plugins: [resolve(), commonjs()] |
| 94 | + plugins: [nodeResolve(), commonjs()] |
95 | 95 | }); |
96 | 96 |
|
97 | 97 | const { output } = await bundle.generate({ |
@@ -212,7 +212,7 @@ test.serial('handles symlinked node_modules with preserveSymlinks: false', (t) = |
212 | 212 | throw new Error(`Unexpected warning: ${warning.message}`); |
213 | 213 | }, |
214 | 214 | plugins: [ |
215 | | - resolve({ |
| 215 | + nodeResolve({ |
216 | 216 | preserveSymlinks: false, |
217 | 217 | preferBuiltins: false |
218 | 218 | }), |
@@ -400,7 +400,7 @@ test('rewrites top-level defines', async (t) => { |
400 | 400 | test('respects options.external', async (t) => { |
401 | 401 | const bundle = await rollup({ |
402 | 402 | input: 'fixtures/samples/external/main.js', |
403 | | - plugins: [resolve(), commonjs()], |
| 403 | + plugins: [nodeResolve(), commonjs()], |
404 | 404 | external: ['baz'] |
405 | 405 | }); |
406 | 406 |
|
@@ -731,3 +731,35 @@ test('does not transform typeof exports for mixed modules', async (t) => { |
731 | 731 | t.is(code.includes('typeof exports'), true, '"typeof exports" not found in the code'); |
732 | 732 | t.snapshot(code); |
733 | 733 | }); |
| 734 | + |
| 735 | +test('throws when using an old node_resolve version', async (t) => { |
| 736 | + let error = null; |
| 737 | + try { |
| 738 | + await rollup({ |
| 739 | + input: 'ignored', |
| 740 | + plugins: [commonjs(), { name: nodeResolve().name }] |
| 741 | + }); |
| 742 | + } catch (err) { |
| 743 | + error = err; |
| 744 | + } |
| 745 | + t.like(error, { |
| 746 | + message: |
| 747 | + 'Insufficient @rollup/plugin-node-resolve version: "@rollup/plugin-commonjs" requires at least @rollup/[email protected].' |
| 748 | + }); |
| 749 | +}); |
| 750 | + |
| 751 | +test('throws when using an inadequate node_resolve version', async (t) => { |
| 752 | + let error = null; |
| 753 | + try { |
| 754 | + await rollup({ |
| 755 | + input: 'ignored', |
| 756 | + plugins: [commonjs(), { name: nodeResolve().name, version: '13.0.5' }] |
| 757 | + }); |
| 758 | + } catch (err) { |
| 759 | + error = err; |
| 760 | + } |
| 761 | + t.like(error, { |
| 762 | + message: |
| 763 | + 'Insufficient @rollup/plugin-node-resolve version: "@rollup/plugin-commonjs" requires at least @rollup/[email protected] but found @rollup/[email protected].' |
| 764 | + }); |
| 765 | +}); |
0 commit comments