| 1 | export default function handleDeprecatedOptions(opts) { |
| 2 | const warnings = []; |
| 3 | |
| 4 | if (opts.customResolveOptions) { |
| 5 | const { customResolveOptions } = opts; |
| 6 | if (customResolveOptions.moduleDirectory) { |
| 7 | // eslint-disable-next-line no-param-reassign |
| 8 | opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory) |
| 9 | ? customResolveOptions.moduleDirectory |
| 10 | : [customResolveOptions.moduleDirectory]; |
| 11 | |
| 12 | warnings.push( |
| 13 | 'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.' |
| 14 | ); |
| 15 | } |
| 16 | |
| 17 | if (customResolveOptions.preserveSymlinks) { |
| 18 | throw new Error( |
| 19 | 'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.' |
| 20 | ); |
| 21 | } |
| 22 | |
| 23 | [ |
| 24 | 'basedir', |
| 25 | 'package', |
| 26 | 'extensions', |
| 27 | 'includeCoreModules', |
| 28 | 'readFile', |
| 29 | 'isFile', |
| 30 | 'isDirectory', |
| 31 | 'realpath', |
| 32 | 'packageFilter', |
| 33 | 'pathFilter', |
| 34 | 'paths', |
| 35 | 'packageIterator' |
| 36 | ].forEach((resolveOption) => { |
| 37 | if (customResolveOptions[resolveOption]) { |
| 38 | throw new Error( |
| 39 | `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.` |
| 40 | ); |
| 41 | } |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | return { warnings }; |
| 46 | } |