@fragno-dev/unplugin-fragno 0.0.1 → 0.0.3

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.
Files changed (36) hide show
  1. package/LICENSE.md +16 -0
  2. package/dist/{index-DxDbJ0wz.d.ts → index-C_Qj2XYR.d.ts} +3 -3
  3. package/dist/{index-DxDbJ0wz.d.ts.map → index-C_Qj2XYR.d.ts.map} +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/integrations/astro.d.ts +1 -1
  7. package/dist/integrations/astro.js +2 -2
  8. package/dist/integrations/esbuild.d.ts +4 -4
  9. package/dist/integrations/esbuild.js +2 -2
  10. package/dist/integrations/farm.d.ts +4 -3
  11. package/dist/integrations/farm.js +2 -2
  12. package/dist/integrations/nuxt.d.ts +1 -1
  13. package/dist/integrations/nuxt.js +4 -4
  14. package/dist/integrations/rollup.d.ts +2 -2
  15. package/dist/integrations/rollup.js +2 -2
  16. package/dist/integrations/rspack.d.ts +2 -2
  17. package/dist/integrations/rspack.js +2 -2
  18. package/dist/integrations/vite.d.ts +4 -4
  19. package/dist/integrations/vite.js +3 -3
  20. package/dist/integrations/webpack.d.ts +2 -2
  21. package/dist/integrations/webpack.js +3 -3
  22. package/dist/macros.js +1 -1
  23. package/dist/{package-DVqxmLAc.js → package-C_uRIjY-.js} +2 -2
  24. package/dist/package-C_uRIjY-.js.map +1 -0
  25. package/dist/{src--rYTODVa.js → src-CYpDbNKR.js} +59 -9
  26. package/dist/src-CYpDbNKR.js.map +1 -0
  27. package/dist/{types-B2lQo1ln.d.ts → types-DI0A616D.d.ts} +2 -2
  28. package/dist/types-DI0A616D.d.ts.map +1 -0
  29. package/dist/{vite-CXr48_Nq.js → vite-BVQ3tsw-.js} +3 -3
  30. package/dist/{vite-CXr48_Nq.js.map → vite-BVQ3tsw-.js.map} +1 -1
  31. package/dist/{webpack-BHY3Ecxw.js → webpack-CE47oVW0.js} +3 -3
  32. package/dist/{webpack-BHY3Ecxw.js.map → webpack-CE47oVW0.js.map} +1 -1
  33. package/package.json +14 -21
  34. package/dist/package-DVqxmLAc.js.map +0 -1
  35. package/dist/src--rYTODVa.js.map +0 -1
  36. package/dist/types-B2lQo1ln.d.ts.map +0 -1
package/LICENSE.md ADDED
@@ -0,0 +1,16 @@
1
+ Copyright 2025 - present "ReJot Nederland B.V.", and individual contributors.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the “Software”), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial
10
+ portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
15
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-B2lQo1ln.js";
1
+ import { t as Options } from "./types-DI0A616D.js";
2
2
  import * as unplugin0 from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
  import "@babel/types";
@@ -12,5 +12,5 @@ declare const isMacroBinding: (binding: Binding, macro: string) => boolean;
12
12
  declare const unpluginFactory: UnpluginFactory<Options | undefined>;
13
13
  declare const unplugin: unplugin0.UnpluginInstance<Options | undefined, boolean>;
14
14
  //#endregion
15
- export { isMacroBinding, unplugin, unpluginFactory };
16
- //# sourceMappingURL=index-DxDbJ0wz.d.ts.map
15
+ export { unpluginFactory as n, isMacroBinding as r, unplugin as t };
16
+ //# sourceMappingURL=index-C_Qj2XYR.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DxDbJ0wz.d.ts","names":[],"sources":["../../src/transform-macros.ts","../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAgBa,0BAA2B;;;cCX3B,iBAAiB,gBAAgB;cA0BjC,UAAQ,SAAA,CAAA,iBAAA"}
1
+ {"version":3,"file":"index-C_Qj2XYR.d.ts","names":[],"sources":["../../src/transform-macros.ts","../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAgBa,0BAA2B;;;cCX3B,iBAAiB,gBAAgB;cA2BjC,UAAQ,SAAA,CAAA,iBAAA"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Options } from "./types-B2lQo1ln.js";
2
- import { isMacroBinding, unplugin, unpluginFactory } from "./index-DxDbJ0wz.js";
1
+ import { t as Options } from "./types-DI0A616D.js";
2
+ import { n as unpluginFactory, r as isMacroBinding, t as unplugin } from "./index-C_Qj2XYR.js";
3
3
  export { Options, unplugin as default, unplugin, isMacroBinding, unpluginFactory };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./package-DVqxmLAc.js";
2
- import { isMacroBinding, src_default, unplugin, unpluginFactory } from "./src--rYTODVa.js";
1
+ import "./package-C_uRIjY-.js";
2
+ import { i as isMacroBinding, n as unplugin, r as unpluginFactory, t as src_default } from "./src-CYpDbNKR.js";
3
3
 
4
4
  export { src_default as default, isMacroBinding, unplugin, unpluginFactory };
@@ -1,4 +1,4 @@
1
- import { Options } from "../types-B2lQo1ln.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
2
 
3
3
  //#region src/integrations/astro.d.ts
4
4
  declare const _default: (options: Options) => any;
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { src_default } from "../src--rYTODVa.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { t as src_default } from "../src-CYpDbNKR.js";
3
3
 
4
4
  //#region src/integrations/astro.ts
5
5
  var astro_default = (options) => ({
@@ -1,9 +1,9 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
3
- import * as unplugin0 from "unplugin";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
+ import * as esbuild0 from "esbuild";
4
4
 
5
5
  //#region src/integrations/esbuild.d.ts
6
- declare const _default: (options?: Options | undefined) => unplugin0.EsbuildPlugin;
6
+ declare const _default: (options?: Options | undefined) => esbuild0.Plugin;
7
7
  //#endregion
8
8
  export { _default as default };
9
9
  //# sourceMappingURL=esbuild.d.ts.map
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src--rYTODVa.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CYpDbNKR.js";
3
3
  import { createEsbuildPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/esbuild.ts
@@ -1,8 +1,9 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
+ import * as _farmfe_core0 from "@farmfe/core";
3
4
 
4
5
  //#region src/integrations/farm.d.ts
5
- declare const _default: (options?: Options | undefined) => JsPlugin;
6
+ declare const _default: (options?: Options | undefined) => _farmfe_core0.JsPlugin;
6
7
  //#endregion
7
8
  export { _default as default };
8
9
  //# sourceMappingURL=farm.d.ts.map
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src--rYTODVa.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CYpDbNKR.js";
3
3
  import { createFarmPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/farm.ts
@@ -1,4 +1,4 @@
1
- import { Options } from "../types-B2lQo1ln.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
2
  import * as _nuxt_schema0 from "@nuxt/schema";
3
3
 
4
4
  //#region src/integrations/nuxt.d.ts
@@ -1,7 +1,7 @@
1
- import "../package-DVqxmLAc.js";
2
- import "../src--rYTODVa.js";
3
- import { vite_default } from "../vite-CXr48_Nq.js";
4
- import { webpack_default } from "../webpack-BHY3Ecxw.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import "../src-CYpDbNKR.js";
3
+ import { t as vite_default } from "../vite-BVQ3tsw-.js";
4
+ import { t as webpack_default } from "../webpack-CE47oVW0.js";
5
5
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
6
6
 
7
7
  //#region src/integrations/nuxt.ts
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
  import * as rollup0 from "rollup";
4
4
 
5
5
  //#region src/integrations/rollup.d.ts
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src--rYTODVa.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CYpDbNKR.js";
3
3
  import { createRollupPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/rollup.ts
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
 
4
4
  //#region src/integrations/rspack.d.ts
5
5
  declare const _default: (options?: Options | undefined) => RspackPluginInstance;
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import { unpluginFactory } from "../src--rYTODVa.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import { r as unpluginFactory } from "../src-CYpDbNKR.js";
3
3
  import { createRspackPlugin } from "unplugin";
4
4
 
5
5
  //#region src/integrations/rspack.ts
@@ -1,9 +1,9 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
3
- import * as unplugin1 from "unplugin";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
+ import * as vite0 from "vite";
4
4
 
5
5
  //#region src/integrations/vite.d.ts
6
- declare const _default: (options?: Options | undefined) => unplugin1.VitePlugin<any> | unplugin1.VitePlugin<any>[];
6
+ declare const _default: (options?: Options | undefined) => vite0.Plugin<any> | vite0.Plugin<any>[];
7
7
  //#endregion
8
8
  export { _default as default };
9
9
  //# sourceMappingURL=vite.d.ts.map
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import "../src--rYTODVa.js";
3
- import { vite_default } from "../vite-CXr48_Nq.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import "../src-CYpDbNKR.js";
3
+ import { t as vite_default } from "../vite-BVQ3tsw-.js";
4
4
 
5
5
  export { vite_default as default };
@@ -1,5 +1,5 @@
1
- import { Options } from "../types-B2lQo1ln.js";
2
- import "../index-DxDbJ0wz.js";
1
+ import { t as Options } from "../types-DI0A616D.js";
2
+ import "../index-C_Qj2XYR.js";
3
3
  import * as webpack0 from "webpack";
4
4
 
5
5
  //#region src/integrations/webpack.d.ts
@@ -1,5 +1,5 @@
1
- import "../package-DVqxmLAc.js";
2
- import "../src--rYTODVa.js";
3
- import { webpack_default } from "../webpack-BHY3Ecxw.js";
1
+ import "../package-C_uRIjY-.js";
2
+ import "../src-CYpDbNKR.js";
3
+ import { t as webpack_default } from "../webpack-CE47oVW0.js";
4
4
 
5
5
  export { webpack_default as default };
package/dist/macros.js CHANGED
@@ -1,4 +1,4 @@
1
- import { name } from "./package-DVqxmLAc.js";
1
+ import { t as name } from "./package-C_uRIjY-.js";
2
2
 
3
3
  //#region src/macros.ts
4
4
  const maybe = (_) => {
@@ -2,5 +2,5 @@
2
2
  var name = "@fragno-dev/unplugin-fragno";
3
3
 
4
4
  //#endregion
5
- export { name };
6
- //# sourceMappingURL=package-DVqxmLAc.js.map
5
+ export { name as t };
6
+ //# sourceMappingURL=package-C_uRIjY-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-C_uRIjY-.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@fragno-dev/unplugin-fragno\",\n \"type\": \"module\",\n \"version\": \"0.0.3\",\n \"description\": \"\",\n \"keywords\": [\n \"fragno\",\n \"unplugin\"\n ],\n \"exports\": {\n \".\": {\n \"development\": \"./src/index.ts\",\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./macros\": {\n \"development\": \"./src/macros.ts\",\n \"types\": \"./dist/macros.d.ts\",\n \"default\": \"./dist/macros.js\"\n },\n \"./astro\": {\n \"development\": \"./src/integrations/astro.ts\",\n \"types\": \"./dist/integrations/astro.d.ts\",\n \"default\": \"./dist/integrations/astro.js\"\n },\n \"./esbuild\": {\n \"development\": \"./src/integrations/esbuild.ts\",\n \"types\": \"./dist/integrations/esbuild.d.ts\",\n \"default\": \"./dist/integrations/esbuild.js\"\n },\n \"./farm\": {\n \"development\": \"./src/integrations/farm.ts\",\n \"types\": \"./dist/integrations/farm.d.ts\",\n \"default\": \"./dist/integrations/farm.js\"\n },\n \"./nuxt\": {\n \"development\": \"./src/integrations/nuxt.ts\",\n \"types\": \"./dist/integrations/nuxt.d.ts\",\n \"default\": \"./dist/integrations/nuxt.js\"\n },\n \"./rollup\": {\n \"development\": \"./src/integrations/rollup.ts\",\n \"types\": \"./dist/integrations/rollup.d.ts\",\n \"default\": \"./dist/integrations/rollup.js\"\n },\n \"./rspack\": {\n \"development\": \"./src/integrations/rspack.ts\",\n \"types\": \"./dist/integrations/rspack.d.ts\",\n \"default\": \"./dist/integrations/rspack.js\"\n },\n \"./vite\": {\n \"development\": \"./src/integrations/vite.ts\",\n \"types\": \"./dist/integrations/vite.d.ts\",\n \"default\": \"./dist/integrations/vite.js\"\n },\n \"./webpack\": {\n \"development\": \"./src/integrations/webpack.ts\",\n \"types\": \"./dist/integrations/webpack.d.ts\",\n \"default\": \"./dist/integrations/webpack.js\"\n },\n \"./types\": \"./dist/types.js\",\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"./dist/*\",\n \"./*\"\n ]\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"types:check\": \"tsc --noEmit\",\n \"build\": \"tsdown\",\n \"build:watch\": \"tsdown --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest --watch\"\n },\n \"peerDependencies\": {\n \"@farmfe/core\": \">=1\",\n \"@nuxt/kit\": \"^3 || ^4\",\n \"@nuxt/schema\": \"^3 || ^4\",\n \"esbuild\": \"*\",\n \"rollup\": \"^3\",\n \"vite\": \">=3\",\n \"webpack\": \"^4 || ^5\"\n },\n \"peerDependenciesMeta\": {\n \"@farmfe/core\": {\n \"optional\": true\n },\n \"@nuxt/kit\": {\n \"optional\": true\n },\n \"@nuxt/schema\": {\n \"optional\": true\n },\n \"esbuild\": {\n \"optional\": true\n },\n \"rollup\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n },\n \"webpack\": {\n \"optional\": true\n }\n },\n \"dependencies\": {\n \"unplugin\": \"^2.3.4\",\n \"@babel/core\": \"^7.23.7\",\n \"@babel/generator\": \"^7.23.6\",\n \"@babel/parser\": \"^7.23.6\",\n \"@babel/traverse\": \"^7.23.7\",\n \"@babel/types\": \"^7.23.6\",\n \"babel-dead-code-elimination\": \"^1.0.6\"\n },\n \"devDependencies\": {\n \"@antfu/eslint-config\": \"^4.13.2\",\n \"@fragno-private/typescript-config\": \"workspace:*\",\n \"@fragno-private/vitest-config\": \"workspace:*\",\n \"@nuxt/kit\": \"^4.0.3\",\n \"@nuxt/schema\": \"^4.0.3\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/babel__generator\": \"^7.6.8\",\n \"@types/babel__traverse\": \"^7.20.5\",\n \"@types/node\": \"^22.15.21\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"dedent\": \"^1.7.0\",\n \"eslint\": \"^9.27.0\",\n \"nodemon\": \"^3.1.10\",\n \"rollup\": \"^4.41.0\",\n \"tsdown\": \"^0.12.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vite\": \"^6.3.5\",\n \"vitest\": \"^3.2.4\",\n \"webpack\": \"^5.99.9\"\n }\n}\n"],"mappings":";WACU"}
@@ -1,4 +1,4 @@
1
- import { name } from "./package-DVqxmLAc.js";
1
+ import { t as name } from "./package-C_uRIjY-.js";
2
2
  import { createUnplugin } from "unplugin";
3
3
  import * as babel from "@babel/core";
4
4
  import { traverse } from "@babel/core";
@@ -58,11 +58,11 @@ function transformMacros(ast, options) {
58
58
 
59
59
  //#endregion
60
60
  //#region src/transform-define-route.ts
61
- const FRAGNO_PACKAGES$1 = ["@fragno-dev/core"];
61
+ const FRAGNO_PACKAGES = ["@fragno-dev/core"];
62
62
  const isAddRouteBinding = (binding) => {
63
63
  if (!t.isImportDeclaration(binding?.path.parent)) return false;
64
64
  const source = binding.path.parent.source.value;
65
- if (!FRAGNO_PACKAGES$1.some((pkg) => source.startsWith(pkg))) return false;
65
+ if (!FRAGNO_PACKAGES.some((pkg) => source.startsWith(pkg))) return false;
66
66
  if (!t.isImportSpecifier(binding?.path.node)) return false;
67
67
  const { imported } = binding.path.node;
68
68
  if (!t.isIdentifier(imported)) return false;
@@ -104,15 +104,49 @@ function transformDefineRoute(ast, options) {
104
104
 
105
105
  //#endregion
106
106
  //#region src/transform-define-library.ts
107
- const FRAGNO_PACKAGES = ["@fragno-dev/core"];
107
+ const FRAGNO_PACKAGE_DEFINITIONS = {
108
+ "@fragno-dev/core": {
109
+ fragmentDefinitions: ["defineFragment"],
110
+ chainMethods: ["withDependencies", "withServices"]
111
+ },
112
+ "@fragno-dev/db": {
113
+ fragmentDefinitions: ["defineFragmentWithDatabase"],
114
+ chainMethods: [
115
+ "withDependencies",
116
+ "withServices",
117
+ "withDatabase"
118
+ ],
119
+ utilityFunctions: ["schema"]
120
+ }
121
+ };
122
+ const getPackageDefinition = (source) => {
123
+ for (const [pkg, definition] of Object.entries(FRAGNO_PACKAGE_DEFINITIONS)) if (source === pkg || source.startsWith(`${pkg}/`)) return definition;
124
+ };
125
+ const getAllChainMethods = () => {
126
+ const methods = /* @__PURE__ */ new Set();
127
+ for (const definition of Object.values(FRAGNO_PACKAGE_DEFINITIONS)) if ("chainMethods" in definition) for (const method of definition.chainMethods) methods.add(method);
128
+ return methods;
129
+ };
108
130
  const isDefineLibraryBinding = (binding) => {
109
131
  if (!t.isImportDeclaration(binding?.path.parent)) return false;
110
132
  const source = binding.path.parent.source.value;
111
- if (!FRAGNO_PACKAGES.some((pkg) => source.startsWith(pkg))) return false;
133
+ const definition = getPackageDefinition(source);
134
+ if (!definition || !("fragmentDefinitions" in definition)) return false;
135
+ if (!t.isImportSpecifier(binding?.path.node)) return false;
136
+ const { imported } = binding.path.node;
137
+ if (!t.isIdentifier(imported)) return false;
138
+ if (!definition.fragmentDefinitions.includes(imported.name)) return false;
139
+ return true;
140
+ };
141
+ const isUtilityFunctionBinding = (binding) => {
142
+ if (!t.isImportDeclaration(binding?.path.parent)) return false;
143
+ const source = binding.path.parent.source.value;
144
+ const definition = getPackageDefinition(source);
145
+ if (!definition || !("utilityFunctions" in definition)) return false;
112
146
  if (!t.isImportSpecifier(binding?.path.node)) return false;
113
147
  const { imported } = binding.path.node;
114
148
  if (!t.isIdentifier(imported)) return false;
115
- if (imported.name !== "defineFragment") return false;
149
+ if (!definition.utilityFunctions.includes(imported.name)) return false;
116
150
  return true;
117
151
  };
118
152
  const isDefineLibraryCall = (node, scope) => {
@@ -124,6 +158,14 @@ const isDefineLibraryCall = (node, scope) => {
124
158
  const createNoOpArrowFunction = () => {
125
159
  return t.arrowFunctionExpression([], t.blockStatement([]));
126
160
  };
161
+ /**
162
+ * Create an arrow function that returns its first parameter.
163
+ * Used for utility functions like schema() where the callback needs to return a builder.
164
+ */
165
+ const createPassThroughArrowFunction = () => {
166
+ const param = t.identifier("s");
167
+ return t.arrowFunctionExpression([param], param);
168
+ };
127
169
  const isDefineLibraryChain = (node, scope) => {
128
170
  if (t.isCallExpression(node) && isDefineLibraryCall(node, scope)) return true;
129
171
  if (t.isCallExpression(node) && t.isMemberExpression(node.callee)) return isDefineLibraryChain(node.callee.object, scope);
@@ -138,13 +180,21 @@ const isDefineLibraryChain = (node, scope) => {
138
180
  };
139
181
  function transformDefineLibrary(ast, options) {
140
182
  if (options.ssr) return;
183
+ const chainMethods = getAllChainMethods();
141
184
  traverse(ast, { CallExpression(path) {
142
185
  const { callee } = path.node;
186
+ if (t.isIdentifier(callee)) {
187
+ const binding = path.scope.getBinding(callee.name);
188
+ if (binding && isUtilityFunctionBinding(binding)) {
189
+ path.node.arguments = [createPassThroughArrowFunction()];
190
+ return;
191
+ }
192
+ }
143
193
  if (!t.isMemberExpression(callee)) return;
144
194
  const { property, object } = callee;
145
195
  if (!t.isIdentifier(property)) return;
146
196
  const methodName = property.name;
147
- if (methodName !== "withDependencies" && methodName !== "withServices") return;
197
+ if (!chainMethods.has(methodName)) return;
148
198
  if (!isDefineLibraryChain(object, path.scope)) return;
149
199
  path.node.arguments = [createNoOpArrowFunction()];
150
200
  } });
@@ -193,5 +243,5 @@ const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
193
243
  var src_default = unplugin;
194
244
 
195
245
  //#endregion
196
- export { isMacroBinding, src_default, unplugin, unpluginFactory };
197
- //# sourceMappingURL=src--rYTODVa.js.map
246
+ export { isMacroBinding as i, unplugin as n, unpluginFactory as r, src_default as t };
247
+ //# sourceMappingURL=src-CYpDbNKR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-CYpDbNKR.js","names":["pkgName","unpluginFactory: UnpluginFactory<Options | undefined>"],"sources":["../src/transform-macros.ts","../src/transform-define-route.ts","../src/transform-define-library.ts","../src/transform.ts","../src/index.ts"],"sourcesContent":["/**\n * Modified from: pcattori/vite-env-only\n * Original source: https://github.com/pcattori/vite-env-only/blob/45a39e7fb52e9fae4300e95aa51ed0880374f507/src/transform.ts\n * License: MIT\n * Date obtained: September 4 2025\n * Copyright (c) 2024 Pedro Cattori\n */\n\nimport { traverse } from \"@babel/core\";\nimport type { Binding, NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\nimport { name as pkgName } from \"../package.json\";\n\nconst macrosSpecifier = `${pkgName}/macros`;\n\nexport const isMacroBinding = (binding: Binding, macro: string): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n if (binding.path.parent.source.value !== macrosSpecifier) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n if (imported.name !== macro) {\n return false;\n }\n return true;\n};\n\nconst isMacro = (path: NodePath<t.CallExpression>, macro: string) => {\n if (!t.isIdentifier(path.node.callee)) {\n return false;\n }\n const binding = path.scope.getBinding(path.node.callee.name);\n\n if (!binding) {\n return false;\n }\n if (!isMacroBinding(binding, macro)) {\n return false;\n }\n\n if (path.node.arguments.length !== 1) {\n throw path.buildCodeFrameError(`'${macro}' must take exactly one argument`);\n }\n return true;\n};\n\nexport function transformMacros(ast: Node, options: { ssr: boolean }) {\n traverse(ast, {\n CallExpression(path) {\n if (isMacro(path, options.ssr ? \"clientOnly$\" : \"serverOnly$\")) {\n path.replaceWith(t.identifier(\"undefined\"));\n }\n if (isMacro(path, options.ssr ? \"serverOnly$\" : \"clientOnly$\")) {\n const arg = path.node.arguments[0];\n if (t.isExpression(arg)) {\n path.replaceWith(arg);\n }\n }\n },\n\n Identifier(path) {\n if (t.isImportSpecifier(path.parent)) {\n return;\n }\n\n const binding = path.scope.getBinding(path.node.name);\n if (!binding) {\n return;\n }\n if (!isMacroBinding(binding, \"serverOnly$\") && !isMacroBinding(binding, \"clientOnly$\")) {\n return;\n }\n if (t.isCallExpression(path.parent)) {\n return;\n }\n throw path.buildCodeFrameError(\n `'${path.node.name}' macro cannot be manipulated at runtime as it must be statically analysable`,\n );\n },\n\n ImportDeclaration(path) {\n if (path.node.source.value !== macrosSpecifier) {\n return;\n }\n path.node.specifiers.forEach((specifier, i) => {\n if (t.isImportNamespaceSpecifier(specifier)) {\n const subpath = path.get(`specifiers.${i}`);\n if (Array.isArray(subpath)) {\n throw new Error(\"unreachable\");\n }\n throw subpath.buildCodeFrameError(\n `Namespace import is not supported by '${macrosSpecifier}'`,\n );\n }\n });\n },\n });\n}\n","import { traverse } from \"@babel/core\";\nimport type { Binding, NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\n\nconst FRAGNO_PACKAGES = [\"@fragno-dev/core\"];\n\nconst isAddRouteBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n if (!FRAGNO_PACKAGES.some((pkg) => source.startsWith(pkg))) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n if (imported.name !== \"addRoute\" && imported.name !== \"defineRoute\") {\n return false;\n }\n\n return true;\n};\n\nconst isAddRouteCall = (path: NodePath<t.CallExpression>): boolean => {\n if (!t.isIdentifier(path.node.callee)) {\n return false;\n }\n const binding = path.scope.getBinding(path.node.callee.name);\n\n if (!binding) {\n return false;\n }\n\n return isAddRouteBinding(binding);\n};\n\nfunction replaceHandlerWithNoop(routeConfig: t.Expression) {\n if (!t.isObjectExpression(routeConfig)) {\n return;\n }\n\n const handlerProp = routeConfig.properties.find((prop) => {\n if (t.isObjectProperty(prop) || t.isObjectMethod(prop)) {\n const key = prop.key;\n return t.isIdentifier(key) && key.name === \"handler\";\n }\n return false;\n });\n\n if (!handlerProp) {\n return;\n }\n\n if (t.isObjectProperty(handlerProp)) {\n handlerProp.value = t.arrowFunctionExpression([], t.blockStatement([]));\n } else if (t.isObjectMethod(handlerProp)) {\n handlerProp.body = t.blockStatement([]);\n handlerProp.params = [];\n }\n}\n\nexport function transformDefineRoute(ast: Node, options: { ssr: boolean }) {\n if (options.ssr) {\n return;\n }\n\n traverse(ast, {\n CallExpression(path) {\n if (!isAddRouteCall(path)) {\n return;\n }\n\n if (path.node.arguments.length > 0) {\n const firstArg = path.node.arguments[0];\n if (t.isExpression(firstArg)) {\n replaceHandlerWithNoop(firstArg);\n }\n }\n },\n });\n}\n","import { traverse } from \"@babel/core\";\nimport type { Binding, Scope } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\n\nconst FRAGNO_PACKAGE_DEFINITIONS = {\n \"@fragno-dev/core\": {\n fragmentDefinitions: [\"defineFragment\"],\n chainMethods: [\"withDependencies\", \"withServices\"],\n },\n \"@fragno-dev/db\": {\n fragmentDefinitions: [\"defineFragmentWithDatabase\"],\n chainMethods: [\"withDependencies\", \"withServices\", \"withDatabase\"],\n utilityFunctions: [\"schema\"],\n },\n} as const;\n\ntype PackageDefinition =\n (typeof FRAGNO_PACKAGE_DEFINITIONS)[keyof typeof FRAGNO_PACKAGE_DEFINITIONS];\n\nconst getPackageDefinition = (source: string): PackageDefinition | undefined => {\n for (const [pkg, definition] of Object.entries(FRAGNO_PACKAGE_DEFINITIONS)) {\n if (source === pkg || source.startsWith(`${pkg}/`)) {\n return definition;\n }\n }\n return undefined;\n};\n\nconst getAllChainMethods = (): Set<string> => {\n const methods = new Set<string>();\n for (const definition of Object.values(FRAGNO_PACKAGE_DEFINITIONS)) {\n if (\"chainMethods\" in definition) {\n for (const method of definition.chainMethods) {\n methods.add(method);\n }\n }\n }\n return methods;\n};\n\nconst isDefineLibraryBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n const definition = getPackageDefinition(source);\n\n if (!definition || !(\"fragmentDefinitions\" in definition)) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n // Safe cast: we checked that fragmentDefinitions exists above\n if (!(definition.fragmentDefinitions as readonly string[]).includes(imported.name)) {\n return false;\n }\n\n return true;\n};\n\nconst isUtilityFunctionBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n const definition = getPackageDefinition(source);\n\n if (!definition || !(\"utilityFunctions\" in definition)) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n // Safe cast: we checked that utilityFunctions exists above\n if (!(definition.utilityFunctions as readonly string[]).includes(imported.name)) {\n return false;\n }\n\n return true;\n};\n\nconst isDefineLibraryCall = (node: t.CallExpression, scope: Scope): boolean => {\n if (!t.isIdentifier(node.callee)) {\n return false;\n }\n const binding = scope.getBinding(node.callee.name);\n\n if (!binding) {\n return false;\n }\n return isDefineLibraryBinding(binding);\n};\n\nconst createNoOpArrowFunction = (): t.ArrowFunctionExpression => {\n return t.arrowFunctionExpression([], t.blockStatement([]));\n};\n\n/**\n * Create an arrow function that returns its first parameter.\n * Used for utility functions like schema() where the callback needs to return a builder.\n */\nconst createPassThroughArrowFunction = (): t.ArrowFunctionExpression => {\n const param = t.identifier(\"s\");\n return t.arrowFunctionExpression([param], param);\n};\n\nconst isDefineLibraryChain = (node: t.Node, scope: Scope): boolean => {\n // Check direct defineFragment call\n if (t.isCallExpression(node) && isDefineLibraryCall(node, scope)) {\n return true;\n }\n\n // Check chained method calls\n if (t.isCallExpression(node) && t.isMemberExpression(node.callee)) {\n return isDefineLibraryChain(node.callee.object, scope);\n }\n\n // Check if it's an identifier that refers to a defineFragment result\n if (t.isIdentifier(node)) {\n const binding = scope.getBinding(node.name);\n if (binding && binding.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init) {\n return isDefineLibraryChain(init, scope);\n }\n }\n }\n\n return false;\n};\n\nexport function transformDefineLibrary(ast: Node, options: { ssr: boolean }): void {\n if (options.ssr) {\n return;\n }\n\n const chainMethods = getAllChainMethods();\n\n traverse(ast, {\n CallExpression(path) {\n const { callee } = path.node;\n\n // Check if this is a utility function call (like schema)\n if (t.isIdentifier(callee)) {\n const binding = path.scope.getBinding(callee.name);\n if (binding && isUtilityFunctionBinding(binding)) {\n // Replace with a pass-through function that returns its parameter\n // This prevents errors like \"Cannot read properties of undefined (reading 'build')\"\n // when schema(() => {}) would return undefined\n path.node.arguments = [createPassThroughArrowFunction()];\n return;\n }\n }\n\n // Check if this is a method call\n if (!t.isMemberExpression(callee)) {\n return;\n }\n\n const { property, object } = callee;\n\n // Check if the method is a chain method\n if (!t.isIdentifier(property)) {\n return;\n }\n\n const methodName = property.name;\n if (!chainMethods.has(methodName)) {\n return;\n }\n\n // Check if this is part of a defineFragment chain\n if (!isDefineLibraryChain(object, path.scope)) {\n return;\n }\n\n // Replace the argument with a no-op function\n path.node.arguments = [createNoOpArrowFunction()];\n },\n });\n}\n","import * as babel from \"@babel/core\";\nimport { parse } from \"@babel/parser\";\nimport { generate } from \"@babel/generator\";\nimport type { GeneratorResult } from \"@babel/generator\";\n\nimport { deadCodeElimination, findReferencedIdentifiers } from \"babel-dead-code-elimination\";\nimport { transformMacros } from \"./transform-macros\";\nimport { transformDefineRoute } from \"./transform-define-route\";\nimport { transformDefineLibrary } from \"./transform-define-library\";\n\nexport const transform = (code: string, id: string, options: { ssr: boolean }): GeneratorResult => {\n const ast = parse(code, { sourceType: \"module\", plugins: [[\"typescript\", {}]] });\n\n // - https://github.com/babel/babel/issues/11889\n // - https://github.com/babel/babel/issues/11350#issuecomment-606169054\n // @ts-expect-error `@types/babel__core` is missing types for `File`\n new babel.File({ filename: undefined }, { code, ast });\n\n const refs = findReferencedIdentifiers(ast);\n\n transformMacros(ast, options);\n transformDefineRoute(ast, options);\n transformDefineLibrary(ast, options);\n\n deadCodeElimination(ast, refs);\n return generate(ast, { sourceMaps: true, sourceFileName: id }, code);\n};\n","import type { UnpluginFactory } from \"unplugin\";\nimport type { Options } from \"./types\";\nimport { createUnplugin } from \"unplugin\";\nimport { transform } from \"./transform\";\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const { platform } = options;\n\n if (platform !== \"browser\") {\n return [];\n }\n\n return {\n name: \"unplugin-fragno\",\n\n transformInclude(id) {\n if (id.endsWith(\".d.ts\")) {\n return false;\n }\n\n if (id.includes(\"@fragno-dev/unplugin-fragno\") || id.includes(\"@fragno-dev/core\")) {\n return false;\n }\n\n return true;\n },\n transform(code, id) {\n return transform(code, id, { ssr: false });\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\nexport type { Options };\nexport { isMacroBinding } from \"./transform-macros\";\n"],"mappings":";;;;;;;;;;AAcA,MAAM,kBAAkB,GAAGA,KAAQ;AAEnC,MAAa,kBAAkB,SAAkB,UAA2B;AAC1E,KAAI,CAAC,EAAE,oBAAoB,SAAS,KAAK,OAAO,CAC9C,QAAO;AAET,KAAI,QAAQ,KAAK,OAAO,OAAO,UAAU,gBACvC,QAAO;AAGT,KAAI,CAAC,EAAE,kBAAkB,SAAS,KAAK,KAAK,CAC1C,QAAO;CAET,MAAM,EAAE,aAAa,QAAQ,KAAK;AAClC,KAAI,CAAC,EAAE,aAAa,SAAS,CAC3B,QAAO;AAET,KAAI,SAAS,SAAS,MACpB,QAAO;AAET,QAA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yD,UAAU,EAAE,KAAK;CACrF,MAAM,EAAE,aAAa;AAErB,KAAI,aAAa,UACf,QAAO,EAAE;AAGX,QAAO;EACL,MAAM;EAEN,iBAAiB,IAAI;AACnB,OAAI,GAAG,SAAS,QAAQ,CACtB,QAAO;AAGT,OAAI,GAAG,SAAS,8BAA8B,IAAI,GAAG,SAAS,mBAAmB,CAC/E,QAAO;AAGT,UAAO;;EAET,UAAU,MAAM,IAAI;AAClB,UAAO,UAAU,MAAM,IAAI,EAAE,KAAK,OAAO,CAAC;;EAE7C;;AAGH,MAAa,WAA2B,+BAAe,gBAAgB;AAEvE,kBAAe"}
@@ -4,5 +4,5 @@ interface Options {
4
4
  }
5
5
  //# sourceMappingURL=types.d.ts.map
6
6
  //#endregion
7
- export { Options };
8
- //# sourceMappingURL=types-B2lQo1ln.d.ts.map
7
+ export { Options as t };
8
+ //# sourceMappingURL=types-DI0A616D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DI0A616D.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";UAAiB,OAAA;EAAA,QAAA,CAAA,EAAO,SAAA,GAAA,MAAA"}
@@ -1,9 +1,9 @@
1
- import { unpluginFactory } from "./src--rYTODVa.js";
1
+ import { r as unpluginFactory } from "./src-CYpDbNKR.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
 
4
4
  //#region src/integrations/vite.ts
5
5
  var vite_default = createVitePlugin(unpluginFactory);
6
6
 
7
7
  //#endregion
8
- export { vite_default };
9
- //# sourceMappingURL=vite-CXr48_Nq.js.map
8
+ export { vite_default as t };
9
+ //# sourceMappingURL=vite-BVQ3tsw-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-CXr48_Nq.js","names":[],"sources":["../src/integrations/vite.ts"],"sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport { unpluginFactory } from \"..\";\n\nexport default createVitePlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,mBAAe,iBAAiB,gBAAgB"}
1
+ {"version":3,"file":"vite-BVQ3tsw-.js","names":[],"sources":["../src/integrations/vite.ts"],"sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport { unpluginFactory } from \"..\";\n\nexport default createVitePlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,mBAAe,iBAAiB,gBAAgB"}
@@ -1,9 +1,9 @@
1
- import { unpluginFactory } from "./src--rYTODVa.js";
1
+ import { r as unpluginFactory } from "./src-CYpDbNKR.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/integrations/webpack.ts
5
5
  var webpack_default = createWebpackPlugin(unpluginFactory);
6
6
 
7
7
  //#endregion
8
- export { webpack_default };
9
- //# sourceMappingURL=webpack-BHY3Ecxw.js.map
8
+ export { webpack_default as t };
9
+ //# sourceMappingURL=webpack-CE47oVW0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-BHY3Ecxw.js","names":[],"sources":["../src/integrations/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \"..\";\n\nexport default createWebpackPlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,sBAAe,oBAAoB,gBAAgB"}
1
+ {"version":3,"file":"webpack-CE47oVW0.js","names":[],"sources":["../src/integrations/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \"..\";\n\nexport default createWebpackPlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,sBAAe,oBAAoB,gBAAgB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragno-dev/unplugin-fragno",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "fragno",
@@ -9,61 +9,51 @@
9
9
  ],
10
10
  "exports": {
11
11
  ".": {
12
- "bun": "./src/index.ts",
13
12
  "development": "./src/index.ts",
14
13
  "types": "./dist/index.d.ts",
15
14
  "default": "./dist/index.js"
16
15
  },
17
16
  "./macros": {
18
- "bun": "./src/macros.ts",
19
17
  "development": "./src/macros.ts",
20
18
  "types": "./dist/macros.d.ts",
21
19
  "default": "./dist/macros.js"
22
20
  },
23
21
  "./astro": {
24
- "bun": "./src/integrations/astro.ts",
25
22
  "development": "./src/integrations/astro.ts",
26
23
  "types": "./dist/integrations/astro.d.ts",
27
24
  "default": "./dist/integrations/astro.js"
28
25
  },
29
26
  "./esbuild": {
30
- "bun": "./src/integrations/esbuild.ts",
31
27
  "development": "./src/integrations/esbuild.ts",
32
28
  "types": "./dist/integrations/esbuild.d.ts",
33
29
  "default": "./dist/integrations/esbuild.js"
34
30
  },
35
31
  "./farm": {
36
- "bun": "./src/integrations/farm.ts",
37
32
  "development": "./src/integrations/farm.ts",
38
33
  "types": "./dist/integrations/farm.d.ts",
39
34
  "default": "./dist/integrations/farm.js"
40
35
  },
41
36
  "./nuxt": {
42
- "bun": "./src/integrations/nuxt.ts",
43
37
  "development": "./src/integrations/nuxt.ts",
44
38
  "types": "./dist/integrations/nuxt.d.ts",
45
39
  "default": "./dist/integrations/nuxt.js"
46
40
  },
47
41
  "./rollup": {
48
- "bun": "./src/integrations/rollup.ts",
49
42
  "development": "./src/integrations/rollup.ts",
50
43
  "types": "./dist/integrations/rollup.d.ts",
51
44
  "default": "./dist/integrations/rollup.js"
52
45
  },
53
46
  "./rspack": {
54
- "bun": "./src/integrations/rspack.ts",
55
47
  "development": "./src/integrations/rspack.ts",
56
48
  "types": "./dist/integrations/rspack.d.ts",
57
49
  "default": "./dist/integrations/rspack.js"
58
50
  },
59
51
  "./vite": {
60
- "bun": "./src/integrations/vite.ts",
61
52
  "development": "./src/integrations/vite.ts",
62
53
  "types": "./dist/integrations/vite.d.ts",
63
54
  "default": "./dist/integrations/vite.js"
64
55
  },
65
56
  "./webpack": {
66
- "bun": "./src/integrations/webpack.ts",
67
57
  "development": "./src/integrations/webpack.ts",
68
58
  "types": "./dist/integrations/webpack.d.ts",
69
59
  "default": "./dist/integrations/webpack.js"
@@ -85,12 +75,6 @@
85
75
  "files": [
86
76
  "dist"
87
77
  ],
88
- "scripts": {
89
- "types:check": "tsc --noEmit",
90
- "build": "tsdown",
91
- "build:watch": "tsdown --watch",
92
- "test": "vitest"
93
- },
94
78
  "peerDependencies": {
95
79
  "@farmfe/core": ">=1",
96
80
  "@nuxt/kit": "^3 || ^4",
@@ -134,13 +118,13 @@
134
118
  },
135
119
  "devDependencies": {
136
120
  "@antfu/eslint-config": "^4.13.2",
137
- "@fragno-private/typescript-config": "0.0.1",
138
121
  "@nuxt/kit": "^4.0.3",
139
122
  "@nuxt/schema": "^4.0.3",
140
123
  "@types/babel__core": "^7.20.5",
141
124
  "@types/babel__generator": "^7.6.8",
142
125
  "@types/babel__traverse": "^7.20.5",
143
126
  "@types/node": "^22.15.21",
127
+ "@vitest/coverage-istanbul": "^3.2.4",
144
128
  "dedent": "^1.7.0",
145
129
  "eslint": "^9.27.0",
146
130
  "nodemon": "^3.1.10",
@@ -149,7 +133,16 @@
149
133
  "tsx": "^4.19.4",
150
134
  "typescript": "^5.8.3",
151
135
  "vite": "^6.3.5",
152
- "vitest": "^3.1.4",
153
- "webpack": "^5.99.9"
136
+ "vitest": "^3.2.4",
137
+ "webpack": "^5.99.9",
138
+ "@fragno-private/typescript-config": "0.0.1",
139
+ "@fragno-private/vitest-config": "0.0.0"
140
+ },
141
+ "scripts": {
142
+ "types:check": "tsc --noEmit",
143
+ "build": "tsdown",
144
+ "build:watch": "tsdown --watch",
145
+ "test": "vitest run",
146
+ "test:watch": "vitest --watch"
154
147
  }
155
- }
148
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-DVqxmLAc.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@fragno-dev/unplugin-fragno\",\n \"type\": \"module\",\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"keywords\": [\n \"fragno\",\n \"unplugin\"\n ],\n \"exports\": {\n \".\": {\n \"bun\": \"./src/index.ts\",\n \"development\": \"./src/index.ts\",\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./macros\": {\n \"bun\": \"./src/macros.ts\",\n \"development\": \"./src/macros.ts\",\n \"types\": \"./dist/macros.d.ts\",\n \"default\": \"./dist/macros.js\"\n },\n \"./astro\": {\n \"bun\": \"./src/integrations/astro.ts\",\n \"development\": \"./src/integrations/astro.ts\",\n \"types\": \"./dist/integrations/astro.d.ts\",\n \"default\": \"./dist/integrations/astro.js\"\n },\n \"./esbuild\": {\n \"bun\": \"./src/integrations/esbuild.ts\",\n \"development\": \"./src/integrations/esbuild.ts\",\n \"types\": \"./dist/integrations/esbuild.d.ts\",\n \"default\": \"./dist/integrations/esbuild.js\"\n },\n \"./farm\": {\n \"bun\": \"./src/integrations/farm.ts\",\n \"development\": \"./src/integrations/farm.ts\",\n \"types\": \"./dist/integrations/farm.d.ts\",\n \"default\": \"./dist/integrations/farm.js\"\n },\n \"./nuxt\": {\n \"bun\": \"./src/integrations/nuxt.ts\",\n \"development\": \"./src/integrations/nuxt.ts\",\n \"types\": \"./dist/integrations/nuxt.d.ts\",\n \"default\": \"./dist/integrations/nuxt.js\"\n },\n \"./rollup\": {\n \"bun\": \"./src/integrations/rollup.ts\",\n \"development\": \"./src/integrations/rollup.ts\",\n \"types\": \"./dist/integrations/rollup.d.ts\",\n \"default\": \"./dist/integrations/rollup.js\"\n },\n \"./rspack\": {\n \"bun\": \"./src/integrations/rspack.ts\",\n \"development\": \"./src/integrations/rspack.ts\",\n \"types\": \"./dist/integrations/rspack.d.ts\",\n \"default\": \"./dist/integrations/rspack.js\"\n },\n \"./vite\": {\n \"bun\": \"./src/integrations/vite.ts\",\n \"development\": \"./src/integrations/vite.ts\",\n \"types\": \"./dist/integrations/vite.d.ts\",\n \"default\": \"./dist/integrations/vite.js\"\n },\n \"./webpack\": {\n \"bun\": \"./src/integrations/webpack.ts\",\n \"development\": \"./src/integrations/webpack.ts\",\n \"types\": \"./dist/integrations/webpack.d.ts\",\n \"default\": \"./dist/integrations/webpack.js\"\n },\n \"./types\": \"./dist/types.js\",\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"./dist/*\",\n \"./*\"\n ]\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"types:check\": \"tsc --noEmit\",\n \"build\": \"tsdown\",\n \"build:watch\": \"tsdown --watch\",\n \"test\": \"vitest\"\n },\n \"peerDependencies\": {\n \"@farmfe/core\": \">=1\",\n \"@nuxt/kit\": \"^3 || ^4\",\n \"@nuxt/schema\": \"^3 || ^4\",\n \"esbuild\": \"*\",\n \"rollup\": \"^3\",\n \"vite\": \">=3\",\n \"webpack\": \"^4 || ^5\"\n },\n \"peerDependenciesMeta\": {\n \"@farmfe/core\": {\n \"optional\": true\n },\n \"@nuxt/kit\": {\n \"optional\": true\n },\n \"@nuxt/schema\": {\n \"optional\": true\n },\n \"esbuild\": {\n \"optional\": true\n },\n \"rollup\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n },\n \"webpack\": {\n \"optional\": true\n }\n },\n \"dependencies\": {\n \"unplugin\": \"^2.3.4\",\n \"@babel/core\": \"^7.23.7\",\n \"@babel/generator\": \"^7.23.6\",\n \"@babel/parser\": \"^7.23.6\",\n \"@babel/traverse\": \"^7.23.7\",\n \"@babel/types\": \"^7.23.6\",\n \"babel-dead-code-elimination\": \"^1.0.6\"\n },\n \"devDependencies\": {\n \"@antfu/eslint-config\": \"^4.13.2\",\n \"@fragno-private/typescript-config\": \"workspace:*\",\n \"@nuxt/kit\": \"^4.0.3\",\n \"@nuxt/schema\": \"^4.0.3\",\n \"@types/babel__core\": \"^7.20.5\",\n \"@types/babel__generator\": \"^7.6.8\",\n \"@types/babel__traverse\": \"^7.20.5\",\n \"@types/node\": \"^22.15.21\",\n \"dedent\": \"^1.7.0\",\n \"eslint\": \"^9.27.0\",\n \"nodemon\": \"^3.1.10\",\n \"rollup\": \"^4.41.0\",\n \"tsdown\": \"^0.12.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vite\": \"^6.3.5\",\n \"vitest\": \"^3.1.4\",\n \"webpack\": \"^5.99.9\"\n }\n}\n"],"mappings":";WACU"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"src--rYTODVa.js","names":["pkgName","FRAGNO_PACKAGES","unpluginFactory: UnpluginFactory<Options | undefined>"],"sources":["../src/transform-macros.ts","../src/transform-define-route.ts","../src/transform-define-library.ts","../src/transform.ts","../src/index.ts"],"sourcesContent":["/**\n * Modified from: pcattori/vite-env-only\n * Original source: https://github.com/pcattori/vite-env-only/blob/45a39e7fb52e9fae4300e95aa51ed0880374f507/src/transform.ts\n * License: MIT\n * Date obtained: September 4 2025\n * Copyright (c) 2024 Pedro Cattori\n */\n\nimport { traverse } from \"@babel/core\";\nimport type { Binding, NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\nimport { name as pkgName } from \"../package.json\";\n\nconst macrosSpecifier = `${pkgName}/macros`;\n\nexport const isMacroBinding = (binding: Binding, macro: string): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) return false;\n if (binding.path.parent.source.value !== macrosSpecifier) return false;\n\n if (!t.isImportSpecifier(binding?.path.node)) return false;\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) return false;\n if (imported.name !== macro) return false;\n return true;\n};\n\nconst isMacro = (path: NodePath<t.CallExpression>, macro: string) => {\n if (!t.isIdentifier(path.node.callee)) return false;\n const binding = path.scope.getBinding(path.node.callee.name);\n\n if (!binding) return false;\n if (!isMacroBinding(binding, macro)) return false;\n\n if (path.node.arguments.length !== 1) {\n throw path.buildCodeFrameError(`'${macro}' must take exactly one argument`);\n }\n return true;\n};\n\nexport function transformMacros(ast: Node, options: { ssr: boolean }) {\n traverse(ast, {\n CallExpression(path) {\n if (isMacro(path, options.ssr ? \"clientOnly$\" : \"serverOnly$\")) {\n path.replaceWith(t.identifier(\"undefined\"));\n }\n if (isMacro(path, options.ssr ? \"serverOnly$\" : \"clientOnly$\")) {\n const arg = path.node.arguments[0];\n if (t.isExpression(arg)) {\n path.replaceWith(arg);\n }\n }\n },\n\n Identifier(path) {\n if (t.isImportSpecifier(path.parent)) return;\n\n const binding = path.scope.getBinding(path.node.name);\n if (!binding) return;\n if (!isMacroBinding(binding, \"serverOnly$\") && !isMacroBinding(binding, \"clientOnly$\")) {\n return;\n }\n if (t.isCallExpression(path.parent)) return;\n throw path.buildCodeFrameError(\n `'${path.node.name}' macro cannot be manipulated at runtime as it must be statically analysable`,\n );\n },\n\n ImportDeclaration(path) {\n if (path.node.source.value !== macrosSpecifier) return;\n path.node.specifiers.forEach((specifier, i) => {\n if (t.isImportNamespaceSpecifier(specifier)) {\n const subpath = path.get(`specifiers.${i}`);\n if (Array.isArray(subpath)) throw new Error(\"unreachable\");\n throw subpath.buildCodeFrameError(\n `Namespace import is not supported by '${macrosSpecifier}'`,\n );\n }\n });\n },\n });\n}\n","import { traverse } from \"@babel/core\";\nimport type { Binding, NodePath } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\n\nconst FRAGNO_PACKAGES = [\"@fragno-dev/core\"];\n\nconst isAddRouteBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n if (!FRAGNO_PACKAGES.some((pkg) => source.startsWith(pkg))) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n if (imported.name !== \"addRoute\" && imported.name !== \"defineRoute\") {\n return false;\n }\n\n return true;\n};\n\nconst isAddRouteCall = (path: NodePath<t.CallExpression>): boolean => {\n if (!t.isIdentifier(path.node.callee)) {\n return false;\n }\n const binding = path.scope.getBinding(path.node.callee.name);\n\n if (!binding) {\n return false;\n }\n\n return isAddRouteBinding(binding);\n};\n\nfunction replaceHandlerWithNoop(routeConfig: t.Expression) {\n if (!t.isObjectExpression(routeConfig)) {\n return;\n }\n\n const handlerProp = routeConfig.properties.find((prop) => {\n if (t.isObjectProperty(prop) || t.isObjectMethod(prop)) {\n const key = prop.key;\n return t.isIdentifier(key) && key.name === \"handler\";\n }\n return false;\n });\n\n if (!handlerProp) {\n return;\n }\n\n if (t.isObjectProperty(handlerProp)) {\n handlerProp.value = t.arrowFunctionExpression([], t.blockStatement([]));\n } else if (t.isObjectMethod(handlerProp)) {\n handlerProp.body = t.blockStatement([]);\n handlerProp.params = [];\n }\n}\n\nexport function transformDefineRoute(ast: Node, options: { ssr: boolean }) {\n if (options.ssr) {\n return;\n }\n\n traverse(ast, {\n CallExpression(path) {\n if (!isAddRouteCall(path)) {\n return;\n }\n\n if (path.node.arguments.length > 0) {\n const firstArg = path.node.arguments[0];\n if (t.isExpression(firstArg)) {\n replaceHandlerWithNoop(firstArg);\n }\n }\n },\n });\n}\n","import { traverse } from \"@babel/core\";\nimport type { Binding, Scope } from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport type { Node } from \"@babel/types\";\n\nconst FRAGNO_PACKAGES = [\"@fragno-dev/core\"];\n\nconst isDefineLibraryBinding = (binding: Binding): boolean => {\n if (!t.isImportDeclaration(binding?.path.parent)) {\n return false;\n }\n\n const source = binding.path.parent.source.value;\n if (!FRAGNO_PACKAGES.some((pkg) => source.startsWith(pkg))) {\n return false;\n }\n\n if (!t.isImportSpecifier(binding?.path.node)) {\n return false;\n }\n\n const { imported } = binding.path.node;\n if (!t.isIdentifier(imported)) {\n return false;\n }\n\n if (imported.name !== \"defineFragment\") {\n return false;\n }\n\n return true;\n};\n\nconst isDefineLibraryCall = (node: t.CallExpression, scope: Scope): boolean => {\n if (!t.isIdentifier(node.callee)) {\n return false;\n }\n const binding = scope.getBinding(node.callee.name);\n\n if (!binding) {\n return false;\n }\n return isDefineLibraryBinding(binding);\n};\n\nconst createNoOpArrowFunction = (): t.ArrowFunctionExpression => {\n return t.arrowFunctionExpression([], t.blockStatement([]));\n};\n\nconst isDefineLibraryChain = (node: t.Node, scope: Scope): boolean => {\n // Check direct defineFragment call\n if (t.isCallExpression(node) && isDefineLibraryCall(node, scope)) {\n return true;\n }\n\n // Check chained method calls\n if (t.isCallExpression(node) && t.isMemberExpression(node.callee)) {\n return isDefineLibraryChain(node.callee.object, scope);\n }\n\n // Check if it's an identifier that refers to a defineFragment result\n if (t.isIdentifier(node)) {\n const binding = scope.getBinding(node.name);\n if (binding && binding.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init) {\n return isDefineLibraryChain(init, scope);\n }\n }\n }\n\n return false;\n};\n\nexport function transformDefineLibrary(ast: Node, options: { ssr: boolean }): void {\n if (options.ssr) {\n return;\n }\n\n traverse(ast, {\n CallExpression(path) {\n const { callee } = path.node;\n\n // Check if this is a method call\n if (!t.isMemberExpression(callee)) {\n return;\n }\n\n const { property, object } = callee;\n\n // Check if the method is withDependencies or withServices\n if (!t.isIdentifier(property)) {\n return;\n }\n\n const methodName = property.name;\n if (methodName !== \"withDependencies\" && methodName !== \"withServices\") {\n return;\n }\n\n // Check if this is part of a defineFragment chain\n if (!isDefineLibraryChain(object, path.scope)) {\n return;\n }\n\n // Replace the argument with a no-op function that returns this\n path.node.arguments = [createNoOpArrowFunction()];\n },\n });\n}\n","import * as babel from \"@babel/core\";\nimport { parse } from \"@babel/parser\";\nimport { generate } from \"@babel/generator\";\nimport type { GeneratorResult } from \"@babel/generator\";\n\nimport { deadCodeElimination, findReferencedIdentifiers } from \"babel-dead-code-elimination\";\nimport { transformMacros } from \"./transform-macros\";\nimport { transformDefineRoute } from \"./transform-define-route\";\nimport { transformDefineLibrary } from \"./transform-define-library\";\n\nexport const transform = (code: string, id: string, options: { ssr: boolean }): GeneratorResult => {\n const ast = parse(code, { sourceType: \"module\", plugins: [[\"typescript\", {}]] });\n\n // - https://github.com/babel/babel/issues/11889\n // - https://github.com/babel/babel/issues/11350#issuecomment-606169054\n // @ts-expect-error `@types/babel__core` is missing types for `File`\n new babel.File({ filename: undefined }, { code, ast });\n\n const refs = findReferencedIdentifiers(ast);\n\n transformMacros(ast, options);\n transformDefineRoute(ast, options);\n transformDefineLibrary(ast, options);\n\n deadCodeElimination(ast, refs);\n return generate(ast, { sourceMaps: true, sourceFileName: id }, code);\n};\n","import type { UnpluginFactory } from \"unplugin\";\nimport type { Options } from \"./types\";\nimport { createUnplugin } from \"unplugin\";\nimport { transform } from \"./transform\";\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options = {}) => {\n const { platform } = options;\n\n if (platform !== \"browser\") {\n return [];\n }\n\n return {\n name: \"unplugin-fragno\",\n transformInclude(id) {\n if (id.endsWith(\".d.ts\")) {\n return false;\n }\n\n if (id.includes(\"@fragno-dev/unplugin-fragno\") || id.includes(\"@fragno-dev/core\")) {\n return false;\n }\n\n return true;\n },\n transform(code, id) {\n return transform(code, id, { ssr: false });\n },\n };\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\nexport type { Options };\nexport { isMacroBinding } from \"./transform-macros\";\n"],"mappings":";;;;;;;;;;AAcA,MAAM,kBAAkB,GAAGA,KAAQ;AAEnC,MAAa,kBAAkB,SAAkB,UAA2B;AAC1E,KAAI,CAAC,EAAE,oBAAoB,SAAS,KAAK,OAAO,CAAE,QAAO;AACzD,KAAI,QAAQ,KAAK,OAAO,OAAO,UAAU,gBAAiB,QAAO;AAEjE,KAAI,CAAC,EAAE,kBAAkB,SAAS,KAAK,KAAK,CAAE,QAAO;CACrD,MAAM,EAAE,aAAa,QAAQ,KAAK;AAClC,KAAI,CAAC,EAAE,aAAa,SAAS,CAAE,QAAO;AACtC,KAAI,SAAS,SAAS,MAAO,QAAO;AACpC,QAAO;;AAGT,MAAM,WAA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