mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
refactor: Migrate nodes build system to tsup (no-changelog) (#14192)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { PostgresChatMessageHistory } from '@langchain/community/stores/message/postgres';
|
||||
import { BufferMemory, BufferWindowMemory } from 'langchain/memory';
|
||||
import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/transport';
|
||||
import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/transport/index';
|
||||
import type { PostgresNodeCredentials } from 'n8n-nodes-base/dist/nodes/Postgres/v2/helpers/interfaces';
|
||||
import { postgresConnectionTest } from 'n8n-nodes-base/dist/nodes/Postgres/v2/methods/credentialTest';
|
||||
import type {
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
type PGVectorStoreArgs,
|
||||
} from '@langchain/community/vectorstores/pgvector';
|
||||
import type { EmbeddingsInterface } from '@langchain/core/embeddings';
|
||||
import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/transport';
|
||||
import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/transport/index';
|
||||
import type { PostgresNodeCredentials } from 'n8n-nodes-base/dist/nodes/Postgres/v2/helpers/interfaces';
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import type pg from 'pg';
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
"clean": "rimraf dist .turbo",
|
||||
"dev": "pnpm run watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-metadata",
|
||||
"copy-nodes-json": "node ../../nodes-base/scripts/copy-nodes-json.js .",
|
||||
"build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-metadata",
|
||||
"format": "biome format --write .",
|
||||
"format:check": "biome ci .",
|
||||
"lint": "eslint nodes credentials utils --quiet",
|
||||
"lintfix": "eslint nodes credentials utils --fix",
|
||||
"watch": "tsc-watch -p tsconfig.build.json --onCompilationComplete \"tsc-alias -p tsconfig.build.json\" --onSuccess \"pnpm n8n-generate-metadata\"",
|
||||
"watch": "tsup --watch --tsconfig tsconfig.build.json --onSuccess \"pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-generate-metadata\"",
|
||||
"test": "jest",
|
||||
"test:dev": "jest --watch"
|
||||
},
|
||||
@@ -134,7 +135,8 @@
|
||||
"@types/pg": "^8.11.6",
|
||||
"@types/sanitize-html": "^2.11.0",
|
||||
"@types/temp": "^0.9.1",
|
||||
"n8n-core": "workspace:*"
|
||||
"n8n-core": "workspace:*",
|
||||
"tsup": "catalog:"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-sso-oidc": "3.666.0",
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
},
|
||||
"include": [
|
||||
"credentials/**/*.ts",
|
||||
"credentials/translations/**/*.json",
|
||||
"nodes/**/*.ts",
|
||||
"nodes/**/*.json",
|
||||
"credentials/translations/**/*.json",
|
||||
"types/*.ts"
|
||||
"test/**/*.ts",
|
||||
"types/**/*.ts",
|
||||
"utils/**/*.ts"
|
||||
],
|
||||
"exclude": ["nodes/**/*.test.ts", "test/**"]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"@n8n/typescript-config/tsconfig.backend.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@utils/*": ["./utils/*"]
|
||||
},
|
||||
@@ -11,7 +12,14 @@
|
||||
// TODO: remove all options below this line
|
||||
"useUnknownInCatchVariables": false
|
||||
},
|
||||
"include": ["credentials/**/*", "nodes/**/*", "utils/**/*.ts", "nodes/**/*.json", "types/*.ts"],
|
||||
"include": [
|
||||
"credentials/**/*.ts",
|
||||
"nodes/**/*.ts",
|
||||
"nodes/**/*.json",
|
||||
"test/**/*.ts",
|
||||
"types/**/*.ts",
|
||||
"utils/**/*.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../../workflow/tsconfig.build.json" },
|
||||
{ "path": "../../core/tsconfig.build.json" }
|
||||
|
||||
11
packages/@n8n/nodes-langchain/tsup.config.ts
Normal file
11
packages/@n8n/nodes-langchain/tsup.config.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineConfig({
|
||||
entry: ['{credentials,nodes,test,types,utils}/**/*.ts', '!**/*.d.ts', '!**/*.test.ts'],
|
||||
format: ['cjs'],
|
||||
clean: true,
|
||||
dts: false,
|
||||
bundle: false,
|
||||
});
|
||||
@@ -30,7 +30,7 @@
|
||||
"@n8n/vitest-config": "workspace:*",
|
||||
"@testing-library/jest-dom": "catalog:frontend",
|
||||
"@testing-library/user-event": "catalog:frontend",
|
||||
"tsup": "catalog:frontend",
|
||||
"tsup": "catalog:",
|
||||
"typescript": "catalog:frontend",
|
||||
"vite": "catalog:frontend",
|
||||
"vitest": "catalog:frontend"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"@vue/tsconfig": "catalog:frontend",
|
||||
"@vueuse/core": "catalog:frontend",
|
||||
"vue": "catalog:frontend",
|
||||
"tsup": "catalog:frontend",
|
||||
"tsup": "catalog:",
|
||||
"typescript": "catalog:frontend",
|
||||
"vite": "catalog:frontend",
|
||||
"vitest": "catalog:frontend",
|
||||
|
||||
@@ -5,14 +5,15 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist .turbo",
|
||||
"copy-nodes-json": "node scripts/copy-nodes-json.js .",
|
||||
"dev": "pnpm watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
|
||||
"build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
|
||||
"format": "biome format --write .",
|
||||
"format:check": "biome ci .",
|
||||
"lint": "eslint nodes credentials utils test --quiet && node ./scripts/validate-load-options-methods.js",
|
||||
"lintfix": "eslint nodes credentials utils test --fix",
|
||||
"watch": "tsc-watch -p tsconfig.build.json --onCompilationComplete \"tsc-alias -p tsconfig.build.json\" --onSuccess \"pnpm n8n-generate-metadata\"",
|
||||
"watch": "tsup --watch --tsconfig tsconfig.build.json --onSuccess \"pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-generate-metadata\"",
|
||||
"test": "jest"
|
||||
},
|
||||
"files": [
|
||||
|
||||
12
packages/nodes-base/scripts/copy-nodes-json.js
Normal file
12
packages/nodes-base/scripts/copy-nodes-json.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const glob = require('fast-glob');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function copyJsonFiles(baseDir) {
|
||||
const files = glob.sync('nodes/**/*.node.json', { cwd: baseDir });
|
||||
for (const file of files) {
|
||||
fs.copyFileSync(path.resolve(baseDir, file), path.resolve(baseDir, 'dist', file));
|
||||
}
|
||||
}
|
||||
|
||||
copyJsonFiles(process.argv[2]);
|
||||
@@ -6,10 +6,11 @@
|
||||
},
|
||||
"include": [
|
||||
"credentials/**/*.ts",
|
||||
"credentials/translations/**/*.json",
|
||||
"nodes/**/*.ts",
|
||||
"nodes/**/*.json",
|
||||
"credentials/translations/**/*.json",
|
||||
"types/**/*.ts"
|
||||
"types/**/*.ts",
|
||||
"utils/**/*.ts"
|
||||
],
|
||||
"exclude": ["nodes/**/*.test.ts", "credentials/**/*.test.ts", "test/**"]
|
||||
"exclude": ["nodes/**/*.test.ts", "credentials/**/*.test.ts", "utils/**/*.test.ts", "test/**"]
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
"include": [
|
||||
"credentials/**/*.ts",
|
||||
"nodes/**/*.ts",
|
||||
"nodes/**/*.json",
|
||||
"test/**/*.ts",
|
||||
"utils/**/*.ts",
|
||||
"types/**/*.ts"
|
||||
"types/**/*.ts",
|
||||
"utils/**/*.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../@n8n/imap/tsconfig.build.json" },
|
||||
|
||||
53
packages/nodes-base/tsup.config.ts
Normal file
53
packages/nodes-base/tsup.config.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
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'];
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineConfig([
|
||||
{
|
||||
entry: [
|
||||
'{credentials,nodes,test,types,utils}/**/*.ts',
|
||||
...commonIgnoredFiles,
|
||||
...aiNodesPackageDependencies.map((path) => `!${path}`),
|
||||
],
|
||||
format: ['cjs'],
|
||||
dts: false,
|
||||
bundle: false,
|
||||
},
|
||||
{
|
||||
entry: [...aiNodesPackageDependencies, ...commonIgnoredFiles],
|
||||
format: ['cjs'],
|
||||
dts: true,
|
||||
bundle: false,
|
||||
},
|
||||
]);
|
||||
13
pnpm-lock.yaml
generated
13
pnpm-lock.yaml
generated
@@ -63,6 +63,9 @@ catalogs:
|
||||
reflect-metadata:
|
||||
specifier: 0.2.2
|
||||
version: 0.2.2
|
||||
tsup:
|
||||
specifier: ^8.4.0
|
||||
version: 8.4.0
|
||||
uuid:
|
||||
specifier: 10.0.0
|
||||
version: 10.0.0
|
||||
@@ -103,9 +106,6 @@ catalogs:
|
||||
highlight.js:
|
||||
specifier: ^11.8.0
|
||||
version: 11.9.0
|
||||
tsup:
|
||||
specifier: ^8.4.0
|
||||
version: 8.4.0
|
||||
vite:
|
||||
specifier: ^6.2.0
|
||||
version: 6.2.1
|
||||
@@ -691,6 +691,9 @@ importers:
|
||||
n8n-core:
|
||||
specifier: workspace:*
|
||||
version: link:../../core
|
||||
tsup:
|
||||
specifier: 'catalog:'
|
||||
version: 8.4.0(@microsoft/api-extractor@7.52.1(@types/node@18.16.16))(jiti@1.21.0)(postcss@8.5.3)(typescript@5.8.2)
|
||||
|
||||
packages/@n8n/permissions:
|
||||
devDependencies:
|
||||
@@ -806,7 +809,7 @@ importers:
|
||||
specifier: catalog:frontend
|
||||
version: 14.6.1(@testing-library/dom@10.4.0)
|
||||
tsup:
|
||||
specifier: catalog:frontend
|
||||
specifier: 'catalog:'
|
||||
version: 8.4.0(@microsoft/api-extractor@7.52.1(@types/node@18.16.16))(jiti@1.21.0)(postcss@8.5.3)(typescript@5.8.2)
|
||||
typescript:
|
||||
specifier: ^5.8.2
|
||||
@@ -1397,7 +1400,7 @@ importers:
|
||||
specifier: catalog:frontend
|
||||
version: 10.11.0(vue@3.5.13(typescript@5.8.2))
|
||||
tsup:
|
||||
specifier: catalog:frontend
|
||||
specifier: 'catalog:'
|
||||
version: 8.4.0(@microsoft/api-extractor@7.52.1(@types/node@18.16.16))(jiti@1.21.0)(postcss@8.5.3)(typescript@5.8.2)
|
||||
typescript:
|
||||
specifier: ^5.8.2
|
||||
|
||||
@@ -24,6 +24,7 @@ catalog:
|
||||
nanoid: 3.3.8
|
||||
picocolors: 1.0.1
|
||||
reflect-metadata: 0.2.2
|
||||
tsup: ^8.4.0
|
||||
uuid: 10.0.0
|
||||
xml2js: 0.6.2
|
||||
xss: 1.0.15
|
||||
@@ -40,7 +41,6 @@ catalogs:
|
||||
'@vitest/coverage-v8': ^3.0.7
|
||||
'@vitejs/plugin-vue': ^5.2.1
|
||||
'@sentry/vue': ^8.33.1
|
||||
tsup: ^8.4.0
|
||||
typescript: ^5.8.2
|
||||
vite: ^6.2.0
|
||||
vitest: ^3.0.7
|
||||
|
||||
Reference in New Issue
Block a user