Skip to content

Conversation

AguacateContreras
Copy link

Add --preserve-import-extensions flag to Plasmic CLI

Problem

Currently, the Plasmic sync process automatically strips file extensions from import statements in generated code. For example, if a file has import Component from "./Component.jsx", the sync will transform it to import Component from "./Component".

This behavior is problematic for projects that:

  • Use ESM modules with Node.js (which requires explicit file extensions)
  • Have specific bundler configurations that expect explicit extensions
  • Follow coding standards that mandate file extensions in imports
  • Use TypeScript with moduleResolution: "node16" or "nodenext"

Solution

This PR adds a new --preserve-import-extensions flag that prevents the CLI from stripping file extensions during the sync process.

Usage

plasmic sync --preserve-import-extensions

When enabled, import statements will preserve their original file extensions:
- Before: import Component from "./Component"
- After: import Component from "./Component.jsx"

Implementation

The flag is implemented by:
1. Adding a new global setting preserveImportExtensions
2. Adding the CLI flag to the sync command options
3. Modifying the makeImportPath() function to conditionally skip extension stripping when the flag is set

The default behavior remains unchanged (extensions are stripped) to maintain backward compatibility.

Copy link

vercel bot commented Oct 2, 2025

@AguacateContreras is attempting to deploy a commit to the Plasmic Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

github-actions bot commented Oct 2, 2025

Thank you for your submission, we really appreciate it! ❤️

Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. If you are contributing on behalf of a company, please contact us at [email protected] to sign a Corporate Contributor License Agreement.

You can sign the individual CLA by posting a comment with the below text.


I have read, agree to, and hereby sign Plasmic's Individual Contributor License Agreement


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@IcaroG IcaroG requested a review from sarahsga October 3, 2025 10:55
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.

1 participant