@clayroach/effect-unplugin 4.0.0-effect4-transformer.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAC5B,KAAK,GACL,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,KAAK,GACL,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,CAAA;AAEV;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAA;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAC3D;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAClE;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAC/D;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CACvE;AAED;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC;;OAEG;IACH,QAAQ,CAA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0,0 +1,5 @@
1
+ /**
2
+ * @since 0.0.1
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":[null],"mappings":"AAAA","ignoreList":[]}
package/dist/vite.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const _default: (options?: import("./types.ts").SourceTraceOptions | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
2
+ export default _default;
3
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":";AAkBA,wBAA4B"}
package/dist/vite.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Vite plugin for Effect source location tracing.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * // vite.config.ts
7
+ * import { defineConfig } from "vite"
8
+ * import effectSourceTrace from "@effect/unplugin/vite"
9
+ *
10
+ * export default defineConfig({
11
+ * plugins: [effectSourceTrace()]
12
+ * })
13
+ * ```
14
+ *
15
+ * @since 0.0.1
16
+ */
17
+ import unplugin from "./index.js";
18
+ export default unplugin.vite;
19
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","names":["unplugin","vite"],"sources":["../src/vite.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBA,OAAOA,QAAQ,MAAM,YAAY;AAEjC,eAAeA,QAAQ,CAACC,IAAI","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ declare const _default: (options?: import("./types.ts").SourceTraceOptions | undefined) => WebpackPluginInstance;
2
+ export default _default;
3
+ //# sourceMappingURL=webpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":";AAiBA,wBAA+B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Webpack plugin for Effect source location tracing.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * // webpack.config.js
7
+ * import effectSourceTrace from "@effect/unplugin/webpack"
8
+ *
9
+ * export default {
10
+ * plugins: [effectSourceTrace()]
11
+ * }
12
+ * ```
13
+ *
14
+ * @since 0.0.1
15
+ */
16
+ import unplugin from "./index.js";
17
+ export default unplugin.webpack;
18
+ //# sourceMappingURL=webpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.js","names":["unplugin","webpack"],"sources":["../src/webpack.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;AAeA,OAAOA,QAAQ,MAAM,YAAY;AAEjC,eAAeA,QAAQ,CAACC,OAAO","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@clayroach/effect-unplugin",
3
+ "type": "module",
4
+ "version": "4.0.0-effect4-transformer.1",
5
+ "license": "MIT",
6
+ "description": "Build-time AST transformer for Effect source location tracing",
7
+ "homepage": "https://github.com/clayroach/effect",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/clayroach/effect.git",
11
+ "directory": "packages/tools/unplugin"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/clayroach/effect/issues"
15
+ },
16
+ "tags": [
17
+ "typescript",
18
+ "effect",
19
+ "unplugin",
20
+ "vite",
21
+ "webpack",
22
+ "rollup",
23
+ "esbuild"
24
+ ],
25
+ "keywords": [
26
+ "typescript",
27
+ "effect",
28
+ "unplugin",
29
+ "vite",
30
+ "webpack",
31
+ "rollup",
32
+ "esbuild"
33
+ ],
34
+ "sideEffects": [],
35
+ "exports": {
36
+ "./package.json": "./package.json",
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./sourceTrace": {
42
+ "types": "./dist/sourceTrace.d.ts",
43
+ "default": "./dist/sourceTrace.js"
44
+ },
45
+ "./vite": {
46
+ "types": "./dist/vite.d.ts",
47
+ "default": "./dist/vite.js"
48
+ },
49
+ "./rollup": {
50
+ "types": "./dist/rollup.d.ts",
51
+ "default": "./dist/rollup.js"
52
+ },
53
+ "./webpack": {
54
+ "types": "./dist/webpack.d.ts",
55
+ "default": "./dist/webpack.js"
56
+ },
57
+ "./esbuild": {
58
+ "types": "./dist/esbuild.d.ts",
59
+ "default": "./dist/esbuild.js"
60
+ }
61
+ },
62
+ "files": [
63
+ "src/**/*.ts",
64
+ "dist/**/*.js",
65
+ "dist/**/*.js.map",
66
+ "dist/**/*.d.ts",
67
+ "dist/**/*.d.ts.map"
68
+ ],
69
+ "publishConfig": {
70
+ "exports": {
71
+ "./package.json": "./package.json",
72
+ ".": "./dist/index.js",
73
+ "./sourceTrace": "./dist/sourceTrace.js",
74
+ "./vite": "./dist/vite.js",
75
+ "./rollup": "./dist/rollup.js",
76
+ "./webpack": "./dist/webpack.js",
77
+ "./esbuild": "./dist/esbuild.js"
78
+ }
79
+ },
80
+ "scripts": {
81
+ "build": "tsc -b tsconfig.json && pnpm babel",
82
+ "build:tsgo": "tsgo -b tsconfig.json && pnpm babel",
83
+ "babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
84
+ "check": "tsc -b tsconfig.json",
85
+ "test": "vitest",
86
+ "coverage": "vitest --coverage"
87
+ },
88
+ "peerDependencies": {
89
+ "@clayroach/effect": "4.0.0-source-tracing.5"
90
+ },
91
+ "dependencies": {
92
+ "@babel/generator": "^7.27.5",
93
+ "@babel/parser": "^7.27.5",
94
+ "@babel/traverse": "^7.27.4",
95
+ "@babel/types": "^7.27.6",
96
+ "unplugin": "^2.3.4"
97
+ },
98
+ "devDependencies": {
99
+ "@types/babel__generator": "^7.27.0",
100
+ "@types/babel__traverse": "^7.20.7"
101
+ }
102
+ }
package/src/esbuild.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * esbuild plugin for Effect source location tracing.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import esbuild from "esbuild"
7
+ * import effectSourceTrace from "@effect/unplugin/esbuild"
8
+ *
9
+ * esbuild.build({
10
+ * plugins: [effectSourceTrace()]
11
+ * })
12
+ * ```
13
+ *
14
+ * @since 0.0.1
15
+ */
16
+ import unplugin from "./index.ts"
17
+
18
+ export default unplugin.esbuild
package/src/index.ts ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Build-time AST transformer for Effect source location tracing and auto-instrumentation.
3
+ *
4
+ * Provides two features:
5
+ * 1. **Source Tracing**: Transforms `yield*` expressions inside `Effect.gen()` to
6
+ * inject source location information via `CurrentStackFrame`.
7
+ * 2. **Span Instrumentation**: Wraps Effect combinators with `withSpan()` for
8
+ * automatic distributed tracing with OpenTelemetry semantic conventions.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * // vite.config.ts
13
+ * import { defineConfig } from "vite"
14
+ * import effectSourceTrace from "@effect/unplugin/vite"
15
+ *
16
+ * export default defineConfig({
17
+ * plugins: [effectSourceTrace({
18
+ * // Enable source tracing (default: true)
19
+ * sourceTrace: true,
20
+ * // Enable span instrumentation
21
+ * spans: {
22
+ * enabled: true,
23
+ * include: ["gen", "fork", "all", "forEach"],
24
+ * nameFormat: "function" // "function" | "location" | "full"
25
+ * }
26
+ * })]
27
+ * })
28
+ * ```
29
+ *
30
+ * @since 0.0.1
31
+ */
32
+ import { createUnplugin, type TransformResult as UnpluginTransformResult } from "unplugin"
33
+ import { transform } from "./sourceTrace.ts"
34
+ import type { FilterPattern, SourceTraceOptions } from "./types.ts"
35
+
36
+ export { type TransformResult } from "./sourceTrace.ts"
37
+ export type { FilterPattern, InstrumentableEffect, SourceTraceOptions, SpanInstrumentationOptions } from "./types.ts"
38
+
39
+ const defaultInclude: ReadonlyArray<string | RegExp> = [/\.[jt]sx?$/]
40
+ const defaultExclude: ReadonlyArray<string | RegExp> = [/node_modules/]
41
+
42
+ function toArray(value: FilterPattern | undefined): ReadonlyArray<string | RegExp> {
43
+ if (value === undefined) return []
44
+ if (Array.isArray(value)) return value
45
+ return [value as string | RegExp]
46
+ }
47
+
48
+ function createFilter(
49
+ include: FilterPattern | undefined,
50
+ exclude: FilterPattern | undefined
51
+ ): (id: string) => boolean {
52
+ const includePatterns = toArray(include ?? defaultInclude)
53
+ const excludePatterns = toArray(exclude ?? defaultExclude)
54
+
55
+ return (id: string): boolean => {
56
+ for (const pattern of excludePatterns) {
57
+ if (typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)) {
58
+ return false
59
+ }
60
+ }
61
+ for (const pattern of includePatterns) {
62
+ if (typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)) {
63
+ return true
64
+ }
65
+ }
66
+ return false
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Creates the Effect source trace unplugin.
72
+ *
73
+ * @since 0.0.1
74
+ * @category unplugin
75
+ */
76
+ export const unplugin = createUnplugin<SourceTraceOptions | undefined>((options = {}) => {
77
+ const filter = createFilter(options.include, options.exclude)
78
+
79
+ return {
80
+ name: "effect-source-trace",
81
+ enforce: "pre",
82
+
83
+ transformInclude(id) {
84
+ return filter(id)
85
+ },
86
+
87
+ transform(code, id) {
88
+ const result = transform(code, id, options)
89
+ if (!result.transformed) {
90
+ return null
91
+ }
92
+ return { code: result.code, map: result.map } as UnpluginTransformResult
93
+ }
94
+ }
95
+ })
96
+
97
+ export default unplugin
package/src/rollup.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Rollup plugin for Effect source location tracing.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * // rollup.config.js
7
+ * import effectSourceTrace from "@effect/unplugin/rollup"
8
+ *
9
+ * export default {
10
+ * plugins: [effectSourceTrace()]
11
+ * }
12
+ * ```
13
+ *
14
+ * @since 0.0.1
15
+ */
16
+ import unplugin from "./index.ts"
17
+
18
+ export default unplugin.rollup