| 99 | const packageBase = getPackageBase(); |
| 100 | const localName = `./rollup.${packageBase}.node`; |
| 101 | const requireWithFriendlyError = id => { |
| 102 | try { |
| 103 | return require(id); |
| 104 | } catch (error) { |
| 105 | if ( |
| 106 | platform === 'win32' && |
| 107 | error instanceof Error && |
| 108 | error.code === 'ERR_DLOPEN_FAILED' && |
| 109 | error.message.includes('The specified module could not be found') |
| 110 | ) { |
| 111 | const msvcDownloadLink = `https://aka.ms/vs/17/release/${msvcLinkFilenameByArch[arch]}`; |
| 112 | throw new Error( |
| 113 | `Failed to load module ${id}. ` + |
| 114 | 'Required DLL was not found. ' + |
| 115 | 'This error usually happens when Microsoft Visual C++ Redistributable is not installed. ' + |
| 116 | `You can download it from ${msvcDownloadLink}`, |
| 117 | { cause: error } |
| 118 | ); |
| 119 | } |
| 120 | |
| 121 | throw new Error( |
| 122 | `Cannot find module ${id}. ` + |
| 123 | `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + |
| 124 | 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', |
| 125 | { cause: error } |
| 126 | ); |
| 127 | } |
| 128 | }; |
| 129 | |
| 130 | const { parse, parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } = requireWithFriendlyError( |
| 131 | existsSync(path.join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}` |