babel-plugin-saykit 0.0.0-beta-20260418085054
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/dist/index.d.mts +6 -0
- package/dist/index.mjs +24 -0
- package/package.json +51 -0
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { parse } from "@babel/parser";
|
|
3
|
+
import { resolveConfig } from "@saykit/config/features/loader";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
function src_default() {
|
|
6
|
+
const config = resolveConfig();
|
|
7
|
+
return {
|
|
8
|
+
name: "saykit",
|
|
9
|
+
visitor: { Program(path, state) {
|
|
10
|
+
const id_ = state.file.opts.filename;
|
|
11
|
+
if (!id_ || id_.includes("node_modules")) return;
|
|
12
|
+
const code = state.file.code ?? "";
|
|
13
|
+
const id = relative(process.cwd(), id_).replaceAll("\\", "/").split("?")[0];
|
|
14
|
+
const transformed = config.buckets.find((b) => b.match(id))?.transformer.transform(code, id) ?? code;
|
|
15
|
+
if (transformed !== code) {
|
|
16
|
+
const ast = parse(transformed, state.file.opts.parserOpts);
|
|
17
|
+
path.replaceWith(ast.program);
|
|
18
|
+
path.skip();
|
|
19
|
+
}
|
|
20
|
+
} }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { src_default as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "babel-plugin-saykit",
|
|
3
|
+
"version": "0.0.0-beta-20260418085054",
|
|
4
|
+
"description": "Babel plugin for SayKit",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"i18n",
|
|
7
|
+
"rollup",
|
|
8
|
+
"saykit",
|
|
9
|
+
"unplugin",
|
|
10
|
+
"vite",
|
|
11
|
+
"webpack"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/k0d13/saykit#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/k0d13/saykit/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/k0d13/saykit.git",
|
|
21
|
+
"directory": "packages/plugin-babel"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"!dist/**/*.map"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.mts",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@babel/core": "^7.29.0",
|
|
40
|
+
"@babel/parser": "^7.29.2",
|
|
41
|
+
"@types/babel__core": "^7.20.5",
|
|
42
|
+
"@saykit/config": "^0.0.0-beta-20260418085054"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/babel__parser": "^7.1.5"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"check": "tsc --noEmit",
|
|
49
|
+
"build": "tsdown"
|
|
50
|
+
}
|
|
51
|
+
}
|