Skip to content

Commit 913281e

Browse files
fix(cli): avoid tsconfig paths/baseUrl conflict in workspace setup
Co-authored-by: EtienneLescot <215859519+EtienneLescot@users.noreply.github.com>
1 parent 08f9273 commit 913281e

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

packages/cli/src/core/assets/n8n-workflows.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Provides TypeScript types for .workflow.ts files without requiring
88
* a local installation of @n8n-as-code/transformer.
99
*
10-
* Mapped as the @n8n-as-code/transformer module via tsconfig "paths".
10+
* Exposes @n8n-as-code/transformer as an ambient module declaration.
1111
*/
1212

1313
// =========================================================================
@@ -160,6 +160,7 @@ export declare function node(options: NodeDecoratorOptions): PropertyDecorator;
160160
export declare function links(): MethodDecorator;
161161

162162

163+
declare module '@n8n-as-code/transformer' {
163164
// =========================================================================
164165
// WORKFLOW SETTINGS
165166
// =========================================================================

packages/cli/src/core/services/workspace-setup-service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ const TSCONFIG_CONTENT = JSON.stringify(
5757
target: 'ES2022',
5858
module: 'ESNext',
5959
moduleResolution: 'node',
60-
paths: {
61-
'*': ['./*'],
62-
'@n8n-as-code/transformer': ['./n8n-workflows.d.ts'],
63-
},
6460
experimentalDecorators: true,
6561
emitDecoratorMetadata: false,
6662
strict: false,

packages/cli/tests/unit/workspace-setup-service.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ afterEach(() => {
1414
});
1515

1616
describe('WorkspaceSetupService', () => {
17-
it('writes a minimal tsconfig without baseUrl and with wildcard paths mapping', () => {
17+
it('writes a minimal tsconfig without baseUrl and paths mapping', () => {
1818
const workflowDir = fs.mkdtempSync(path.join(os.tmpdir(), 'n8nac-workspace-'));
1919
tempDirs.push(workflowDir);
2020

@@ -25,7 +25,19 @@ describe('WorkspaceSetupService', () => {
2525

2626
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
2727
expect(tsconfig.compilerOptions.baseUrl).toBeUndefined();
28-
expect(tsconfig.compilerOptions.paths['*']).toEqual(['./*']);
29-
expect(tsconfig.compilerOptions.paths['@n8n-as-code/transformer']).toEqual(['./n8n-workflows.d.ts']);
28+
expect(tsconfig.compilerOptions.paths).toBeUndefined();
29+
});
30+
31+
it('writes declaration file with ambient module for @n8n-as-code/transformer', () => {
32+
const workflowDir = fs.mkdtempSync(path.join(os.tmpdir(), 'n8nac-workspace-'));
33+
tempDirs.push(workflowDir);
34+
35+
WorkspaceSetupService.ensureWorkspaceFiles(workflowDir);
36+
37+
const declarationPath = path.join(workflowDir, 'n8n-workflows.d.ts');
38+
expect(fs.existsSync(declarationPath)).toBe(true);
39+
40+
const declaration = fs.readFileSync(declarationPath, 'utf-8');
41+
expect(declaration).toContain("declare module '@n8n-as-code/transformer' {");
3042
});
3143
});

0 commit comments

Comments
 (0)