Files
n8n-enterprise-unlocked/packages/nodes-base/tsup.config.ts
कारतोफ्फेलस्क्रिप्ट™ 14979c1106 ci: Generate sourcemaps for nodes code again (no-changelog) (#14292)
2025-04-01 10:15:39 +02:00

54 lines
1.4 KiB
TypeScript

import { defineConfig } from 'tsup';
import glob from 'fast-glob';
import { resolve } from 'path';
import { readFile } from 'fs/promises';
const packagesDir = resolve(__dirname, '..');
const aiNodesDir = resolve(packagesDir, '@n8n', 'nodes-langchain');
const aiNodesFiles = await glob('nodes/**/*.ts', { cwd: aiNodesDir });
const aiNodesFilesContents = aiNodesFiles.map((filePath) =>
readFile(resolve(aiNodesDir, filePath), 'utf-8'),
);
// Files used in @n8n/nodes-langchain package
const aiNodesPackageImports = (await Promise.all(aiNodesFilesContents)).reduce(
(acc, fileContents) => {
const regex = /from\s+['"](n8n-nodes-base[^'"]+)['"]/g;
let match;
while ((match = regex.exec(fileContents)) !== null) {
acc.add(match[1]);
}
return acc;
},
new Set<string>(),
);
const aiNodesPackageDependencies = Array.from(aiNodesPackageImports).map(
(i) => i.replace('n8n-nodes-base/dist/', '') + '.ts',
);
const commonIgnoredFiles = ['!**/*.d.ts', '!**/*.test.ts'];
export default defineConfig([
{
entry: [
'{credentials,nodes,test,types,utils}/**/*.ts',
...commonIgnoredFiles,
...aiNodesPackageDependencies.map((path) => `!${path}`),
],
format: ['cjs'],
dts: false,
bundle: false,
sourcemap: true,
},
{
entry: [...aiNodesPackageDependencies, ...commonIgnoredFiles],
format: ['cjs'],
dts: true,
bundle: false,
sourcemap: true,
},
]);