Skip to content

feat: support transforming non-TS files (css, scss, svg, etc.)#474

Open
LouisLau-art wants to merge 1 commit into
LeDDGroup:masterfrom
LouisLau-art:feat/support-non-ts-files
Open

feat: support transforming non-TS files (css, scss, svg, etc.)#474
LouisLau-art wants to merge 1 commit into
LeDDGroup:masterfrom
LouisLau-art:feat/support-non-ts-files

Conversation

@LouisLau-art

Copy link
Copy Markdown

Closes #189

This PR adds support for transforming path aliases in non-TS files such as .css, .scss, .svg, .png, etc.

Changes

  • Updated resolveModuleName to check failedLookupLocations when TS fails to resolve a module.
  • If the module name matches a path alias and the corresponding file exists (after removing TS-specific extensions like .ts, .tsx), it is now correctly transformed to a relative path.
  • Added a test case in the general project to verify .css file transformation.

@kikiminyes

Copy link
Copy Markdown

Thanks for picking this up. I tested this branch locally:

  • yarn compile passes
  • yarn test currently fails in Transformer -> General Tests for test/projects/general/core/index.ts

The transform appears to emit the intended output for the new asset import (import "./styles.css";). The failing assertion looks like a test expectation issue: getExpected in test/tests/transformer/general.test.ts currently rewrites double-quoted alias specifiers, while the new fixture uses a single-quoted import (import '@core/styles.css';). Updating the fixture to double quotes or making getExpected handle both quote styles should make the regression test cover this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support non ts/tsx files like .css, .scss, .svg, .png, etc

2 participants