Skip to content

Convert tailwind to ESM from CJS #2998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

FranjoMindek
Copy link
Contributor

@FranjoMindek FranjoMindek commented Jul 24, 2025

Description

Makes Wasp use ESM for Tailwind configuration files.

Fixes #2996 .

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

Update Waspc ChangeLog and version if needed

If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

Update example apps if needed

If you did code changes and updated an existing feature, make sure you satisfy the following:

  1. I updated waspc/examples/todoApp and its e2e tests as needed and manually checked it works correctly.

Update starter apps if needed

If you did code changes and updated an existing feature, make sure you satisfy the following:

  1. I updated starter skeleton as needed and manually checked it works correctly.
  2. I updated basic starter as needed and manually checked it works correctly.
  3. I updated todo-ts starter as needed and manually checked it works correctly.
  4. I updated embeddings starter as needed and manually checked it works correctly.
  5. I updated saas starter as needed and manually checked it works correctly.

Update e2e tests if needed

If you did code changes and changed Wasp's code generation logic, make sure you satisfy the following:

  1. I updated e2e tests as needed and manually checked they are correct.

Copy link

cloudflare-workers-and-pages bot commented Jul 24, 2025

Deploying wasp-docs-on-main with  Cloudflare Pages  Cloudflare Pages

Latest commit: bd65575
Status: ✅  Deploy successful!
Preview URL: https://b7341ce1.wasp-docs-on-main.pages.dev
Branch Preview URL: https://franjo-tailwind-ems.wasp-docs-on-main.pages.dev

View logs

@FranjoMindek FranjoMindek self-assigned this Jul 24, 2025
@infomiho
Copy link
Contributor

@FranjoMindek heads up, maybe we move Tailwind to user-land with 0.18.0 already. After we migrate the Vite version, I think it will 100% doable.

@FranjoMindek
Copy link
Contributor Author

FranjoMindek commented Jul 24, 2025

@FranjoMindek heads up, maybe we move Tailwind to user-land with 0.18.0 already. After we migrate the Vite version, I think it will 100% doable.

Yes, I asked this question specifically during the last meeting.
The response was though to solve this issue. A bit weird but I followed with the majority opinion.

@FranjoMindek FranjoMindek marked this pull request as ready for review July 24, 2025 11:58
@FranjoMindek FranjoMindek requested a review from sodic July 25, 2025 09:30
Copy link
Contributor

@sodic sodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense.

I haven't tested it and I haven't verified you got all occurences. I thought you all the tricks I know for finding stuff, so I trust you used them :)

The only real problem is the changelog mistake.


### ⚠️ Breaking Changes

- Wasp now uses CommonJS (CJS) instead of ECMAScript Modules (ESM) for Tailwind configuration files. ([#2998](https://github.com/wasp-lang/wasp/pull/2998))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opposite I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man.


### 1. Rename Tailwind Configuration Files

Update the file extensions from `.cjs` to `.js`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Update the file extensions from `.cjs` to `.js`:
Update the Tailwind configuration files' extensions from `.cjs` to `.js`:


### 2. Convert CJS Syntax to ESM

Update your `tailwind.config.cjs` file to use ESM.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But they already updated the extension, so it's no longer cjs. Perhaps this should be step 1?

Copy link
Contributor Author

@FranjoMindek FranjoMindek Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I wrote steps independently, but didn't catch this out of order mistake.
I'll leave the order, but fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched them in the end, so there is less confusion.

Comment on lines +26 to +27
<Tabs>
<TabItem value="before" label="Before">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is the final product, with both steps? Then I'd separate it into its own section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was meant to show only the cjs -> esm change, but since we already did step 1 i also changed the name.
Hm.

Maybe then I should switch the steps after all so there is less confusion.
And have this be tailwind.config.cjs for both instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched them, makes sense now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we bump the version too? Probably not, just double checking.

Copy link
Contributor Author

@FranjoMindek FranjoMindek Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had this discussion once during initial onboarding, I think the answer was that it doesn't really matter, since we always do it on release. Or something like that. But the answer was that it doesn't really matter.

@FranjoMindek
Copy link
Contributor Author

FranjoMindek commented Aug 1, 2025

I my initial search I did miss tailwind.config.cjs files outside of waspc and web, probably was my search restriction?
I've converted all examples apps + mage (also bumped up its wasp verison)

Copy link
Contributor

@sodic sodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please check the last two comments

@@ -10,4 +10,4 @@ module.exports = {
extend: {},
},
plugins: [],
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these files are missing newlines at the end. Can prettier take care of that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this file in the docs. Is that on purpose?
image

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.

Convert Tailwind config from CJS to ESM
3 participants