Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion deps/amaro/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Amaro

Amaro is a wrapper around `@swc/wasm-typescript`, a WebAssembly port of the SWC TypeScript parser.
Amaro is a Node.js wrapper around the [SWC](https://swc.rs) TypeScript parser and type stripper. Its Rust core in `crates/amaro` depends on the published SWC crates and is compiled to WebAssembly.
It's used as an internal in Node.js for [Type Stripping](https://nodejs.org/api/typescript.html#type-stripping) but can also be used as a standalone package.

> Amaro means "bitter" in Italian. It's a reference to [Mount Amaro](https://en.wikipedia.org/wiki/Monte_Amaro_(Abruzzo)) on whose slopes this package was conceived.

This package provides a stable API for the TypeScript parser and allows users to upgrade to the latest version of TypeScript transpiler independently from the one used internally in Node.js.

## Building from source

The WebAssembly module is not checked in. Building it requires Docker, which
runs the Rust build inside the [Node.js wasm-builder](https://github.com/nodejs/wasm-builder)
container:

```bash
npm run build:wasm
npm run build
npm test
```

Releases build the module in CI before publishing.

## How to Install

To install Amaro, run:
Expand Down
2 changes: 1 addition & 1 deletion deps/amaro/dist/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
32 changes: 30 additions & 2 deletions deps/amaro/dist/errors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
"use strict";
export function isSwcError(error) {
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var errors_exports = {};
__export(errors_exports, {
isSwcError: () => isSwcError,
wrapAndReThrowSwcError: () => wrapAndReThrowSwcError
});
module.exports = __toCommonJS(errors_exports);
function isSwcError(error) {
return error.code !== void 0;
}
export function wrapAndReThrowSwcError(error) {
function wrapAndReThrowSwcError(error) {
const errorHints = `${error.filename}:${error.startLine}
${error.snippet}
`;
Expand All @@ -22,3 +45,8 @@ ${error.snippet}
throw new Error(error.message);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
isSwcError,
wrapAndReThrowSwcError
});
2 changes: 1 addition & 1 deletion deps/amaro/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { transformSync } from "./transform.ts";
export { transformSync } from "./internal.js";
Loading
Loading