mirror of https://github.com/nodejs/node.git
deps: update amaro to 0.3.0
PR-URL: https://github.com/nodejs/node/pull/56568 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>pull/56613/head
parent
e52440bc3b
commit
d1a3f30642
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
export function isSwcError(error) {
|
||||
return error.code !== void 0;
|
||||
}
|
||||
export function wrapAndReThrowSwcError(error) {
|
||||
switch (error.code) {
|
||||
case "UnsupportedSyntax": {
|
||||
const unsupportedSyntaxError = new Error(error.message);
|
||||
unsupportedSyntaxError.name = "UnsupportedSyntaxError";
|
||||
throw unsupportedSyntaxError;
|
||||
}
|
||||
case "InvalidSyntax":
|
||||
throw new SyntaxError(error.message);
|
||||
default:
|
||||
throw new Error(error.message);
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
"강동윤 <kdy1997.dev@gmail.com>"
|
||||
],
|
||||
"description": "wasm module for swc",
|
||||
"version": "1.10.4",
|
||||
"version": "1.10.7",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,24 +1,32 @@
|
|||
"use strict";
|
||||
import { isSwcError, wrapAndReThrowSwcError } from "./errors.js";
|
||||
import { transformSync } from "./index.js";
|
||||
export async function load(url, context, nextLoad) {
|
||||
const { format } = context;
|
||||
if (format.endsWith("-typescript")) {
|
||||
const { source } = await nextLoad(url, {
|
||||
...context,
|
||||
format: "module"
|
||||
});
|
||||
const { code } = transformSync(source.toString(), {
|
||||
mode: "strip-only"
|
||||
});
|
||||
return {
|
||||
format: format.replace("-typescript", ""),
|
||||
// Source map is not necessary in strip-only mode. However, to map the source
|
||||
// file in debuggers to the original TypeScript source, add a sourceURL magic
|
||||
// comment to hint that it is a generated source.
|
||||
source: `${code}
|
||||
try {
|
||||
const { source } = await nextLoad(url, {
|
||||
...context,
|
||||
format: "module"
|
||||
});
|
||||
const { code } = transformSync(source.toString(), {
|
||||
mode: "strip-only"
|
||||
});
|
||||
return {
|
||||
format: format.replace("-typescript", ""),
|
||||
// Source map is not necessary in strip-only mode. However, to map the source
|
||||
// file in debuggers to the original TypeScript source, add a sourceURL magic
|
||||
// comment to hint that it is a generated source.
|
||||
source: `${code}
|
||||
|
||||
//# sourceURL=${url}`
|
||||
};
|
||||
};
|
||||
} catch (error) {
|
||||
if (isSwcError(error)) {
|
||||
wrapAndReThrowSwcError(error);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
|
|
|
@ -1,30 +1,38 @@
|
|||
"use strict";
|
||||
import { isSwcError, wrapAndReThrowSwcError } from "./errors.js";
|
||||
import { transformSync } from "./index.js";
|
||||
export async function load(url, context, nextLoad) {
|
||||
const { format } = context;
|
||||
if (format.endsWith("-typescript")) {
|
||||
const { source } = await nextLoad(url, {
|
||||
...context,
|
||||
format: "module"
|
||||
});
|
||||
const { code, map } = transformSync(source.toString(), {
|
||||
mode: "transform",
|
||||
sourceMap: true,
|
||||
filename: url
|
||||
});
|
||||
let output = code;
|
||||
if (map) {
|
||||
const base64SourceMap = Buffer.from(map).toString("base64");
|
||||
output = `${code}
|
||||
try {
|
||||
const { source } = await nextLoad(url, {
|
||||
...context,
|
||||
format: "module"
|
||||
});
|
||||
const { code, map } = transformSync(source.toString(), {
|
||||
mode: "transform",
|
||||
sourceMap: true,
|
||||
filename: url
|
||||
});
|
||||
let output = code;
|
||||
if (map) {
|
||||
const base64SourceMap = Buffer.from(map).toString("base64");
|
||||
output = `${code}
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`;
|
||||
}
|
||||
return {
|
||||
format: format.replace("-typescript", ""),
|
||||
source: `${output}
|
||||
}
|
||||
return {
|
||||
format: format.replace("-typescript", ""),
|
||||
source: `${output}
|
||||
|
||||
//# sourceURL=${url}`
|
||||
};
|
||||
};
|
||||
} catch (error) {
|
||||
if (isSwcError(error)) {
|
||||
wrapAndReThrowSwcError(error);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "amaro",
|
||||
"version": "0.2.2",
|
||||
"version": "0.3.0",
|
||||
"description": "Node.js TypeScript wrapper",
|
||||
"license": "MIT",
|
||||
"type": "commonjs",
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// Refer to tools/dep_updaters/update-amaro.sh
|
||||
#ifndef SRC_AMARO_VERSION_H_
|
||||
#define SRC_AMARO_VERSION_H_
|
||||
#define AMARO_VERSION "0.2.2"
|
||||
#define AMARO_VERSION "0.3.0"
|
||||
#endif // SRC_AMARO_VERSION_H_
|
||||
|
|
Loading…
Reference in New Issue