Support tsconfig `paths` in Template API imports (.figma.ts)

Đang mở
#408 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Lĩnh vực
tooling

Hướng nghiên cứu

Start by reading raw_template_bundler.ts and the bundleTemplateWithHelpers function mentioned in the issue, then trace how figma.config.json settings reach the esbuild call. Check the existing template import handling and tests for bundling or path aliases. Done means .figma.ts templates can resolve aliases configured with paths and publish without the relative-import error.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

API question

Please provide:

  • Code Connect CLI version: 2.0.0
  • Operating system: MacOS
  • Code Connect file, Figma design and/or relevant code snippet that could help us get more context
    • If you prefer not to share those publicly please reach out via the Figma support
Problem

Alias imports in .figma.ts fail during publish, even with paths set per docs.

And looking at the source, in raw_template_bundler.ts the bundleTemplateWithHelpers function passes an empty value for the tsconfig.json settings during the esbuild build, and it doesn't seem to specifically consume the paths field added in figma.config.json. I'm not sure if I've pinpointed this correctly, but is there a specific reason this decision was made?

Infos

figma.config.json:

{
    "$schema": "https://raw.githubusercontent.com/figma/code-connect/main/schemas/figma.config.schema.json",
    "codeConnect": {
        "parser": "react",
        "label": "TEST",
        "language": "typescript",
        "include": ["src/**/*.figma.ts"],
        "paths": {
            "~/*": ["./src/*"]
        }
    },
    "fileKey": "he4tiAGOKGPl0Fm56ZpJsy",
    "packageImportPath": "@vapor-ui/composites"
}

.figma.ts:

import { getProperties } from '~/utils/figma-utils';

export default {
    example: figma.code` ... `
}

error log:

npx figma connect publish

Config file found, parsing /Users/goorm/01_works/my-works/packages/composites using specified include globs
❌ /Users/goorm/01_works/my-works/packages/composites/src/components/dialog/dialog.figma.ts
TypeScript template files only support importing from 'figma' and relative helper files.
Found in /Users/goorm/01_works/my-works/packages/composites/src/components/dialog/dialog.figma.ts:
  import { getProperties } from '~/utils/figma-utils';

Use "const figma = require('figma')" or "import figma from 'figma'" for the Figma API.
Helper imports must use relative paths (for example: "./helpers").
Using label "TEST"
Using language "typescript"
No Code Connect files found in /Users/goorm/01_works/my-works/packages/composites - Make sure you have configured `include` and `exclude` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.
Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
126
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của figma/code-connect

Tất cả issue của figma/code-connect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.