zero-com 1.2.0 → 1.4.0

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,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run build:*)",
5
+ "Bash(npm test)"
6
+ ]
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import type { LoaderContext } from 'webpack';
2
+ import { ServerFuncRegistry } from './common';
3
+ export interface ZeroComLoaderOptions {
4
+ registry: ServerFuncRegistry;
5
+ }
6
+ export default function zeroComLoader(this: LoaderContext<ZeroComLoaderOptions>, source: string): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = zeroComLoader;
4
+ const common_1 = require("./common");
5
+ function zeroComLoader(source) {
6
+ const options = this.getOptions();
7
+ const filePath = this.resourcePath;
8
+ const result = (0, common_1.transformSourceFile)(filePath, source, options.registry);
9
+ if (!result.transformed) {
10
+ return source;
11
+ }
12
+ const jsContent = (0, common_1.emitToJs)(filePath, result.content);
13
+ console.log(`[ZeroComWebpackPlugin] Transformed: ${filePath}`);
14
+ return jsContent;
15
+ }
package/lib/webpack.js CHANGED
@@ -1,11 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ZeroComWebpackPlugin = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
4
  const common_1 = require("./common");
10
5
  class ZeroComWebpackPlugin {
11
6
  constructor(options = {}) {
@@ -21,23 +16,18 @@ class ZeroComWebpackPlugin {
21
16
  (0, common_1.buildRegistry)(compiler.context, this.registry);
22
17
  console.log(`[ZeroComWebpackPlugin] Found ${this.registry.size} files with server functions`);
23
18
  });
24
- // Transform files during module resolution
25
- compiler.hooks.normalModuleFactory.tap(pluginName, (nmf) => {
26
- nmf.hooks.beforeResolve.tap(pluginName, (resolveData) => {
27
- if (!resolveData.request.startsWith('.') && !resolveData.request.startsWith('/'))
28
- return;
29
- const resolvedPath = (0, common_1.resolveFilePath)(path_1.default.resolve(resolveData.context, resolveData.request));
30
- if (!resolvedPath || !fs_1.default.existsSync(resolvedPath))
31
- return;
32
- const content = fs_1.default.readFileSync(resolvedPath, 'utf8');
33
- const result = (0, common_1.transformSourceFile)(resolvedPath, content, this.registry);
34
- if (!result.transformed)
35
- return;
36
- const jsContent = (0, common_1.emitToJs)(resolvedPath, result.content);
37
- resolveData.request = `data:text/javascript,${encodeURIComponent(jsContent)}`;
38
- console.log(`[ZeroComWebpackPlugin] Transformed: ${path_1.default.relative(compiler.context, resolvedPath)}`);
39
- });
40
- });
19
+ // Add loader rule for TypeScript/JavaScript files
20
+ const loaderPath = require.resolve('./webpack-loader');
21
+ const loaderRule = {
22
+ test: new RegExp(`\\.(${common_1.FILE_EXTENSIONS.slice(1).map(e => e.slice(1)).join('|')})$`),
23
+ exclude: /node_modules/,
24
+ enforce: 'pre',
25
+ use: [{
26
+ loader: loaderPath,
27
+ options: { registry: this.registry }
28
+ }]
29
+ };
30
+ compiler.options.module.rules.unshift(loaderRule);
41
31
  // Production: minify global names
42
32
  if (this.options.development)
43
33
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zero-com",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/yosbelms/zero-com",
6
6
  "keywords": [
@@ -12,7 +12,7 @@
12
12
  "client"
13
13
  ],
14
14
  "scripts": {
15
- "build": "npx tsc -d",
15
+ "build": "npx tsc -p tsconfig.build.json -d",
16
16
  "test": "vitest run",
17
17
  "test:watch": "vitest",
18
18
  "clean": "find . -type f \\( -name \"*.js\" -o -name \"*.js.map\" -o -name \"*.d.ts\" -o -name \"*.d.ts.map\" \\) | grep -v \"./node_modules\" | xargs rm",
@@ -26,6 +26,7 @@
26
26
  "ts-morph": "^26.0.0"
27
27
  },
28
28
  "devDependencies": {
29
+ "@types/node": "^25.0.10",
29
30
  "@types/webpack": "^5.28.5",
30
31
  "rollup": "^4.52.5",
31
32
  "typescript": "^5.8.3",
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["index.ts", "lib/**/*"],
4
+ "exclude": ["test", "node_modules"]
5
+ }
package/tsconfig.json CHANGED
@@ -103,10 +103,13 @@
103
103
  /* Completeness */
104
104
  // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
105
105
  "skipLibCheck": true, /* Skip type checking all .d.ts files. */
106
+ "types": ["node"],
106
107
  "paths": {
107
108
  "zero-com": [
108
109
  "./index.ts"
109
110
  ]
110
111
  }
111
- }
112
+ },
113
+ "include": ["index.ts", "lib/**/*", "test/**/*"],
114
+ "exclude": ["node_modules"]
112
115
  }