Skip to content

Commit 51ce159

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update amaro to 1.3.0
PR-URL: #66144 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent ffac553 commit 51ce159

20 files changed

Lines changed: 1731 additions & 646 deletions

‎deps/amaro/README.md‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
# Amaro
22

3-
Amaro is a wrapper around `@swc/wasm-typescript`, a WebAssembly port of the SWC TypeScript parser.
3+
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.
44
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.
55

66
> 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.
77
88
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.
99

10+
## Building from source
11+
12+
The WebAssembly module is not checked in. Building it requires Docker, which
13+
runs the Rust build inside the [Node.js wasm-builder](https://github.com/nodejs/wasm-builder)
14+
container:
15+
16+
```bash
17+
npm run build:wasm
18+
npm run build
19+
npm test
20+
```
21+
22+
Releases build the module in CI before publishing.
23+
1024
## How to Install
1125

1226
To install Amaro, run:
@@ -47,15 +61,13 @@ node --enable-source-maps --import="amaro/transform" file.ts
4761
> Note that the `amaro/transform` loader should be used with `--enable-source-maps`
4862
> to preserve accurate source-mapped stack traces.
4963
50-
#### Programmatic registration with `module.register()`
64+
#### Programmatic registration with `module.registerHooks()`
5165

52-
If you want TypeScript to "just work" in an existing codebase without passing `--import` every time, create a small bootstrap file and register Amaro once before loading your TS entrypoint.
66+
Amaro's `strip` and `transform` entry points use `module.registerHooks()` to register synchronous hooks on Node.js versions that provide it, and fall back to `module.register()` on older versions. If you want TypeScript to "just work" in an existing codebase without passing `--import` every time, create a small bootstrap file that imports Amaro before loading your TS entrypoint.
5367

5468
```mjs
5569
// bootstrap.mjs
56-
import { register } from "node:module";
57-
58-
register("amaro/strip", import.meta.url);
70+
import "amaro/strip";
5971
await import("./src/index.ts");
6072
```
6173

‎deps/amaro/dist/LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ Unless required by applicable law or agreed to in writing, software
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

‎deps/amaro/dist/errors.js‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
"use strict";
2-
export function isSwcError(error) {
2+
var __defProp = Object.defineProperty;
3+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4+
var __getOwnPropNames = Object.getOwnPropertyNames;
5+
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
var __export = (target, all) => {
7+
for (var name in all)
8+
__defProp(target, name, { get: all[name], enumerable: true });
9+
};
10+
var __copyProps = (to, from, except, desc) => {
11+
if (from && typeof from === "object" || typeof from === "function") {
12+
for (let key of __getOwnPropNames(from))
13+
if (!__hasOwnProp.call(to, key) && key !== except)
14+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15+
}
16+
return to;
17+
};
18+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19+
var errors_exports = {};
20+
__export(errors_exports, {
21+
isSwcError: () => isSwcError,
22+
wrapAndReThrowSwcError: () => wrapAndReThrowSwcError
23+
});
24+
module.exports = __toCommonJS(errors_exports);
25+
function isSwcError(error) {
326
return error.code !== void 0;
427
}
5-
export function wrapAndReThrowSwcError(error) {
28+
function wrapAndReThrowSwcError(error) {
629
const errorHints = `${error.filename}:${error.startLine}
730
${error.snippet}
831
`;
@@ -22,3 +45,8 @@ ${error.snippet}
2245
throw new Error(error.message);
2346
}
2447
}
48+
// Annotate the CommonJS export names for ESM import in node:
49+
0 && (module.exports = {
50+
isSwcError,
51+
wrapAndReThrowSwcError
52+
});

‎deps/amaro/dist/index.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { transformSync } from "./transform.ts";
1+
export { transformSync } from "./internal.js";

0 commit comments

Comments
 (0)