@vendure/dashboard 3.4.1-master-202508020237 → 3.4.1-master-202508040248
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/vite/utils/schema-generator.js +17 -12
- package/package.json +154 -155
- package/vite/constants.ts +0 -280
- package/vite/index.ts +0 -1
- package/vite/tests/barrel-exports.spec.ts +0 -30
- package/vite/tests/fixtures-barrel-exports/my-plugin/index.ts +0 -1
- package/vite/tests/fixtures-barrel-exports/my-plugin/src/my.plugin.ts +0 -8
- package/vite/tests/fixtures-barrel-exports/package.json +0 -6
- package/vite/tests/fixtures-barrel-exports/vendure-config.ts +0 -19
- package/vite/tests/fixtures-npm-plugin/fake_node_modules/test-plugin/index.js +0 -20
- package/vite/tests/fixtures-npm-plugin/fake_node_modules/test-plugin/package.json +0 -8
- package/vite/tests/fixtures-npm-plugin/package.json +0 -6
- package/vite/tests/fixtures-npm-plugin/vendure-config.ts +0 -18
- package/vite/tests/fixtures-path-alias/js-aliased/index.ts +0 -1
- package/vite/tests/fixtures-path-alias/js-aliased/src/js-aliased.plugin.ts +0 -8
- package/vite/tests/fixtures-path-alias/package.json +0 -6
- package/vite/tests/fixtures-path-alias/star-aliased/index.ts +0 -1
- package/vite/tests/fixtures-path-alias/star-aliased/src/star-aliased.plugin.ts +0 -8
- package/vite/tests/fixtures-path-alias/ts-aliased/index.ts +0 -1
- package/vite/tests/fixtures-path-alias/ts-aliased/src/ts-aliased.plugin.ts +0 -8
- package/vite/tests/fixtures-path-alias/vendure-config.ts +0 -20
- package/vite/tests/npm-plugin.spec.ts +0 -46
- package/vite/tests/path-alias.spec.ts +0 -61
- package/vite/tests/tsconfig.json +0 -21
- package/vite/types.ts +0 -44
- package/vite/utils/ast-utils.spec.ts +0 -49
- package/vite/utils/ast-utils.ts +0 -33
- package/vite/utils/compiler.ts +0 -244
- package/vite/utils/config-loader.ts +0 -0
- package/vite/utils/logger.ts +0 -43
- package/vite/utils/plugin-discovery.ts +0 -494
- package/vite/utils/schema-generator.ts +0 -45
- package/vite/utils/tsconfig-utils.ts +0 -79
- package/vite/utils/ui-config.ts +0 -52
- package/vite/vite-plugin-admin-api-schema.ts +0 -131
- package/vite/vite-plugin-config-loader.ts +0 -84
- package/vite/vite-plugin-config.ts +0 -70
- package/vite/vite-plugin-dashboard-metadata.ts +0 -73
- package/vite/vite-plugin-gql-tada.ts +0 -62
- package/vite/vite-plugin-tailwind-source.ts +0 -81
- package/vite/vite-plugin-theme.ts +0 -195
- package/vite/vite-plugin-transform-index.ts +0 -40
- package/vite/vite-plugin-ui-config.ts +0 -163
- package/vite/vite-plugin-vendure-dashboard.ts +0 -174
package/vite/utils/compiler.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { VendureConfig } from '@vendure/core';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import tsConfigPaths from 'tsconfig-paths';
|
|
5
|
-
import { RegisterParams } from 'tsconfig-paths/lib/register.js';
|
|
6
|
-
import * as ts from 'typescript';
|
|
7
|
-
import { pathToFileURL } from 'url';
|
|
8
|
-
|
|
9
|
-
import { Logger, PathAdapter, PluginInfo } from '../types.js';
|
|
10
|
-
|
|
11
|
-
import { findConfigExport } from './ast-utils.js';
|
|
12
|
-
import { noopLogger } from './logger.js';
|
|
13
|
-
import { discoverPlugins } from './plugin-discovery.js';
|
|
14
|
-
import { findTsConfigPaths } from './tsconfig-utils.js';
|
|
15
|
-
|
|
16
|
-
const defaultPathAdapter: Required<PathAdapter> = {
|
|
17
|
-
getCompiledConfigPath: ({ outputPath, configFileName }) => path.join(outputPath, configFileName),
|
|
18
|
-
transformTsConfigPathMappings: ({ patterns }) => patterns,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface PackageScannerConfig {
|
|
22
|
-
nodeModulesRoot?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CompilerOptions {
|
|
26
|
-
vendureConfigPath: string;
|
|
27
|
-
outputPath: string;
|
|
28
|
-
pathAdapter?: PathAdapter;
|
|
29
|
-
logger?: Logger;
|
|
30
|
-
pluginPackageScanner?: PackageScannerConfig;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface CompileResult {
|
|
34
|
-
vendureConfig: VendureConfig;
|
|
35
|
-
exportedSymbolName: string;
|
|
36
|
-
pluginInfo: PluginInfo[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Compiles TypeScript files and discovers Vendure plugins in both the compiled output
|
|
41
|
-
* and in node_modules.
|
|
42
|
-
*/
|
|
43
|
-
export async function compile(options: CompilerOptions): Promise<CompileResult> {
|
|
44
|
-
const { vendureConfigPath, outputPath, pathAdapter, logger = noopLogger, pluginPackageScanner } = options;
|
|
45
|
-
const getCompiledConfigPath =
|
|
46
|
-
pathAdapter?.getCompiledConfigPath ?? defaultPathAdapter.getCompiledConfigPath;
|
|
47
|
-
const transformTsConfigPathMappings =
|
|
48
|
-
pathAdapter?.transformTsConfigPathMappings ?? defaultPathAdapter.transformTsConfigPathMappings;
|
|
49
|
-
|
|
50
|
-
// 1. Compile TypeScript files
|
|
51
|
-
const compileStart = Date.now();
|
|
52
|
-
await compileTypeScript({
|
|
53
|
-
inputPath: vendureConfigPath,
|
|
54
|
-
outputPath,
|
|
55
|
-
logger,
|
|
56
|
-
transformTsConfigPathMappings,
|
|
57
|
-
});
|
|
58
|
-
logger.info(`TypeScript compilation completed in ${Date.now() - compileStart}ms`);
|
|
59
|
-
|
|
60
|
-
// 2. Discover plugins
|
|
61
|
-
const analyzePluginsStart = Date.now();
|
|
62
|
-
const plugins = await discoverPlugins({
|
|
63
|
-
vendureConfigPath,
|
|
64
|
-
transformTsConfigPathMappings,
|
|
65
|
-
logger,
|
|
66
|
-
outputPath,
|
|
67
|
-
pluginPackageScanner,
|
|
68
|
-
});
|
|
69
|
-
logger.info(
|
|
70
|
-
`Analyzed plugins and found ${plugins.length} dashboard extensions in ${Date.now() - analyzePluginsStart}ms`,
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
// 3. Load the compiled config
|
|
74
|
-
const configFileName = path.basename(vendureConfigPath);
|
|
75
|
-
const compiledConfigFilePath = pathToFileURL(
|
|
76
|
-
getCompiledConfigPath({
|
|
77
|
-
inputRootDir: path.dirname(vendureConfigPath),
|
|
78
|
-
outputPath,
|
|
79
|
-
configFileName,
|
|
80
|
-
}),
|
|
81
|
-
).href.replace(/.ts$/, '.js');
|
|
82
|
-
|
|
83
|
-
// Create package.json with type commonjs
|
|
84
|
-
await fs.writeFile(
|
|
85
|
-
path.join(outputPath, 'package.json'),
|
|
86
|
-
JSON.stringify({ type: 'commonjs', private: true }, null, 2),
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
// Find the exported config symbol
|
|
90
|
-
const sourceFile = ts.createSourceFile(
|
|
91
|
-
vendureConfigPath,
|
|
92
|
-
await fs.readFile(vendureConfigPath, 'utf-8'),
|
|
93
|
-
ts.ScriptTarget.Latest,
|
|
94
|
-
true,
|
|
95
|
-
);
|
|
96
|
-
const exportedSymbolName = findConfigExport(sourceFile);
|
|
97
|
-
if (!exportedSymbolName) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
`Could not find a variable exported as VendureConfig. Please specify the name of the exported variable.`,
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const loadConfigStart = Date.now();
|
|
104
|
-
|
|
105
|
-
await registerTsConfigPaths({
|
|
106
|
-
outputPath,
|
|
107
|
-
configPath: vendureConfigPath,
|
|
108
|
-
logger,
|
|
109
|
-
phase: 'loading',
|
|
110
|
-
transformTsConfigPathMappings,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
let config: any;
|
|
114
|
-
try {
|
|
115
|
-
config = await import(compiledConfigFilePath).then(m => m[exportedSymbolName]);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
logger.error(`Error loading config: ${e instanceof Error ? e.message : String(e)}`);
|
|
118
|
-
}
|
|
119
|
-
if (!config) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
`Could not find a variable exported as VendureConfig with the name "${exportedSymbolName}".`,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
logger.debug(`Loaded config in ${Date.now() - loadConfigStart}ms`);
|
|
125
|
-
|
|
126
|
-
return { vendureConfig: config, exportedSymbolName, pluginInfo: plugins };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Compiles TypeScript files to JavaScript
|
|
131
|
-
*/
|
|
132
|
-
async function compileTypeScript({
|
|
133
|
-
inputPath,
|
|
134
|
-
outputPath,
|
|
135
|
-
logger,
|
|
136
|
-
transformTsConfigPathMappings,
|
|
137
|
-
}: {
|
|
138
|
-
inputPath: string;
|
|
139
|
-
outputPath: string;
|
|
140
|
-
logger: Logger;
|
|
141
|
-
transformTsConfigPathMappings: Required<PathAdapter>['transformTsConfigPathMappings'];
|
|
142
|
-
}): Promise<void> {
|
|
143
|
-
await fs.ensureDir(outputPath);
|
|
144
|
-
|
|
145
|
-
// Find tsconfig paths first
|
|
146
|
-
const tsConfigInfo = await findTsConfigPaths(
|
|
147
|
-
inputPath,
|
|
148
|
-
logger,
|
|
149
|
-
'compiling',
|
|
150
|
-
transformTsConfigPathMappings,
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
const compilerOptions: ts.CompilerOptions = {
|
|
154
|
-
target: ts.ScriptTarget.ES2020,
|
|
155
|
-
module: ts.ModuleKind.CommonJS,
|
|
156
|
-
moduleResolution: ts.ModuleResolutionKind.Node10, // More explicit CJS resolution
|
|
157
|
-
experimentalDecorators: true,
|
|
158
|
-
emitDecoratorMetadata: true,
|
|
159
|
-
esModuleInterop: true,
|
|
160
|
-
skipLibCheck: true,
|
|
161
|
-
noEmit: false,
|
|
162
|
-
// Speed optimizations
|
|
163
|
-
noEmitOnError: false, // Emit output even if there are errors
|
|
164
|
-
noImplicitAny: false, // Don't require implicit any
|
|
165
|
-
noUnusedLocals: false, // Don't check for unused locals
|
|
166
|
-
noUnusedParameters: false, // Don't check for unused parameters
|
|
167
|
-
allowJs: true,
|
|
168
|
-
checkJs: false, // Don't type check JS files
|
|
169
|
-
skipDefaultLibCheck: true, // Skip checking .d.ts files
|
|
170
|
-
isolatedModules: false, // Need to check cross-file references to compile dependencies
|
|
171
|
-
incremental: false, // Don't use incremental compilation (faster for one-off builds)
|
|
172
|
-
resolveJsonModule: true,
|
|
173
|
-
preserveSymlinks: false,
|
|
174
|
-
outDir: outputPath,
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
logger.debug(`Compiling ${inputPath} to ${outputPath} using TypeScript...`);
|
|
178
|
-
|
|
179
|
-
// Add path mappings if found
|
|
180
|
-
if (tsConfigInfo) {
|
|
181
|
-
// We need to set baseUrl and paths for TypeScript to resolve the imports
|
|
182
|
-
compilerOptions.baseUrl = tsConfigInfo.baseUrl;
|
|
183
|
-
compilerOptions.paths = tsConfigInfo.paths;
|
|
184
|
-
// This is critical - it tells TypeScript to preserve the paths in the output
|
|
185
|
-
// compilerOptions.rootDir = tsConfigInfo.baseUrl;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
logger.debug(`tsConfig paths: ${JSON.stringify(tsConfigInfo?.paths, null, 2)}`);
|
|
189
|
-
logger.debug(`tsConfig baseUrl: ${tsConfigInfo?.baseUrl ?? 'UNKNOWN'}`);
|
|
190
|
-
|
|
191
|
-
// Create a custom transformer to rewrite the output paths
|
|
192
|
-
const customTransformers: ts.CustomTransformers = {
|
|
193
|
-
after: [
|
|
194
|
-
context => {
|
|
195
|
-
return sourceFile => {
|
|
196
|
-
// Only transform files that are not the entry point
|
|
197
|
-
if (sourceFile.fileName === inputPath) {
|
|
198
|
-
return sourceFile;
|
|
199
|
-
}
|
|
200
|
-
sourceFile.fileName = path.join(outputPath, path.basename(sourceFile.fileName));
|
|
201
|
-
return sourceFile;
|
|
202
|
-
};
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const program = ts.createProgram([inputPath], compilerOptions);
|
|
208
|
-
const emitResult = program.emit(undefined, undefined, undefined, undefined, customTransformers);
|
|
209
|
-
|
|
210
|
-
// Only log actual emit errors, not type errors
|
|
211
|
-
if (emitResult.emitSkipped) {
|
|
212
|
-
for (const diagnostic of emitResult.diagnostics) {
|
|
213
|
-
if (diagnostic.file && diagnostic.start !== undefined) {
|
|
214
|
-
const { line, character } = ts.getLineAndCharacterOfPosition(
|
|
215
|
-
diagnostic.file,
|
|
216
|
-
diagnostic.start,
|
|
217
|
-
);
|
|
218
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
219
|
-
logger.warn(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
220
|
-
} else {
|
|
221
|
-
logger.warn(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'));
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
async function registerTsConfigPaths(options: {
|
|
228
|
-
outputPath: string;
|
|
229
|
-
configPath: string;
|
|
230
|
-
logger: Logger;
|
|
231
|
-
phase: 'compiling' | 'loading';
|
|
232
|
-
transformTsConfigPathMappings: Required<PathAdapter>['transformTsConfigPathMappings'];
|
|
233
|
-
}) {
|
|
234
|
-
const { outputPath, configPath, logger, phase, transformTsConfigPathMappings } = options;
|
|
235
|
-
const tsConfigInfo = await findTsConfigPaths(configPath, logger, phase, transformTsConfigPathMappings);
|
|
236
|
-
if (tsConfigInfo) {
|
|
237
|
-
const params: RegisterParams = {
|
|
238
|
-
baseUrl: outputPath,
|
|
239
|
-
paths: tsConfigInfo.paths,
|
|
240
|
-
};
|
|
241
|
-
logger.debug(`Registering tsconfig paths: ${JSON.stringify(params, null, 2)}`);
|
|
242
|
-
tsConfigPaths.register(params);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
File without changes
|
package/vite/utils/logger.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../types.js';
|
|
2
|
-
|
|
3
|
-
// ANSI color codes
|
|
4
|
-
const colors = {
|
|
5
|
-
grey: '\x1b[90m',
|
|
6
|
-
red: '\x1b[31m',
|
|
7
|
-
yellow: '\x1b[33m',
|
|
8
|
-
reset: '\x1b[0m',
|
|
9
|
-
} as const;
|
|
10
|
-
|
|
11
|
-
export const debugLogger: Logger = {
|
|
12
|
-
info: (message: string) => {
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
console.log(`[INFO] ${message}`);
|
|
15
|
-
},
|
|
16
|
-
warn: (message: string) => {
|
|
17
|
-
// eslint-disable-next-line no-console
|
|
18
|
-
console.warn(`${colors.yellow}[WARN] ${message}${colors.reset}`);
|
|
19
|
-
},
|
|
20
|
-
debug: (message: string) => {
|
|
21
|
-
// eslint-disable-next-line no-console
|
|
22
|
-
console.debug(`${colors.grey}[DEBUG] ${message}${colors.reset}`);
|
|
23
|
-
},
|
|
24
|
-
error: (message: string) => {
|
|
25
|
-
// eslint-disable-next-line no-console
|
|
26
|
-
console.error(`${colors.red}[ERROR] ${message}${colors.reset}`);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const noopLogger: Logger = {
|
|
31
|
-
info: () => {
|
|
32
|
-
/* noop */
|
|
33
|
-
},
|
|
34
|
-
warn: () => {
|
|
35
|
-
/* noop */
|
|
36
|
-
},
|
|
37
|
-
debug: () => {
|
|
38
|
-
/* noop */
|
|
39
|
-
},
|
|
40
|
-
error: () => {
|
|
41
|
-
/* noop */
|
|
42
|
-
},
|
|
43
|
-
};
|