@514labs/moose-lib 0.6.322-ci-9-g72529e37 → 0.6.322-ci-14-ga8e5dacb
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/browserCompatible.js +0 -9
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +0 -9
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js +3 -7
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs +3 -7
- package/dist/dataModels/toDataModels.mjs.map +1 -1
- package/dist/dmv2/index.js +0 -9
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +0 -9
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js +16 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -64
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +57 -140
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +64 -147
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +2 -3
- package/dist/moose-tspc.d.mts +0 -1
- package/dist/moose-tspc.d.ts +0 -1
- package/dist/moose-tspc.js +0 -121
- package/dist/moose-tspc.js.map +0 -1
- package/dist/moose-tspc.mjs +0 -98
- package/dist/moose-tspc.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@514labs/moose-lib",
|
|
3
|
-
"version": "0.6.322-ci-
|
|
3
|
+
"version": "0.6.322-ci-14-ga8e5dacb",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/514-labs/moosestack"
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"bin": {
|
|
28
|
-
"moose-runner": "./dist/moose-runner.js"
|
|
29
|
-
"moose-tspc": "./dist/moose-tspc.js"
|
|
28
|
+
"moose-runner": "./dist/moose-runner.js"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
31
|
"@clickhouse/client": "1.8.1",
|
package/dist/moose-tspc.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/moose-tspc.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/moose-tspc.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// src/moose-tspc.ts
|
|
27
|
-
var import_child_process = require("child_process");
|
|
28
|
-
var import_fs = require("fs");
|
|
29
|
-
var import_path = __toESM(require("path"));
|
|
30
|
-
|
|
31
|
-
// src/compiler-config.ts
|
|
32
|
-
var MOOSE_COMPILER_PLUGINS = [
|
|
33
|
-
{
|
|
34
|
-
transform: "./node_modules/@514labs/moose-lib/dist/compilerPlugin.js",
|
|
35
|
-
transformProgram: true
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
transform: "typia/lib/transform"
|
|
39
|
-
}
|
|
40
|
-
];
|
|
41
|
-
var MOOSE_COMPILER_OPTIONS = {
|
|
42
|
-
experimentalDecorators: true,
|
|
43
|
-
esModuleInterop: true,
|
|
44
|
-
// Disable strict module syntax checking to avoid dual-package type conflicts
|
|
45
|
-
// This prevents errors where the same type imported with different resolution
|
|
46
|
-
// modes (CJS vs ESM) is treated as incompatible
|
|
47
|
-
verbatimModuleSyntax: false
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/moose-tspc.ts
|
|
51
|
-
var outDir = process.argv[2] || ".moose/compiled";
|
|
52
|
-
var projectRoot = process.cwd();
|
|
53
|
-
var tsconfigPath = import_path.default.join(projectRoot, "tsconfig.json");
|
|
54
|
-
var tempTsconfigPath = import_path.default.join(projectRoot, "tsconfig.moose-build.json");
|
|
55
|
-
if (!(0, import_fs.existsSync)(tsconfigPath)) {
|
|
56
|
-
console.error("Error: tsconfig.json not found in", projectRoot);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
console.log(`Compiling TypeScript to ${outDir}...`);
|
|
60
|
-
try {
|
|
61
|
-
const moduleOptions = {
|
|
62
|
-
module: "CommonJS",
|
|
63
|
-
moduleResolution: "Node"
|
|
64
|
-
};
|
|
65
|
-
console.log(
|
|
66
|
-
"Using CommonJS module output for Docker build (avoids ESM import path issues)..."
|
|
67
|
-
);
|
|
68
|
-
const buildTsconfig = {
|
|
69
|
-
extends: "./tsconfig.json",
|
|
70
|
-
compilerOptions: {
|
|
71
|
-
...MOOSE_COMPILER_OPTIONS,
|
|
72
|
-
...moduleOptions,
|
|
73
|
-
plugins: [...MOOSE_COMPILER_PLUGINS],
|
|
74
|
-
// Skip type checking of declaration files to avoid dual-package conflicts
|
|
75
|
-
// This must be in compilerOptions (not just CLI flag) to fully work
|
|
76
|
-
skipLibCheck: true,
|
|
77
|
-
skipDefaultLibCheck: true,
|
|
78
|
-
// Additional settings to handle module resolution conflicts
|
|
79
|
-
allowSyntheticDefaultImports: true,
|
|
80
|
-
// CRITICAL: Emit JavaScript even when there are type errors
|
|
81
|
-
// This is essential for Docker builds where we need compilation to succeed
|
|
82
|
-
// Type errors are acceptable here since the code works at runtime
|
|
83
|
-
noEmitOnError: false
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
(0, import_fs.writeFileSync)(tempTsconfigPath, JSON.stringify(buildTsconfig, null, 2));
|
|
87
|
-
console.log("Created temporary tsconfig with moose plugins...");
|
|
88
|
-
try {
|
|
89
|
-
(0, import_child_process.execSync)(
|
|
90
|
-
`npx tspc -p ${tempTsconfigPath} --outDir ${outDir} --rootDir . --sourceMap --inlineSources`,
|
|
91
|
-
{
|
|
92
|
-
stdio: "inherit",
|
|
93
|
-
cwd: projectRoot
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
console.log("Compilation complete.");
|
|
97
|
-
} catch (compileError) {
|
|
98
|
-
const sourceDir = process.env.MOOSE_SOURCE_DIR || "app";
|
|
99
|
-
const outputIndexPath = import_path.default.join(projectRoot, outDir, sourceDir, "index.js");
|
|
100
|
-
if ((0, import_fs.existsSync)(outputIndexPath)) {
|
|
101
|
-
console.warn(
|
|
102
|
-
"Warning: TypeScript reported errors but files were emitted successfully."
|
|
103
|
-
);
|
|
104
|
-
console.warn(
|
|
105
|
-
"Type errors detected, but continuing with generated JavaScript."
|
|
106
|
-
);
|
|
107
|
-
console.log("Compilation complete (with type errors).");
|
|
108
|
-
} else {
|
|
109
|
-
console.error("Compilation failed - no output files generated.");
|
|
110
|
-
throw compileError;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.error("Build process failed:", error);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
} finally {
|
|
117
|
-
if ((0, import_fs.existsSync)(tempTsconfigPath)) {
|
|
118
|
-
(0, import_fs.unlinkSync)(tempTsconfigPath);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=moose-tspc.js.map
|
package/dist/moose-tspc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/moose-tspc.ts","../src/compiler-config.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Pre-compiles TypeScript app code with moose compiler plugins and typia transforms.\n * Used during Docker build to eliminate ts-node overhead at runtime.\n *\n * Usage: moose-tspc [outDir]\n * outDir: Output directory for compiled files (default: .moose/compiled)\n *\n * This script creates a temporary tsconfig that extends the user's config and adds\n * the required moose compiler plugins, then runs tspc to compile with transforms.\n */\nimport { execSync } from \"child_process\";\nimport { existsSync, writeFileSync, unlinkSync } from \"fs\";\nimport path from \"path\";\nimport {\n MOOSE_COMPILER_PLUGINS,\n MOOSE_COMPILER_OPTIONS,\n} from \"./compiler-config\";\n\nconst outDir = process.argv[2] || \".moose/compiled\";\nconst projectRoot = process.cwd();\nconst tsconfigPath = path.join(projectRoot, \"tsconfig.json\");\nconst tempTsconfigPath = path.join(projectRoot, \"tsconfig.moose-build.json\");\n\nif (!existsSync(tsconfigPath)) {\n console.error(\"Error: tsconfig.json not found in\", projectRoot);\n process.exit(1);\n}\n\nconsole.log(`Compiling TypeScript to ${outDir}...`);\n\ntry {\n // For pre-compiled builds, always use CommonJS to avoid ESM import path issues\n // Node.js ESM requires explicit .js extensions which TypeScript doesn't add\n // CommonJS is simpler and more reliable for Docker builds\n const moduleOptions: Record<string, any> = {\n module: \"CommonJS\",\n moduleResolution: \"Node\",\n };\n console.log(\n \"Using CommonJS module output for Docker build (avoids ESM import path issues)...\",\n );\n\n // Create a temporary tsconfig that extends the user's config and adds plugins.\n // We use extends (not spread) to properly inherit all user settings.\n // Only override what's needed for moose compilation.\n const buildTsconfig = {\n extends: \"./tsconfig.json\",\n compilerOptions: {\n ...MOOSE_COMPILER_OPTIONS,\n ...moduleOptions,\n plugins: [...MOOSE_COMPILER_PLUGINS],\n // Skip type checking of declaration files to avoid dual-package conflicts\n // This must be in compilerOptions (not just CLI flag) to fully work\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n // Additional settings to handle module resolution conflicts\n allowSyntheticDefaultImports: true,\n // CRITICAL: Emit JavaScript even when there are type errors\n // This is essential for Docker builds where we need compilation to succeed\n // Type errors are acceptable here since the code works at runtime\n noEmitOnError: false,\n },\n };\n\n // Write the temporary tsconfig\n writeFileSync(tempTsconfigPath, JSON.stringify(buildTsconfig, null, 2));\n console.log(\"Created temporary tsconfig with moose plugins...\");\n\n // Use tspc (ts-patch compiler CLI) with the temporary tsconfig\n // Include source maps for better error messages in production\n // --rootDir . preserves directory structure (e.g., app/index.ts -> outDir/app/index.js)\n // Note: skipLibCheck and noEmitOnError are in compilerOptions\n try {\n execSync(\n `npx tspc -p ${tempTsconfigPath} --outDir ${outDir} --rootDir . --sourceMap --inlineSources`,\n {\n stdio: \"inherit\",\n cwd: projectRoot,\n },\n );\n console.log(\"Compilation complete.\");\n } catch (compileError: any) {\n // TypeScript might exit with non-zero code even when noEmitOnError: false\n // Check if output files were actually created\n const sourceDir = process.env.MOOSE_SOURCE_DIR || \"app\";\n const outputIndexPath = path.join(projectRoot, outDir, sourceDir, \"index.js\");\n\n if (existsSync(outputIndexPath)) {\n console.warn(\n \"Warning: TypeScript reported errors but files were emitted successfully.\",\n );\n console.warn(\n \"Type errors detected, but continuing with generated JavaScript.\",\n );\n console.log(\"Compilation complete (with type errors).\");\n } else {\n console.error(\"Compilation failed - no output files generated.\");\n throw compileError;\n }\n }\n} catch (error) {\n console.error(\"Build process failed:\", error);\n process.exit(1);\n} finally {\n // Clean up the temporary tsconfig\n if (existsSync(tempTsconfigPath)) {\n unlinkSync(tempTsconfigPath);\n }\n}\n","import { existsSync } from \"fs\";\nimport path from \"path\";\n\n/**\n * Shared TypeScript compiler configuration for moose projects.\n * Used by both moose-runner.ts (runtime) and moose-tspc.ts (pre-compilation).\n *\n * This ensures identical compilation behavior between:\n * - Development: ts-node with plugins (dynamic compilation)\n * - Production: Pre-compiled JavaScript (via moose-tspc)\n */\n\nexport const MOOSE_COMPILER_PLUGINS = [\n {\n transform: \"./node_modules/@514labs/moose-lib/dist/compilerPlugin.js\",\n transformProgram: true,\n },\n {\n transform: \"typia/lib/transform\",\n },\n] as const;\n\n// Options required for moose compilation\n// Note: We only set what's absolutely necessary to avoid conflicts with user projects\nexport const MOOSE_COMPILER_OPTIONS = {\n experimentalDecorators: true,\n esModuleInterop: true,\n // Disable strict module syntax checking to avoid dual-package type conflicts\n // This prevents errors where the same type imported with different resolution\n // modes (CJS vs ESM) is treated as incompatible\n verbatimModuleSyntax: false,\n} as const;\n\n// Module resolution options - only applied if not already set in user's tsconfig\n// These help with ESM/CJS interop but can be overridden by user config\nexport const MOOSE_MODULE_OPTIONS = {\n module: \"NodeNext\",\n moduleResolution: \"NodeNext\",\n} as const;\n\n// Commands that require full plugin compilation (moose transforms + typia)\nexport const COMMANDS_REQUIRING_PLUGINS = [\n \"consumption-apis\",\n \"consumption-type-serializer\",\n \"dmv2-serializer\",\n \"streaming-functions\",\n \"scripts\",\n] as const;\n\n/**\n * Default source directory for user code.\n * Can be overridden via MOOSE_SOURCE_DIR environment variable.\n */\nexport function getSourceDir(): string {\n return process.env.MOOSE_SOURCE_DIR || \"app\";\n}\n\n/**\n * Check if pre-compiled artifacts exist for the current project.\n * Used to determine whether to use compiled code or fall back to ts-node.\n */\nexport function hasCompiledArtifacts(\n projectRoot: string = process.cwd(),\n): boolean {\n const sourceDir = getSourceDir();\n const compiledIndexPath = path.join(\n projectRoot,\n \".moose\",\n \"compiled\",\n sourceDir,\n \"index.js\",\n );\n return existsSync(compiledIndexPath);\n}\n\n/**\n * Determine if we should use pre-compiled code.\n * Returns true if MOOSE_USE_COMPILED=true AND compiled artifacts exist.\n * This provides automatic fallback to ts-node if compilation wasn't run.\n */\nexport function shouldUseCompiled(\n projectRoot: string = process.cwd(),\n): boolean {\n const envSaysCompiled = process.env.MOOSE_USE_COMPILED === \"true\";\n if (!envSaysCompiled) {\n return false;\n }\n\n const hasArtifacts = hasCompiledArtifacts(projectRoot);\n if (!hasArtifacts) {\n console.warn(\n \"[moose] MOOSE_USE_COMPILED=true but no compiled artifacts found at \" +\n `.moose/compiled/${getSourceDir()}/index.js. Falling back to ts-node.`,\n );\n }\n return hasArtifacts;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,2BAAyB;AACzB,gBAAsD;AACtD,kBAAiB;;;ACDV,IAAM,yBAAyB;AAAA,EACpC;AAAA,IACE,WAAW;AAAA,IACX,kBAAkB;AAAA,EACpB;AAAA,EACA;AAAA,IACE,WAAW;AAAA,EACb;AACF;AAIO,IAAM,yBAAyB;AAAA,EACpC,wBAAwB;AAAA,EACxB,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIjB,sBAAsB;AACxB;;;ADZA,IAAM,SAAS,QAAQ,KAAK,CAAC,KAAK;AAClC,IAAM,cAAc,QAAQ,IAAI;AAChC,IAAM,eAAe,YAAAA,QAAK,KAAK,aAAa,eAAe;AAC3D,IAAM,mBAAmB,YAAAA,QAAK,KAAK,aAAa,2BAA2B;AAE3E,IAAI,KAAC,sBAAW,YAAY,GAAG;AAC7B,UAAQ,MAAM,qCAAqC,WAAW;AAC9D,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,IAAI,2BAA2B,MAAM,KAAK;AAElD,IAAI;AAIF,QAAM,gBAAqC;AAAA,IACzC,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB;AACA,UAAQ;AAAA,IACN;AAAA,EACF;AAKA,QAAM,gBAAgB;AAAA,IACpB,SAAS;AAAA,IACT,iBAAiB;AAAA,MACf,GAAG;AAAA,MACH,GAAG;AAAA,MACH,SAAS,CAAC,GAAG,sBAAsB;AAAA;AAAA;AAAA,MAGnC,cAAc;AAAA,MACd,qBAAqB;AAAA;AAAA,MAErB,8BAA8B;AAAA;AAAA;AAAA;AAAA,MAI9B,eAAe;AAAA,IACjB;AAAA,EACF;AAGA,+BAAc,kBAAkB,KAAK,UAAU,eAAe,MAAM,CAAC,CAAC;AACtE,UAAQ,IAAI,kDAAkD;AAM9D,MAAI;AACF;AAAA,MACE,eAAe,gBAAgB,aAAa,MAAM;AAAA,MAClD;AAAA,QACE,OAAO;AAAA,QACP,KAAK;AAAA,MACP;AAAA,IACF;AACA,YAAQ,IAAI,uBAAuB;AAAA,EACrC,SAAS,cAAmB;AAG1B,UAAM,YAAY,QAAQ,IAAI,oBAAoB;AAClD,UAAM,kBAAkB,YAAAA,QAAK,KAAK,aAAa,QAAQ,WAAW,UAAU;AAE5E,YAAI,sBAAW,eAAe,GAAG;AAC/B,cAAQ;AAAA,QACN;AAAA,MACF;AACA,cAAQ;AAAA,QACN;AAAA,MACF;AACA,cAAQ,IAAI,0CAA0C;AAAA,IACxD,OAAO;AACL,cAAQ,MAAM,iDAAiD;AAC/D,YAAM;AAAA,IACR;AAAA,EACF;AACF,SAAS,OAAO;AACd,UAAQ,MAAM,yBAAyB,KAAK;AAC5C,UAAQ,KAAK,CAAC;AAChB,UAAE;AAEA,UAAI,sBAAW,gBAAgB,GAAG;AAChC,8BAAW,gBAAgB;AAAA,EAC7B;AACF;","names":["path"]}
|
package/dist/moose-tspc.mjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/moose-tspc.ts
|
|
4
|
-
import { execSync } from "child_process";
|
|
5
|
-
import { existsSync, writeFileSync, unlinkSync } from "fs";
|
|
6
|
-
import path from "path";
|
|
7
|
-
|
|
8
|
-
// src/compiler-config.ts
|
|
9
|
-
var MOOSE_COMPILER_PLUGINS = [
|
|
10
|
-
{
|
|
11
|
-
transform: "./node_modules/@514labs/moose-lib/dist/compilerPlugin.js",
|
|
12
|
-
transformProgram: true
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
transform: "typia/lib/transform"
|
|
16
|
-
}
|
|
17
|
-
];
|
|
18
|
-
var MOOSE_COMPILER_OPTIONS = {
|
|
19
|
-
experimentalDecorators: true,
|
|
20
|
-
esModuleInterop: true,
|
|
21
|
-
// Disable strict module syntax checking to avoid dual-package type conflicts
|
|
22
|
-
// This prevents errors where the same type imported with different resolution
|
|
23
|
-
// modes (CJS vs ESM) is treated as incompatible
|
|
24
|
-
verbatimModuleSyntax: false
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// src/moose-tspc.ts
|
|
28
|
-
var outDir = process.argv[2] || ".moose/compiled";
|
|
29
|
-
var projectRoot = process.cwd();
|
|
30
|
-
var tsconfigPath = path.join(projectRoot, "tsconfig.json");
|
|
31
|
-
var tempTsconfigPath = path.join(projectRoot, "tsconfig.moose-build.json");
|
|
32
|
-
if (!existsSync(tsconfigPath)) {
|
|
33
|
-
console.error("Error: tsconfig.json not found in", projectRoot);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
console.log(`Compiling TypeScript to ${outDir}...`);
|
|
37
|
-
try {
|
|
38
|
-
const moduleOptions = {
|
|
39
|
-
module: "CommonJS",
|
|
40
|
-
moduleResolution: "Node"
|
|
41
|
-
};
|
|
42
|
-
console.log(
|
|
43
|
-
"Using CommonJS module output for Docker build (avoids ESM import path issues)..."
|
|
44
|
-
);
|
|
45
|
-
const buildTsconfig = {
|
|
46
|
-
extends: "./tsconfig.json",
|
|
47
|
-
compilerOptions: {
|
|
48
|
-
...MOOSE_COMPILER_OPTIONS,
|
|
49
|
-
...moduleOptions,
|
|
50
|
-
plugins: [...MOOSE_COMPILER_PLUGINS],
|
|
51
|
-
// Skip type checking of declaration files to avoid dual-package conflicts
|
|
52
|
-
// This must be in compilerOptions (not just CLI flag) to fully work
|
|
53
|
-
skipLibCheck: true,
|
|
54
|
-
skipDefaultLibCheck: true,
|
|
55
|
-
// Additional settings to handle module resolution conflicts
|
|
56
|
-
allowSyntheticDefaultImports: true,
|
|
57
|
-
// CRITICAL: Emit JavaScript even when there are type errors
|
|
58
|
-
// This is essential for Docker builds where we need compilation to succeed
|
|
59
|
-
// Type errors are acceptable here since the code works at runtime
|
|
60
|
-
noEmitOnError: false
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
writeFileSync(tempTsconfigPath, JSON.stringify(buildTsconfig, null, 2));
|
|
64
|
-
console.log("Created temporary tsconfig with moose plugins...");
|
|
65
|
-
try {
|
|
66
|
-
execSync(
|
|
67
|
-
`npx tspc -p ${tempTsconfigPath} --outDir ${outDir} --rootDir . --sourceMap --inlineSources`,
|
|
68
|
-
{
|
|
69
|
-
stdio: "inherit",
|
|
70
|
-
cwd: projectRoot
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
console.log("Compilation complete.");
|
|
74
|
-
} catch (compileError) {
|
|
75
|
-
const sourceDir = process.env.MOOSE_SOURCE_DIR || "app";
|
|
76
|
-
const outputIndexPath = path.join(projectRoot, outDir, sourceDir, "index.js");
|
|
77
|
-
if (existsSync(outputIndexPath)) {
|
|
78
|
-
console.warn(
|
|
79
|
-
"Warning: TypeScript reported errors but files were emitted successfully."
|
|
80
|
-
);
|
|
81
|
-
console.warn(
|
|
82
|
-
"Type errors detected, but continuing with generated JavaScript."
|
|
83
|
-
);
|
|
84
|
-
console.log("Compilation complete (with type errors).");
|
|
85
|
-
} else {
|
|
86
|
-
console.error("Compilation failed - no output files generated.");
|
|
87
|
-
throw compileError;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error("Build process failed:", error);
|
|
92
|
-
process.exit(1);
|
|
93
|
-
} finally {
|
|
94
|
-
if (existsSync(tempTsconfigPath)) {
|
|
95
|
-
unlinkSync(tempTsconfigPath);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=moose-tspc.mjs.map
|
package/dist/moose-tspc.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/moose-tspc.ts","../src/compiler-config.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Pre-compiles TypeScript app code with moose compiler plugins and typia transforms.\n * Used during Docker build to eliminate ts-node overhead at runtime.\n *\n * Usage: moose-tspc [outDir]\n * outDir: Output directory for compiled files (default: .moose/compiled)\n *\n * This script creates a temporary tsconfig that extends the user's config and adds\n * the required moose compiler plugins, then runs tspc to compile with transforms.\n */\nimport { execSync } from \"child_process\";\nimport { existsSync, writeFileSync, unlinkSync } from \"fs\";\nimport path from \"path\";\nimport {\n MOOSE_COMPILER_PLUGINS,\n MOOSE_COMPILER_OPTIONS,\n} from \"./compiler-config\";\n\nconst outDir = process.argv[2] || \".moose/compiled\";\nconst projectRoot = process.cwd();\nconst tsconfigPath = path.join(projectRoot, \"tsconfig.json\");\nconst tempTsconfigPath = path.join(projectRoot, \"tsconfig.moose-build.json\");\n\nif (!existsSync(tsconfigPath)) {\n console.error(\"Error: tsconfig.json not found in\", projectRoot);\n process.exit(1);\n}\n\nconsole.log(`Compiling TypeScript to ${outDir}...`);\n\ntry {\n // For pre-compiled builds, always use CommonJS to avoid ESM import path issues\n // Node.js ESM requires explicit .js extensions which TypeScript doesn't add\n // CommonJS is simpler and more reliable for Docker builds\n const moduleOptions: Record<string, any> = {\n module: \"CommonJS\",\n moduleResolution: \"Node\",\n };\n console.log(\n \"Using CommonJS module output for Docker build (avoids ESM import path issues)...\",\n );\n\n // Create a temporary tsconfig that extends the user's config and adds plugins.\n // We use extends (not spread) to properly inherit all user settings.\n // Only override what's needed for moose compilation.\n const buildTsconfig = {\n extends: \"./tsconfig.json\",\n compilerOptions: {\n ...MOOSE_COMPILER_OPTIONS,\n ...moduleOptions,\n plugins: [...MOOSE_COMPILER_PLUGINS],\n // Skip type checking of declaration files to avoid dual-package conflicts\n // This must be in compilerOptions (not just CLI flag) to fully work\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n // Additional settings to handle module resolution conflicts\n allowSyntheticDefaultImports: true,\n // CRITICAL: Emit JavaScript even when there are type errors\n // This is essential for Docker builds where we need compilation to succeed\n // Type errors are acceptable here since the code works at runtime\n noEmitOnError: false,\n },\n };\n\n // Write the temporary tsconfig\n writeFileSync(tempTsconfigPath, JSON.stringify(buildTsconfig, null, 2));\n console.log(\"Created temporary tsconfig with moose plugins...\");\n\n // Use tspc (ts-patch compiler CLI) with the temporary tsconfig\n // Include source maps for better error messages in production\n // --rootDir . preserves directory structure (e.g., app/index.ts -> outDir/app/index.js)\n // Note: skipLibCheck and noEmitOnError are in compilerOptions\n try {\n execSync(\n `npx tspc -p ${tempTsconfigPath} --outDir ${outDir} --rootDir . --sourceMap --inlineSources`,\n {\n stdio: \"inherit\",\n cwd: projectRoot,\n },\n );\n console.log(\"Compilation complete.\");\n } catch (compileError: any) {\n // TypeScript might exit with non-zero code even when noEmitOnError: false\n // Check if output files were actually created\n const sourceDir = process.env.MOOSE_SOURCE_DIR || \"app\";\n const outputIndexPath = path.join(projectRoot, outDir, sourceDir, \"index.js\");\n\n if (existsSync(outputIndexPath)) {\n console.warn(\n \"Warning: TypeScript reported errors but files were emitted successfully.\",\n );\n console.warn(\n \"Type errors detected, but continuing with generated JavaScript.\",\n );\n console.log(\"Compilation complete (with type errors).\");\n } else {\n console.error(\"Compilation failed - no output files generated.\");\n throw compileError;\n }\n }\n} catch (error) {\n console.error(\"Build process failed:\", error);\n process.exit(1);\n} finally {\n // Clean up the temporary tsconfig\n if (existsSync(tempTsconfigPath)) {\n unlinkSync(tempTsconfigPath);\n }\n}\n","import { existsSync } from \"fs\";\nimport path from \"path\";\n\n/**\n * Shared TypeScript compiler configuration for moose projects.\n * Used by both moose-runner.ts (runtime) and moose-tspc.ts (pre-compilation).\n *\n * This ensures identical compilation behavior between:\n * - Development: ts-node with plugins (dynamic compilation)\n * - Production: Pre-compiled JavaScript (via moose-tspc)\n */\n\nexport const MOOSE_COMPILER_PLUGINS = [\n {\n transform: \"./node_modules/@514labs/moose-lib/dist/compilerPlugin.js\",\n transformProgram: true,\n },\n {\n transform: \"typia/lib/transform\",\n },\n] as const;\n\n// Options required for moose compilation\n// Note: We only set what's absolutely necessary to avoid conflicts with user projects\nexport const MOOSE_COMPILER_OPTIONS = {\n experimentalDecorators: true,\n esModuleInterop: true,\n // Disable strict module syntax checking to avoid dual-package type conflicts\n // This prevents errors where the same type imported with different resolution\n // modes (CJS vs ESM) is treated as incompatible\n verbatimModuleSyntax: false,\n} as const;\n\n// Module resolution options - only applied if not already set in user's tsconfig\n// These help with ESM/CJS interop but can be overridden by user config\nexport const MOOSE_MODULE_OPTIONS = {\n module: \"NodeNext\",\n moduleResolution: \"NodeNext\",\n} as const;\n\n// Commands that require full plugin compilation (moose transforms + typia)\nexport const COMMANDS_REQUIRING_PLUGINS = [\n \"consumption-apis\",\n \"consumption-type-serializer\",\n \"dmv2-serializer\",\n \"streaming-functions\",\n \"scripts\",\n] as const;\n\n/**\n * Default source directory for user code.\n * Can be overridden via MOOSE_SOURCE_DIR environment variable.\n */\nexport function getSourceDir(): string {\n return process.env.MOOSE_SOURCE_DIR || \"app\";\n}\n\n/**\n * Check if pre-compiled artifacts exist for the current project.\n * Used to determine whether to use compiled code or fall back to ts-node.\n */\nexport function hasCompiledArtifacts(\n projectRoot: string = process.cwd(),\n): boolean {\n const sourceDir = getSourceDir();\n const compiledIndexPath = path.join(\n projectRoot,\n \".moose\",\n \"compiled\",\n sourceDir,\n \"index.js\",\n );\n return existsSync(compiledIndexPath);\n}\n\n/**\n * Determine if we should use pre-compiled code.\n * Returns true if MOOSE_USE_COMPILED=true AND compiled artifacts exist.\n * This provides automatic fallback to ts-node if compilation wasn't run.\n */\nexport function shouldUseCompiled(\n projectRoot: string = process.cwd(),\n): boolean {\n const envSaysCompiled = process.env.MOOSE_USE_COMPILED === \"true\";\n if (!envSaysCompiled) {\n return false;\n }\n\n const hasArtifacts = hasCompiledArtifacts(projectRoot);\n if (!hasArtifacts) {\n console.warn(\n \"[moose] MOOSE_USE_COMPILED=true but no compiled artifacts found at \" +\n `.moose/compiled/${getSourceDir()}/index.js. Falling back to ts-node.`,\n );\n }\n return hasArtifacts;\n}\n"],"mappings":";;;AAWA,SAAS,gBAAgB;AACzB,SAAS,YAAY,eAAe,kBAAkB;AACtD,OAAO,UAAU;;;ACDV,IAAM,yBAAyB;AAAA,EACpC;AAAA,IACE,WAAW;AAAA,IACX,kBAAkB;AAAA,EACpB;AAAA,EACA;AAAA,IACE,WAAW;AAAA,EACb;AACF;AAIO,IAAM,yBAAyB;AAAA,EACpC,wBAAwB;AAAA,EACxB,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIjB,sBAAsB;AACxB;;;ADZA,IAAM,SAAS,QAAQ,KAAK,CAAC,KAAK;AAClC,IAAM,cAAc,QAAQ,IAAI;AAChC,IAAM,eAAe,KAAK,KAAK,aAAa,eAAe;AAC3D,IAAM,mBAAmB,KAAK,KAAK,aAAa,2BAA2B;AAE3E,IAAI,CAAC,WAAW,YAAY,GAAG;AAC7B,UAAQ,MAAM,qCAAqC,WAAW;AAC9D,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,IAAI,2BAA2B,MAAM,KAAK;AAElD,IAAI;AAIF,QAAM,gBAAqC;AAAA,IACzC,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB;AACA,UAAQ;AAAA,IACN;AAAA,EACF;AAKA,QAAM,gBAAgB;AAAA,IACpB,SAAS;AAAA,IACT,iBAAiB;AAAA,MACf,GAAG;AAAA,MACH,GAAG;AAAA,MACH,SAAS,CAAC,GAAG,sBAAsB;AAAA;AAAA;AAAA,MAGnC,cAAc;AAAA,MACd,qBAAqB;AAAA;AAAA,MAErB,8BAA8B;AAAA;AAAA;AAAA;AAAA,MAI9B,eAAe;AAAA,IACjB;AAAA,EACF;AAGA,gBAAc,kBAAkB,KAAK,UAAU,eAAe,MAAM,CAAC,CAAC;AACtE,UAAQ,IAAI,kDAAkD;AAM9D,MAAI;AACF;AAAA,MACE,eAAe,gBAAgB,aAAa,MAAM;AAAA,MAClD;AAAA,QACE,OAAO;AAAA,QACP,KAAK;AAAA,MACP;AAAA,IACF;AACA,YAAQ,IAAI,uBAAuB;AAAA,EACrC,SAAS,cAAmB;AAG1B,UAAM,YAAY,QAAQ,IAAI,oBAAoB;AAClD,UAAM,kBAAkB,KAAK,KAAK,aAAa,QAAQ,WAAW,UAAU;AAE5E,QAAI,WAAW,eAAe,GAAG;AAC/B,cAAQ;AAAA,QACN;AAAA,MACF;AACA,cAAQ;AAAA,QACN;AAAA,MACF;AACA,cAAQ,IAAI,0CAA0C;AAAA,IACxD,OAAO;AACL,cAAQ,MAAM,iDAAiD;AAC/D,YAAM;AAAA,IACR;AAAA,EACF;AACF,SAAS,OAAO;AACd,UAAQ,MAAM,yBAAyB,KAAK;AAC5C,UAAQ,KAAK,CAAC;AAChB,UAAE;AAEA,MAAI,WAAW,gBAAgB,GAAG;AAChC,eAAW,gBAAgB;AAAA,EAC7B;AACF;","names":[]}
|