@swc/plugin-swc-confidential 5.3.2 → 6.0.1

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
@@ -1,5 +1,17 @@
1
1
  # @swc/plugin-swc-confidential
2
2
 
3
+ ## 6.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 31e3254: build: Update `swc_core` to `v19.0.0`
8
+
9
+ ## 6.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - f0fee1d: Update swc_core to v15.0.1
14
+
3
15
  ## 5.3.2
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Should load swc-confidential wasm plugin correctly > Should transform simple correctly 1`] = `
4
+ "console.log("secure:de454774988d624b8f317bbe9dadfe1f");
5
+ "
6
+ `;
@@ -0,0 +1,81 @@
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
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/plugin-swc-confidential",
3
- "version": "5.3.2",
3
+ "version": "6.0.1",
4
4
  "description": "SWC plugin for swc-confidential",
5
5
  "main": "swc_plugin_swc_confidential.wasm",
6
6
  "homepage": "https://swc.rs",
@@ -19,5 +19,9 @@
19
19
  "dependencies": {
20
20
  "@swc/counter": "^0.1.3"
21
21
  },
22
- "scripts": {}
22
+ "scripts": {
23
+ "build": "cargo build --release -p swc_plugin_swc_confidential --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_swc_confidential.wasm .",
24
+ "build:debug": "cargo build -p swc_plugin_swc_confidential --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_swc_confidential.wasm .",
25
+ "test": "pnpm run build:debug && vitest run --testTimeout=0"
26
+ }
23
27
  }
Binary file