zero-com 1.7.1 → 1.8.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/lib/rollup.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { Plugin } from 'rollup';
2
2
  import { Options } from './common';
3
- export declare function zeroComRollupPlugin(options?: Options): Plugin;
3
+ export declare function zeroComRollupPlugin(options?: Options): Plugin & {
4
+ configResolved?: () => void;
5
+ };
package/lib/rollup.js CHANGED
@@ -20,14 +20,23 @@ function zeroComRollupPlugin(options = {}) {
20
20
  const { development = true } = options;
21
21
  const compilationId = (0, common_1.generateCompilationId)();
22
22
  const registry = new Map();
23
+ let isVite = false;
23
24
  return {
24
25
  name: 'zero-com-rollup-plugin',
26
+ // Vite-only hook — detect that we're running inside Vite
27
+ configResolved() {
28
+ isVite = true;
29
+ },
25
30
  buildStart() {
26
31
  (0, common_1.buildRegistry)(process.cwd(), registry);
27
32
  console.log(`[ZeroComRollupPlugin] Found ${registry.size} files with server functions`);
28
33
  },
34
+ // Rollup path: resolveId marks files, load transforms them.
35
+ // Skipped in Vite because meta doesn't propagate from resolveId to load.
29
36
  resolveId(source, importer, opts) {
30
37
  return __awaiter(this, void 0, void 0, function* () {
38
+ if (isVite)
39
+ return null;
31
40
  if (!importer || (!source.startsWith('.') && !source.startsWith('/')))
32
41
  return null;
33
42
  const result = yield this.resolve(source, importer, Object.assign(Object.assign({}, opts), { skipSelf: true }));
@@ -43,6 +52,8 @@ function zeroComRollupPlugin(options = {}) {
43
52
  },
44
53
  load(id) {
45
54
  var _a, _b, _c;
55
+ if (isVite)
56
+ return null;
46
57
  if (!((_b = (_a = this.getModuleInfo(id)) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.needsTransform) || !fs_1.default.existsSync(id))
47
58
  return null;
48
59
  const content = fs_1.default.readFileSync(id, 'utf8');
@@ -53,6 +64,20 @@ function zeroComRollupPlugin(options = {}) {
53
64
  const code = (0, common_1.emitToJs)(id, result.content);
54
65
  return { code, map: (_c = result.map) !== null && _c !== void 0 ? _c : null };
55
66
  },
67
+ // Vite path: transform hook works reliably (no cross-hook meta needed).
68
+ // Returns transformed TypeScript — Vite's esbuild handles TS→JS.
69
+ transform(code, id) {
70
+ var _a;
71
+ if (!isVite)
72
+ return null;
73
+ if (id.includes('node_modules') || !/\.(ts|tsx|js|jsx|mjs)$/.test(id))
74
+ return null;
75
+ const result = (0, common_1.transformSourceFile)(id, code, registry, { development });
76
+ if (!result.transformed)
77
+ return null;
78
+ console.log(`[ZeroComRollupPlugin] Transformed: ${path_1.default.relative(process.cwd(), id)}`);
79
+ return { code: result.content, map: (_a = result.map) !== null && _a !== void 0 ? _a : null };
80
+ },
56
81
  renderChunk(code) {
57
82
  if (development)
58
83
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zero-com",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/yosbelms/zero-com",
6
6
  "keywords": [