source: imaps-frontend/node_modules/rollup/dist/native.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 3.5 KB
Line 
1const { existsSync } = require('node:fs');
2const path = require('node:path');
3const { platform, arch, report } = require('node:process');
4
5const isMusl = () => !report.getReport().header.glibcVersionRuntime;
6
7const bindingsByPlatformAndArch = {
8 android: {
9 arm: { base: 'android-arm-eabi' },
10 arm64: { base: 'android-arm64' }
11 },
12 darwin: {
13 arm64: { base: 'darwin-arm64' },
14 x64: { base: 'darwin-x64' }
15 },
16 freebsd: {
17 arm64: { base: 'freebsd-arm64' },
18 x64: { base: 'freebsd-x64' }
19 },
20 linux: {
21 arm: { base: 'linux-arm-gnueabihf', musl: 'linux-arm-musleabihf' },
22 arm64: { base: 'linux-arm64-gnu', musl: 'linux-arm64-musl' },
23 loong64: { base: 'linux-loongarch64-gnu', musl: null },
24 ppc64: { base: 'linux-powerpc64le-gnu', musl: null },
25 riscv64: { base: 'linux-riscv64-gnu', musl: null },
26 s390x: { base: 'linux-s390x-gnu', musl: null },
27 x64: { base: 'linux-x64-gnu', musl: 'linux-x64-musl' }
28 },
29 win32: {
30 arm64: { base: 'win32-arm64-msvc' },
31 ia32: { base: 'win32-ia32-msvc' },
32 x64: { base: 'win32-x64-msvc' }
33 }
34};
35
36const msvcLinkFilenameByArch = {
37 arm64: 'vc_redist.arm64.exe',
38 ia32: 'vc_redist.x86.exe',
39 x64: 'vc_redist.x64.exe'
40};
41
42const packageBase = getPackageBase();
43const localName = `./rollup.${packageBase}.node`;
44const requireWithFriendlyError = id => {
45 try {
46 return require(id);
47 } catch (error) {
48 if (
49 platform === 'win32' &&
50 error instanceof Error &&
51 error.code === 'ERR_DLOPEN_FAILED' &&
52 error.message.includes('The specified module could not be found')
53 ) {
54 const msvcDownloadLink = `https://aka.ms/vs/17/release/${msvcLinkFilenameByArch[arch]}`;
55 throw new Error(
56 `Failed to load module ${id}. ` +
57 'Required DLL was not found. ' +
58 'This error usually happens when Microsoft Visual C++ Redistributable is not installed. ' +
59 `You can download it from ${msvcDownloadLink}`,
60 { cause: error }
61 );
62 }
63
64 throw new Error(
65 `Cannot find module ${id}. ` +
66 `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
67 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
68 { cause: error }
69 );
70 }
71};
72
73const { parse, parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } = requireWithFriendlyError(
74 existsSync(path.join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}`
75);
76
77function getPackageBase() {
78 const imported = bindingsByPlatformAndArch[platform]?.[arch];
79 if (!imported) {
80 throwUnsupportedError(false);
81 }
82 if ('musl' in imported && isMusl()) {
83 return imported.musl || throwUnsupportedError(true);
84 }
85 return imported.base;
86}
87
88function throwUnsupportedError(isMusl) {
89 throw new Error(
90 `Your current platform "${platform}${isMusl ? ' (musl)' : ''}" and architecture "${arch}" combination is not yet supported by the native Rollup build. Please use the WASM build "@rollup/wasm-node" instead.
91
92The following platform-architecture combinations are supported:
93${Object.entries(bindingsByPlatformAndArch)
94 .flatMap(([platformName, architectures]) =>
95 Object.entries(architectures).flatMap(([architectureName, { musl }]) => {
96 const name = `${platformName}-${architectureName}`;
97 return musl ? [name, `${name} (musl)`] : [name];
98 })
99 )
100 .join('\n')}
101
102If this is important to you, please consider supporting Rollup to make a native build for your platform and architecture available.`
103 );
104}
105
106module.exports.parse = parse;
107module.exports.parseAsync = parseAsync;
108module.exports.xxhashBase64Url = xxhashBase64Url;
109module.exports.xxhashBase36 = xxhashBase36;
110module.exports.xxhashBase16 = xxhashBase16;
Note: See TracBrowser for help on using the repository browser.