0
# @swc/core-darwin-arm64
1
2
@swc/core-darwin-arm64 is a platform-specific native binary package that provides the macOS ARM64 (Apple Silicon) native Node.js addon for SWC (Speedy Web Compiler). This package contains only the compiled native binary (`swc.darwin-arm64.node`) and does not provide any direct JavaScript API. It is automatically loaded by the main `@swc/core` package when running on compatible systems.
3
4
## Package Information
5
6
- **Package Name**: @swc/core-darwin-arm64
7
- **Package Type**: npm
8
- **Language**: Rust (native binary)
9
- **Installation**: Automatically installed as an optional dependency of `@swc/core`
10
- **Platform**: macOS (darwin), ARM64 (Apple Silicon)
11
- **Node.js**: Version 10 or higher
12
- **Binary File**: `swc.darwin-arm64.node`
13
14
## Core Imports
15
16
This package does not provide any direct JavaScript imports or API. The native binary is automatically loaded by the main `@swc/core` package:
17
18
```javascript
19
// @swc/core automatically loads the platform-specific binary
20
const swc = require("@swc/core");
21
```
22
23
For TypeScript:
24
25
```typescript
26
import * as swc from "@swc/core";
27
```
28
29
## Basic Usage
30
31
Since this is a platform-specific binary package with no API surface, you interact with SWC functionality through the main `@swc/core` package:
32
33
```typescript
34
import { transform } from "@swc/core";
35
36
// The darwin-arm64 binary is automatically used for the transformation
37
const result = await transform("const x: number = 1;", {
38
jsc: {
39
parser: {
40
syntax: "typescript",
41
},
42
target: "es2018",
43
},
44
module: {
45
type: "commonjs",
46
},
47
});
48
49
console.log(result.code); // Transformed JavaScript
50
```
51
52
## Architecture
53
54
@swc/core-darwin-arm64 is part of SWC's multi-platform distribution strategy:
55
56
- **Native Binary**: Contains only `swc.darwin-arm64.node`, a compiled Rust binary providing optimal performance
57
- **Platform Detection**: The main @swc/core package automatically detects the platform and loads the appropriate binary
58
- **Fallback Support**: If the native binary fails to load, @swc/core falls back to a WebAssembly version
59
- **NAPI Integration**: Uses Node.js N-API for stable binary interface across Node.js versions
60
- **Optional Dependency**: Installed as an optional dependency by @swc/core based on the target platform
61
62
## Capabilities
63
64
### Native Binary Provision
65
66
The sole capability of this package is to provide the underlying native implementation that powers all SWC transformation operations on macOS ARM64 systems.
67
68
```typescript { .api }
69
// This package provides no JavaScript API
70
// Binary file: swc.darwin-arm64.node
71
// Automatically loaded by @swc/core when available
72
```
73
74
The package contains only the native binary file and does not export any JavaScript functions or interfaces. All SWC functionality is accessed through the main `@swc/core` package, which dynamically loads this binary when running on compatible systems.
75
76
## Platform Requirements
77
78
- **Operating System**: macOS (darwin)
79
- **Architecture**: ARM64 (Apple Silicon: M1, M2, M3, M4 processors)
80
- **Node.js**: Version 10 or higher
81
- **Dependencies**: None (this package contains only the binary file)
82
83
## Installation Notes
84
85
This package is automatically installed as an optional dependency by @swc/core and should not be installed manually:
86
87
```bash
88
# Correct installation - this automatically installs the platform-specific binary
89
npm install @swc/core
90
```
91
92
Manual installation is unnecessary and not recommended:
93
94
```bash
95
# Not recommended - the binary is automatically managed
96
npm install @swc/core-darwin-arm64
97
```
98
99
## Troubleshooting
100
101
### Binary Loading Issues
102
103
If the native binary fails to load, @swc/core automatically falls back to the WebAssembly version (@swc/wasm) with reduced performance. Common issues include:
104
105
- **Architecture mismatch**: Using x64 Node.js on ARM64 system or vice versa
106
- **Node.js version**: Unsupported Node.js version (< 10)
107
- **Binary corruption**: Re-installing @swc/core typically resolves this
108
- **Missing native binary**: Package may not have been installed correctly
109
110
### Platform Detection
111
112
You can verify which binary is being used:
113
114
```typescript
115
import { getBinaryMetadata } from "@swc/core";
116
117
console.log(getBinaryMetadata());
118
// Expected output on ARM64 macOS: { target: "aarch64-apple-darwin" }
119
```
120
121
## Performance Characteristics
122
123
The native binary provides significant performance advantages over JavaScript alternatives when successfully loaded:
124
125
- **Parsing**: 20x faster than TypeScript compiler
126
- **Transformation**: 20x faster than Babel
127
- **Minification**: Comparable to Terser with better performance
128
- **Memory Usage**: Lower memory footprint due to Rust implementation
129
- **Multi-threading**: Utilizes multiple CPU cores for large codebases
130
131
## Related Packages
132
133
- **@swc/core**: Main package providing the JavaScript API
134
- **@swc/wasm**: WebAssembly fallback when native binary is unavailable
135
- **Other platform binaries**: @swc/core-darwin-x64, @swc/core-linux-x64-gnu, @swc/core-win32-x64-msvc, etc.