-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add ESM support to typescript config files #246
Comments
I think we already support ESM configs since 4.0. What we need to add for TS support? |
For a minimal example:
Fairly sure the problematic bit is the |
@NashJames can you do a investigation and find what we should change? |
Sure. I had a quick look at tailwind and found these two files: https://github.com/tailwindlabs/tailwindcss/blob/master/loadConfig.js An example of it being used here: https://github.com/tailwindlabs/tailwindcss/blob/e853901591c410ec0ce053c6fc57c92e4ff11548/src/cli/build/plugin.js#L151 I think the config just needs sending through this transformer |
Can you check that PR (which we already merged)? |
I did skim the whole project earlier, and just now that PR. I'm not exactly sure what you're asking but I'm not sure it includes anything to handle an export default? You seem to use |
@michael42 can you explain how we did ESM support in your PR and what to do to use it with @NashJames what is your |
I have no trouble doing this for any other configuration files (I'm assuming they all added support) so I don't think it'll be my setup being problematic. Unless you have trouble re-creating it?
{
"compilerOptions": {
"target": "es2022",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [{ "name": "next" }],
"paths": {
"@public/*": ["./public/*"],
"@components/*": ["./src/components/*"],
"@pages/*": ["./src/pages/*"],
"@data/*": ["./src/data/*"],
"@lib/*": ["./src/lib/*"]
},
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Nope |
@NashJames: Default exports should be supported, in fact (for most file types, it's the only kind of export that's supported, as even CommonJS files are loaded with @ai: I didn't, however, get a Supporting ESM in
|
@NashJames if you don’t have |
I'm agreed with everything said and am aware that there's no real benefit to TS config files. I'm quite happy to use JS or I'm experiencing a lot more libraries encouraging TS as their default config file format with ESM defaults and satisfy typing examples. I think there's a huge preference to use TS for everything now and it's a small surprise when you find something not supported out-of-the-box. Particularly, ESM and TS both supported but not at the same time was a little weird. Even though there's no material benefit to adding the support natively, it may save people time figuring the same out in the future. I reckon it is worth keeping open until either the API has an update or someone is looking to contribute. Especially since there's no harm to adding support (the transpilation cost should be next to nothing?). I'll make the issue title a little clearer since this only affects |
Thanks for the release |
Hi! It would be quite nice to start writing postcss config files with full ESM + TS support since it seems to be becoming standard with most popular tools. As an example, a
postcss.config.ts
file written as such:If it is any help, I noticed Tailwind made some small mention of the libraries they used to handle this in a blog post.
Thanks.
The text was updated successfully, but these errors were encountered: