fix: handle ESM default export in TS configs, fix backtick escaping, remove dead code#71
Open
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
…remove dead code - Fix ESM default export handling in createTypewindContext (fixes #69, #44): When a tailwind.config.ts uses `export default`, esbuild converts it to CJS with a .default property. The eval result was used directly without extracting .default, causing resolveConfig to receive the wrong object. - Fix incomplete backtick escaping in babel plugin: String.replace with a string argument only replaces the first occurrence. Changed to regex with global flag to escape all backticks in error messages. - Remove unused dead code from vite example (leftover from adc6629) Co-Authored-By: mokshitjain2006+coggittest2003@gmail.com <mokshitjain2006@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three bug fixes:
ESM default export not extracted for TypeScript configs (fixes Problems with ESM Tailwind config default export and handling of prefix in Typewind #69, fixes Generating types breaks with Tailwind CSS v
3.3#44): Whentailwind.config.tsusesexport default, esbuild converts it to CJS with a.defaultproperty.createTypewindContext()was passing the raw eval result (containing{ default: configObj }) toresolveConfig()instead of extractingconfigObj. Fixed by usingevalResult.default ?? evalResultto handle both ESM and CJS exports.Incomplete backtick escaping in babel plugin:
String.replace()with a string first argument only replaces the first occurrence. If the generated code contained multiple backticks, subsequent ones were unescaped, causing syntax errors in the eval'd error message. Fixed by using a regex with the global flag (/\/g`).Unused dead code in vite example: Removed leftover debugging variable (
const t = { a: 'b' }) committed in adc6629.Review & Testing Checklist for Human
tailwind.config.tsusingexport default { ... }and verifynpx typewind generateworks correctlynpm test— all 6 snapshot tests pass with these changesNotes
The ESM default export bug affects both
cli.ts(type generation) andevaluate.ts(babel plugin evaluation) since they sharecreateTypewindContext()fromutils.ts.Link to Devin session: https://staging.itsdev.in/sessions/4344bd04228f492c8a4e8f6b0a9f0e13
Requested by: @Mokshit06