@swc/plugin-swc-confidential 6.0.3 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
Binary file
|
package/Cargo.toml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
|
|
3
|
-
description = "SWC Plugin for swc-confidential"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
authors = { workspace = true }
|
|
7
|
-
edition = { workspace = true }
|
|
8
|
-
homepage = { workspace = true }
|
|
9
|
-
license = { workspace = true }
|
|
10
|
-
name = "swc_plugin_swc_confidential"
|
|
11
|
-
publish = false
|
|
12
|
-
repository = { workspace = true }
|
|
13
|
-
rust-version = { workspace = true }
|
|
14
|
-
version = "0.7.4"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[lib]
|
|
18
|
-
crate-type = ["cdylib", "rlib"]
|
|
19
|
-
|
|
20
|
-
[dependencies]
|
|
21
|
-
serde_json = { workspace = true }
|
|
22
|
-
swc_core = { workspace = true, features = ["ecma_plugin_transform"] }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
swc_confidential = { path = "./transform" }
|
package/__tests__/wasm.test.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { expect, test, describe } from "vitest";
|
|
2
|
-
import { transform } from "@swc/core";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import url from "node:url";
|
|
5
|
-
import fs from "node:fs/promises";
|
|
6
|
-
|
|
7
|
-
const pluginName = "swc_plugin_swc_confidential.wasm";
|
|
8
|
-
|
|
9
|
-
const transformCode = async (
|
|
10
|
-
code: string,
|
|
11
|
-
options = {
|
|
12
|
-
algorithm: "AES-256",
|
|
13
|
-
encryptionKey: "secret",
|
|
14
|
-
prefix: "secure:",
|
|
15
|
-
},
|
|
16
|
-
) => {
|
|
17
|
-
return transform(code, {
|
|
18
|
-
jsc: {
|
|
19
|
-
parser: {
|
|
20
|
-
syntax: "ecmascript",
|
|
21
|
-
},
|
|
22
|
-
target: "es2018",
|
|
23
|
-
experimental: {
|
|
24
|
-
plugins: [
|
|
25
|
-
[
|
|
26
|
-
path.join(
|
|
27
|
-
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
28
|
-
"..",
|
|
29
|
-
pluginName,
|
|
30
|
-
),
|
|
31
|
-
options,
|
|
32
|
-
],
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
filename: "test.js",
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
async function walkDir(
|
|
41
|
-
dir: URL,
|
|
42
|
-
callback: (
|
|
43
|
-
dir: string,
|
|
44
|
-
input: string,
|
|
45
|
-
config?: Record<string, unknown>,
|
|
46
|
-
) => Promise<void>,
|
|
47
|
-
) {
|
|
48
|
-
const dirs = await fs.readdir(dir);
|
|
49
|
-
const baseDir = url.fileURLToPath(dir);
|
|
50
|
-
|
|
51
|
-
for (const dir of dirs) {
|
|
52
|
-
const inputFilePath = path.join(baseDir, dir, "input.js");
|
|
53
|
-
const configPath = path.join(baseDir, dir, "config.json");
|
|
54
|
-
|
|
55
|
-
const config = await fs.readFile(configPath, "utf-8").then(
|
|
56
|
-
(json) => {
|
|
57
|
-
return JSON.parse(json);
|
|
58
|
-
},
|
|
59
|
-
(_) => undefined,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
const input = await fs.readFile(inputFilePath, "utf-8");
|
|
64
|
-
await callback(dir, input, config);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
console.log(e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
describe("Should load swc-confidential wasm plugin correctly", async () => {
|
|
72
|
-
await walkDir(
|
|
73
|
-
new URL("../transform/tests/fixture", import.meta.url),
|
|
74
|
-
async (dir, input, config) => {
|
|
75
|
-
await test(`Should transform ${dir} correctly`, async () => {
|
|
76
|
-
const { code } = await transformCode(input, config);
|
|
77
|
-
expect(code).toMatchSnapshot();
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
});
|