Skip to content
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

Feature Request: Support tailwind.config.js in default ESM format #98

Closed
johnbacon opened this issue Sep 28, 2023 · 1 comment · Fixed by #104
Closed

Feature Request: Support tailwind.config.js in default ESM format #98

johnbacon opened this issue Sep 28, 2023 · 1 comment · Fixed by #104

Comments

@johnbacon
Copy link
Contributor

johnbacon commented Sep 28, 2023

In my recent Laravel + Tailwind installation, tailwind.config.js is included as an ES Module. This causes the following error on blast:launch and blast:publish:

php artisan blast:launch
0/2 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] Reusing npm dependencies...
1/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░] Generating Stories...Error [ERR_REQUIRE_ESM]: require() of ES Module /e/server/gigsalad-laravel/laravel/tailwind.config.js 
from /e/server/gigsalad-laravel/laravel/vendor/area17/blast/src/resolveTailwindConfig.js not supported.
Instead change the require of tailwind.config.js in /e/server/gigsalad-laravel/laravel/vendor/area17/blast/src/resolveTailwindConfig.js to a dynamic import() 
which is available in all CommonJS modules.
    at Object.<anonymous> (/e/server/gigsalad-laravel/laravel/vendor/area17/blast/src/resolveTailwindConfig.js:6:18) {
  code: 'ERR_REQUIRE_ESM'
}

It appears Tailwind generates an ESM config file by default depending on other settings in your project: https://tailwindcss.com/docs/configuration#using-esm-or-type-script

And it looks like Laravel has configured package.json as type: module since version 10.2: https://github.com/laravel/laravel/blob/25070a3ffb175c15b59cd7f12289a9648165bba3/CHANGELOG.md?plain=1#L34

By supporting both ESM and CommonJS formats, Blast will be more able to provide documentation "out of the box" going forward.

@johnbacon johnbacon changed the title Feature Request: Support tailwind.config.js in ESM format Feature Request: Support tailwind.config.js in default ESM format Sep 28, 2023
@andresgutgon
Copy link

andresgutgon commented Jan 1, 2024

Maybe now that Tailwind v3.4.0 supports ESM is easier to fix this

By changing require by import here

 const config = import(process.env.CONFIGPATH)

It looks my ESM tailwind config loads correctly

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 a pull request may close this issue.

2 participants